w3c-ccg / vc-api-issuer-test-suite

Test Suite for Issuers that implement the VC HTTP API
https://w3c-ccg.github.io/vc-api-issuer-test-suite/
0 stars 7 forks source link

credentialSubject maybe an object or an Array of objects #26

Closed aljones15 closed 1 year ago

aljones15 commented 2 years ago

https://www.w3.org/TR/vc-data-model/#credential-subject

Currently our assertion on credentialSubject is that it is an object, but it can also be an Array (possibly because it is RDF).

Chai is a bit smart about this:

[].should.be.an('object') fails.

however typeof [] is object

So we need an assertion that ensures credentialSubject is either an object that is not an Array or is an Array that contains only objects.

This should probably be something like this:

if(Array.isArray(vc.credentialSubject)) {
  for(const subject of vc.credentialSubject) {
    subject.should.be.an('object');
  }
 return;
}
vc.credentialSubject.should.be.an('object');

That sounds like a new assertion which might be worth looking into.

aljones15 commented 1 year ago

closing as this has been addressed by PR 24