-
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.
test: add oid4vci issuer crud scenario (#1234)
Signed-off-by: Hyperledger Bot <[email protected]> Signed-off-by: Pat Losoponkul <[email protected]> Co-authored-by: Hyperledger Bot <[email protected]> Signed-off-by: Pat Losoponkul <[email protected]>
- Loading branch information
1 parent
4e25aac
commit 6c61a60
Showing
12 changed files
with
309 additions
and
8 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
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
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
75 changes: 75 additions & 0 deletions
75
tests/integration-tests/src/test/kotlin/steps/oid4vci/ManageCredentialConfigSteps.kt
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,75 @@ | ||
package steps.oid4vci | ||
|
||
import common.CredentialSchema | ||
import interactions.* | ||
import io.cucumber.java.en.* | ||
import io.iohk.atala.automation.extensions.get | ||
import io.iohk.atala.automation.serenity.ensure.Ensure | ||
import net.serenitybdd.rest.SerenityRest | ||
import net.serenitybdd.screenplay.Actor | ||
import org.apache.http.HttpStatus | ||
import org.hyperledger.identus.client.models.* | ||
|
||
class ManageCredentialConfigSteps { | ||
@Given("{actor} has {string} credential configuration created from {}") | ||
fun issuerHasExistingCredentialConfig(issuer: Actor, configurationId: String, schema: CredentialSchema) { | ||
ManageIssuerSteps().issuerHasExistingCredentialIssuer(issuer) | ||
issuerCreateCredentialConfiguration(issuer, schema, configurationId) | ||
} | ||
|
||
@When("{actor} uses {} to create a credential configuration {string}") | ||
fun issuerCreateCredentialConfiguration(issuer: Actor, schema: CredentialSchema, configurationId: String) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
val schemaGuid = issuer.recall<String>(schema.name) | ||
val baseUrl = issuer.recall<String>("baseUrl") | ||
issuer.attemptsTo( | ||
Post.to("/oid4vci/issuers/${credentialIssuer.id}/credential-configurations") | ||
.with { | ||
it.body( | ||
CreateCredentialConfigurationRequest( | ||
configurationId = configurationId, | ||
format = CredentialFormat.JWT_VC_JSON, | ||
schemaId = "$baseUrl/schema-registry/schemas/$schemaGuid/schema", | ||
), | ||
) | ||
}, | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_CREATED), | ||
) | ||
} | ||
|
||
@When("{actor} deletes {string} credential configuration") | ||
fun issuerDeletesCredentialConfiguration(issuer: Actor, configurationId: String) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Delete("/oid4vci/issuers/${credentialIssuer.id}/credential-configurations/$configurationId"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK), | ||
) | ||
} | ||
|
||
@Then("{actor} sees the {string} configuration on IssuerMetadata endpoint") | ||
fun issuerSeesCredentialConfiguration(issuer: Actor, configurationId: String) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Get("/oid4vci/issuers/${credentialIssuer.id}/.well-known/openid-credential-issuer"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK), | ||
) | ||
val metadata = SerenityRest.lastResponse().get<IssuerMetadata>() | ||
val credConfig = metadata.credentialConfigurationsSupported[configurationId]!! | ||
issuer.attemptsTo( | ||
Ensure.that(credConfig.scope).isEqualTo(configurationId), | ||
) | ||
} | ||
|
||
@Then("{actor} cannot see the {string} configuration on IssuerMetadata endpoint") | ||
fun issuerCannotSeeCredentialConfiguration(issuer: Actor, configurationId: String) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Get("/oid4vci/issuers/${credentialIssuer.id}/.well-known/openid-credential-issuer"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK), | ||
) | ||
val metadata = SerenityRest.lastResponse().get<IssuerMetadata>() | ||
issuer.attemptsTo( | ||
Ensure.that(metadata.credentialConfigurationsSupported.keys).doesNotContain(configurationId), | ||
) | ||
} | ||
} |
146 changes: 146 additions & 0 deletions
146
tests/integration-tests/src/test/kotlin/steps/oid4vci/ManageIssuerSteps.kt
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,146 @@ | ||
package steps.oid4vci | ||
|
||
import interactions.* | ||
import io.cucumber.java.en.* | ||
import io.iohk.atala.automation.extensions.get | ||
import io.iohk.atala.automation.serenity.ensure.Ensure | ||
import net.serenitybdd.rest.SerenityRest | ||
import net.serenitybdd.screenplay.Actor | ||
import org.apache.http.HttpStatus | ||
import org.apache.http.HttpStatus.SC_CREATED | ||
import org.apache.http.HttpStatus.SC_OK | ||
import org.hyperledger.identus.client.models.* | ||
|
||
class ManageIssuerSteps { | ||
private val UPDATE_AUTH_SERVER_URL = "http://example.com" | ||
private val UPDATE_AUTH_SERVER_CLIENT_ID = "foo" | ||
private val UPDATE_AUTH_SERVER_CLIENT_SECRET = "bar" | ||
|
||
@Given("{actor} has an existing oid4vci issuer") | ||
fun issuerHasExistingCredentialIssuer(issuer: Actor) { | ||
issuerCreateCredentialIssuer(issuer) | ||
} | ||
|
||
@When("{actor} creates an oid4vci issuer") | ||
fun issuerCreateCredentialIssuer(issuer: Actor) { | ||
issuer.attemptsTo( | ||
Post.to("/oid4vci/issuers") | ||
.with { | ||
it.body( | ||
CreateCredentialIssuerRequest( | ||
authorizationServer = AuthorizationServer( | ||
url = issuer.recall("OID4VCI_AUTH_SERVER_URL"), | ||
clientId = issuer.recall("OID4VCI_AUTH_SERVER_CLIENT_ID"), | ||
clientSecret = issuer.recall("OID4VCI_AUTH_SERVER_CLIENT_SECRET"), | ||
), | ||
), | ||
) | ||
}, | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_CREATED), | ||
) | ||
val credentialIssuer = SerenityRest.lastResponse().get<CredentialIssuer>() | ||
issuer.remember("oid4vciCredentialIssuer", credentialIssuer) | ||
} | ||
|
||
@Then("{actor} sees the oid4vci issuer exists on the agent") | ||
fun issuerSeesCredentialIssuerExists(issuer: Actor) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Get("/oid4vci/issuers"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_OK), | ||
) | ||
val matchedIssuers = SerenityRest.lastResponse().get<CredentialIssuerPage>().contents!! | ||
.filter { it.id == credentialIssuer.id } | ||
issuer.attemptsTo( | ||
Ensure.that(matchedIssuers).hasSize(1), | ||
) | ||
} | ||
|
||
@Then("{actor} sees the oid4vci issuer on IssuerMetadata endpoint") | ||
fun issuerSeesCredentialIssuerExistsOnMetadataEndpoint(issuer: Actor) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Get("/oid4vci/issuers/${credentialIssuer.id}/.well-known/openid-credential-issuer"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_OK), | ||
) | ||
} | ||
|
||
@When("{actor} updates the oid4vci issuer") | ||
fun issuerUpdateCredentialIssuer(issuer: Actor) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Patch.to("/oid4vci/issuers/${credentialIssuer.id}") | ||
.with { | ||
it.body( | ||
PatchCredentialIssuerRequest( | ||
authorizationServer = PatchAuthorizationServer( | ||
url = UPDATE_AUTH_SERVER_URL, | ||
clientId = UPDATE_AUTH_SERVER_CLIENT_ID, | ||
clientSecret = UPDATE_AUTH_SERVER_CLIENT_SECRET, | ||
), | ||
), | ||
) | ||
}, | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK), | ||
) | ||
} | ||
|
||
@When("{actor} deletes the oid4vci issuer") | ||
fun issuerDeleteCredentialIssuer(issuer: Actor) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Delete("/oid4vci/issuers/${credentialIssuer.id}"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK), | ||
) | ||
} | ||
|
||
@Then("{actor} sees the oid4vci issuer updated with new values") | ||
fun issuerSeesUpdatedCredentialIssuer(issuer: Actor) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Get("/oid4vci/issuers"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK), | ||
) | ||
val updatedIssuer = SerenityRest.lastResponse().get<CredentialIssuerPage>().contents!! | ||
.find { it.id == credentialIssuer.id }!! | ||
issuer.attemptsTo( | ||
Ensure.that(updatedIssuer.authorizationServerUrl).isEqualTo(UPDATE_AUTH_SERVER_URL), | ||
) | ||
} | ||
|
||
@Then("{actor} sees the oid4vci IssuerMetadata endpoint updated with new values") | ||
fun issuerSeesUpdatedCredentialIssuerMetadata(issuer: Actor) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Get("/oid4vci/issuers/${credentialIssuer.id}/.well-known/openid-credential-issuer"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK), | ||
) | ||
val metadata = SerenityRest.lastResponse().get<IssuerMetadata>() | ||
issuer.attemptsTo( | ||
Ensure.that(metadata.authorizationServers?.first()!!).isEqualTo(UPDATE_AUTH_SERVER_URL), | ||
) | ||
} | ||
|
||
@Then("{actor} cannot see the oid4vci issuer on the agent") | ||
fun issuerCannotSeeCredentialIssuer(issuer: Actor) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Get("/oid4vci/issuers"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK), | ||
) | ||
val matchedIssuers = SerenityRest.lastResponse().get<CredentialIssuerPage>().contents!! | ||
.filter { it.id == credentialIssuer.id } | ||
issuer.attemptsTo( | ||
Ensure.that(matchedIssuers).isEmpty(), | ||
) | ||
} | ||
|
||
@Then("{actor} cannot see the oid4vci IssuerMetadata endpoint") | ||
fun issuerCannotSeeIssuerMetadata(issuer: Actor) { | ||
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer") | ||
issuer.attemptsTo( | ||
Get("/oid4vci/issuers/${credentialIssuer.id}/.well-known/openid-credential-issuer"), | ||
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_NOT_FOUND), | ||
) | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
tests/integration-tests/src/test/resources/containers/keycloak-oid4vci.yml
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,13 @@ | ||
--- | ||
version: "3.8" | ||
|
||
services: | ||
keycloak: | ||
image: ghcr.io/hyperledger/identus-keycloak-plugins:0.1.0 | ||
ports: | ||
- "${KEYCLOAK_HTTP_PORT}:8080" | ||
environment: | ||
KEYCLOAK_ADMIN: admin | ||
KEYCLOAK_ADMIN_PASSWORD: admin | ||
IDENTUS_URL: | ||
command: start-dev --health-enabled=true --hostname-url=http://localhost:${KEYCLOAK_HTTP_PORT} |
16 changes: 16 additions & 0 deletions
16
tests/integration-tests/src/test/resources/features/oid4vci/manage_credential_config.feature
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,16 @@ | ||
@oid4vci | ||
Feature: Manage OID4VCI credential configuration | ||
|
||
Background: | ||
Given Issuer has a published DID for JWT | ||
And Issuer has published STUDENT_SCHEMA schema | ||
And Issuer has an existing oid4vci issuer | ||
|
||
Scenario: Successfully create credential configuration | ||
When Issuer uses STUDENT_SCHEMA to create a credential configuration "StudentProfile" | ||
Then Issuer sees the "StudentProfile" configuration on IssuerMetadata endpoint | ||
|
||
Scenario: Successfully delete credential configuration | ||
Given Issuer has "StudentProfile" credential configuration created from STUDENT_SCHEMA | ||
When Issuer deletes "StudentProfile" credential configuration | ||
Then Issuer cannot see the "StudentProfile" configuration on IssuerMetadata endpoint |
Oops, something went wrong.