-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add e2e tests for different createCredentialOffer API variations (
#1476) Signed-off-by: Yurii Shynbuiev <[email protected]>
- Loading branch information
1 parent
1e19b04
commit 2ce192e
Showing
21 changed files
with
465 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
.../org/hyperledger/identus/issue/controller/CredentialSchemaReferenceParsingLogicSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.hyperledger.identus.issue.controller | ||
|
||
import org.hyperledger.identus.api.http.ErrorResponse | ||
import org.hyperledger.identus.issue.controller.http.CredentialSchemaRef as HTTPCredentialSchemaRef | ||
import org.hyperledger.identus.pollux.core.model.primitives.UriString | ||
import org.hyperledger.identus.pollux.core.model.schema.{ | ||
CredentialSchemaRef as DomainCredentialSchemaRef, | ||
CredentialSchemaRefType | ||
} | ||
import zio.test.* | ||
import zio.test.Assertion.* | ||
|
||
object CredentialSchemaReferenceParsingLogicSpec extends ZIOSpecDefault with CredentialSchemaReferenceParsingLogic { | ||
|
||
private val credentialSchemaExample = "http://example.com/schema" | ||
|
||
private def isErrorResponseWithDetailFieldEqualTo(detail: String) = | ||
isSubtype[ErrorResponse](hasField("detail", _.detail, isSome(equalTo(detail)))) | ||
|
||
def spec = suite("CredentialSchemaReferenceParsingLogic")( | ||
suite("parseCredentialSchemaRef_VCDM1_1")( | ||
test("should parse valid schema ref with correct type") { | ||
val httpSchemaRef = HTTPCredentialSchemaRef(credentialSchemaExample, "JsonSchemaValidator2018") | ||
for { | ||
result <- parseCredentialSchemaRef_VCDM1_1(None, Some(httpSchemaRef)).either | ||
expectedUriString <- UriString.make(credentialSchemaExample).toZIO | ||
} yield assert(result)( | ||
isRight( | ||
equalTo(DomainCredentialSchemaRef(CredentialSchemaRefType.JsonSchemaValidator2018, expectedUriString)) | ||
) | ||
) | ||
}, | ||
test("should fail for schema ref with invalid type") { | ||
val httpSchemaRef = HTTPCredentialSchemaRef(credentialSchemaExample, "InvalidType") | ||
for { | ||
result <- parseCredentialSchemaRef_VCDM1_1(None, Some(httpSchemaRef)).either | ||
} yield assert(result)( | ||
isLeft(isErrorResponseWithDetailFieldEqualTo("Invalid credentialSchema type: InvalidType.")) | ||
) | ||
}, | ||
test("should parse deprecated schema ID property") { | ||
for { | ||
result <- parseCredentialSchemaRef_VCDM1_1(Some(credentialSchemaExample), None).either | ||
expectedUriString <- UriString.make(credentialSchemaExample).toZIO | ||
} yield assert(result)( | ||
isRight( | ||
equalTo(DomainCredentialSchemaRef(CredentialSchemaRefType.JsonSchemaValidator2018, expectedUriString)) | ||
) | ||
) | ||
}, | ||
test("should fail if no schema is provided") { | ||
for { | ||
result <- parseCredentialSchemaRef_VCDM1_1(None, None).either | ||
} yield assert(result)( | ||
isLeft(isErrorResponseWithDetailFieldEqualTo("Credential schema property missed.")) | ||
) | ||
} | ||
), | ||
suite("parseSchemaIdForAnonCredsModelV1")( | ||
test("should parse schema ID property") { | ||
for { | ||
result <- parseSchemaIdForAnonCredsModelV1(None, Some(credentialSchemaExample)).either | ||
expectedUriString <- UriString.make(credentialSchemaExample).toZIO | ||
} yield assert(result)(isRight(equalTo(expectedUriString))) | ||
}, | ||
test("should parse deprecated schema ID property") { | ||
for { | ||
result <- parseSchemaIdForAnonCredsModelV1(Some(credentialSchemaExample), None).either | ||
expectedUriString <- UriString.make(credentialSchemaExample).toZIO | ||
} yield assert(result)(isRight(equalTo(expectedUriString))) | ||
}, | ||
test("should fail if no schema ID is provided") { | ||
for { | ||
result <- parseSchemaIdForAnonCredsModelV1(None, None).either | ||
} yield assert(result)( | ||
isLeft(isErrorResponseWithDetailFieldEqualTo("Credential schema property missed.")) | ||
) | ||
} | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.