Skip to content

Commit

Permalink
add test for GetUnexpiredCertificatesByLabel
Browse files Browse the repository at this point in the history
  • Loading branch information
nickysemenza committed Oct 3, 2022
1 parent a9a2c2e commit e0c522a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions certdb/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ func testInsertCertificateAndGetUnexpiredCertificate(ta TestAccessor, t *testing

expiry := time.Now().Add(time.Minute)
want := certdb.CertificateRecord{
PEM: "fake cert data",
Serial: "fake serial 2",
AKI: fakeAKI,
Status: "good",
Reason: 0,
Expiry: expiry,
PEM: "fake cert data",
Serial: "fake serial 2",
AKI: fakeAKI,
Status: "good",
Reason: 0,
Expiry: expiry,
CALabel: "foo",
}

if err := ta.Accessor.InsertCertificate(want); err != nil {
Expand Down Expand Up @@ -153,6 +154,14 @@ func testInsertCertificateAndGetUnexpiredCertificate(ta TestAccessor, t *testing
if len(unexpired) != 1 {
t.Error("Should have 1 unexpired certificate record:", len(unexpired))
}

unexpiredFiltered, err := ta.Accessor.GetUnexpiredCertificatesByLabel([]string{"foo"})
require.NoError(t, err)
require.Len(t, unexpiredFiltered, 1)
unexpiredFiltered, err = ta.Accessor.GetUnexpiredCertificatesByLabel([]string{"bar"})
require.NoError(t, err)
require.Len(t, unexpiredFiltered, 0)

}
func testInsertCertificateAndGetUnexpiredCertificateNullCommonName(ta TestAccessor, t *testing.T) {
ta.Truncate()
Expand Down

0 comments on commit e0c522a

Please sign in to comment.