Skip to content

Commit

Permalink
[FABN-1379] Fix certificate service tests
Browse files Browse the repository at this point in the history
When asking the CA for all certificates, the CA
will return all certificates for the requesting
users affiliation. The test assumes that it will
return all certificates for the requesting user.

If other tests enroll other users with the same
affiliation, they will also be returned - so the
test is invalid and needs changing.

Signed-off-by: Simon Stone <[email protected]>
Change-Id: I0254d061bb7e7497c2aecf3c6ace48d5cb53a254
  • Loading branch information
Simon Stone authored and harrisob committed Sep 20, 2019
1 parent c24a331 commit 35edb79
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/integration/fabric-ca-certificate-service-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ test('\n\n ** FabricCAServices - CertificateService Test **\n\n', async (t) => {

resp = await certificateService1.getCertificates(null, user1);
t.equal(resp.success, true, 'certificate service should response success');
t.equal(resp.result.certs.length, 1, 'the new created user can only view the certificate it owns');
// all certificates for this users affiliation will be returned; if we're the first
// test to enroll a user for org2 then we could assert just one certificate, but if
// another test runs first (as the CA is for all tests) it'll fail. just check we can
// see at least one certificate!
t.equal(resp.result.certs.length > 0, true, 'the new created user can also view certificates');

// get certificate by enrollment id, user1._name = user1.enrollmentId
resp = await certificateService1.getCertificates({id: user1.getName()}, user1);
Expand Down Expand Up @@ -94,7 +98,7 @@ async function createAndEnrollIdentity(ca, admin) {
const identityService = ca.newIdentityService();

const req = {
enrollmentID: 'user_' + Math.random().toFixed(3).toString(),
enrollmentID: 'user_' + Math.floor(Math.random() * 1000),
enrollmentSecret: 'userpw',
affiliation,
// set this identity can manage identities of the role user
Expand Down

0 comments on commit 35edb79

Please sign in to comment.