Skip to content

Commit

Permalink
Merge "[FAB-10419] Incorrect filtering on affiliation"
Browse files Browse the repository at this point in the history
  • Loading branch information
mastersingh24 authored and Gerrit Code Review committed Jun 6, 2018
2 parents 133c961 + 5702371 commit b28fdfd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/certdbaccessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func (d *CertDBAccessor) GetCertificates(req server.CertificateRequest, callersA
if callersAffiliation != "" {
getCertificateSQL = "SELECT certificates.pem FROM certificates INNER JOIN users ON users.id = certificates.id"

whereConds = append(whereConds, "users.affiliation = ? OR users.affiliation LIKE ?")
whereConds = append(whereConds, "(users.affiliation = ? OR users.affiliation LIKE ?)")
args = append(args, callersAffiliation)
args = append(args, callersAffiliation+".%")
}
Expand Down
6 changes: 5 additions & 1 deletion lib/certdbaccessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestGetCertificatesDB(t *testing.T) {
certs, err = readRows(rows)
assert.Equal(t, 6, len(certs))

certReq = getCertReq("", "", "", false, false, nil, nil, nil, nil)
certReq = getCertReq("", "1111", "", false, false, nil, nil, nil, nil)
rows, err = ca.certDBAccessor.GetCertificates(certReq, "dept1")
assert.NoError(t, err, "Failed to get certificates from database")
certs, err = readRows(rows)
Expand Down Expand Up @@ -194,6 +194,10 @@ func populateCertificatesTable(t *testing.T, ca *CA) {
}, "testCertificate1", ca)
util.FatalError(t, err, "Failed to insert certificate with serial/AKI")

ca.registry.InsertUser(&spi.UserInfo{
Name: "testCertificate2",
Affiliation: "dept1",
})
err = testInsertCertificate(&certdb.CertificateRecord{
Serial: "1112",
AKI: "9876",
Expand Down

0 comments on commit b28fdfd

Please sign in to comment.