diff --git a/scripts/test-vector-validation/main.js b/scripts/test-vector-validation/main.js index df48825..410d072 100644 --- a/scripts/test-vector-validation/main.js +++ b/scripts/test-vector-validation/main.js @@ -18,6 +18,18 @@ const validate = ajv.compile(vectorsSchema) function validateTestVectors() { const entries = fs.readdirSync(vectorsDir, { withFileTypes: true }) + function validateDescriptions(testData) { + // accumulate duplicates inside a map + const descriptions = new Set() + for (const vector of testData.vectors) { + if (descriptions.has(vector.description)) { + console.log("Duplicate description found: \"" + vector.description + "\". Descriptions are meant to be unique.") + process.exit(1) + } + descriptions.add(vector.description) + } + } + for (const entry of entries) { if (!entry.isDirectory()) { continue @@ -35,9 +47,9 @@ function validateTestVectors() { if (!validate(testData)) { console.log(`Validation failed for ${filePath}:`, validate.errors) process.exit(1) - } else { - console.log(`Validation passed for ${filePath}`) } + validateDescriptions(testData) + console.log(`Validation passed for ${filePath}`) } } } diff --git a/scripts/test-vector-validation/package-lock.json b/scripts/test-vector-validation/package-lock.json index 5dfa208..32528c9 100644 --- a/scripts/test-vector-validation/package-lock.json +++ b/scripts/test-vector-validation/package-lock.json @@ -4,6 +4,7 @@ "requires": true, "packages": { "": { + "name": "test-vector-validation", "dependencies": { "ajv": "8.12.0" } diff --git a/test-harness/sdks/web5-kt/build.gradle.kts b/test-harness/sdks/web5-kt/build.gradle.kts index fb303f8..4c08d4c 100644 --- a/test-harness/sdks/web5-kt/build.gradle.kts +++ b/test-harness/sdks/web5-kt/build.gradle.kts @@ -22,6 +22,7 @@ repositories { mavenCentral() maven(url = "https://jitpack.io") maven(url = "https://repo.danubetech.com/repository/maven-public/") + maven(url = "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/") } dependencies { diff --git a/web5-test-vectors/did-web/resolve.json b/web5-test-vectors/did-web/resolve.json new file mode 100644 index 0000000..3288428 --- /dev/null +++ b/web5-test-vectors/did-web/resolve.json @@ -0,0 +1,92 @@ +{ + "description": "did:web resolution", + "vectors": [ + { + "description": "resolves to a well known URL", + "input": { + "didUri": "did:web:example.com", + "mockServer": { + "https://example.com/.well-known/did.json": { + "id": "did:web:example.com" + } + } + }, + "output": { + "didResolutionMetadata": {}, + "didDocument": { + "id": "did:web:example.com" + } + } + }, + { + "description": "resolves to a URL with a path", + "input": { + "didUri": "did:web:w3c-ccg.github.io:user:alice", + "mockServer": { + "https://w3c-ccg.github.io/user/alice/did.json": { + "id": "did:web:w3c-ccg.github.io:user:alice" + } + } + }, + "output": { + "didResolutionMetadata": {}, + "didDocument": { + "id": "did:web:w3c-ccg.github.io:user:alice" + } + } + }, + { + "description": "resolves to a URL with a path and a port", + "input": { + "didUri": "did:web:example.com%3A3000:user:alice", + "mockServer": { + "https://example.com:3000/user/alice/did.json": { + "id": "did:web:example.com%3A3000:user:alice" + } + } + }, + "output": { + "didResolutionMetadata": {}, + "didDocument": { + "id": "did:web:example.com%3A3000:user:alice" + } + } + }, + { + "description": "methodNotSupported error returned when did method is not web", + "input": { + "didUri": "did:dht:gb46emk73wkenrut43ii67a3o5qctojcaucebth7r83pst6yeh8o" + }, + "output": { + "didResolutionMetadata": { + "error": "methodNotSupported" + } + }, + "errors": true + }, + { + "description": "notFound error returned when domain does not exist", + "input": { + "didUri": "did:web:doesnotexist.com" + }, + "output": { + "didResolutionMetadata": { + "error": "notFound" + } + }, + "errors": true + }, + { + "description": "invalidDid error returned for domain name with invalid character", + "input": { + "didUri": "did:web:invalidcharø.com" + }, + "output": { + "didResolutionMetadata": { + "error": "invalidDid" + } + }, + "errors": true + } + ] +} \ No newline at end of file diff --git a/web5-test-vectors/index.html b/web5-test-vectors/index.html index 44cc5e1..358a26d 100644 --- a/web5-test-vectors/index.html +++ b/web5-test-vectors/index.html @@ -33,6 +33,8 @@

DIDs

href="https://tbd54566975.github.io/sdk-development/web5-test-vectors/did-jwk/resolve.json" class="href">did:jwk resolve +
  • did:web resolve +
  • diff --git a/web5-test-vectors/vectors.schema.json b/web5-test-vectors/vectors.schema.json index 73a16a9..9ff336e 100644 --- a/web5-test-vectors/vectors.schema.json +++ b/web5-test-vectors/vectors.schema.json @@ -31,7 +31,8 @@ "default": false, "description": "Indicates whether the test vector is expected to produce an error. Defaults to false if not present." } - } + }, + "additionalProperties": false } } }