Skip to content

Commit

Permalink
test: partial oid4vci integration
Browse files Browse the repository at this point in the history
Signed-off-by: Allain Magyar <[email protected]>
  • Loading branch information
amagyar-iohk committed Sep 26, 2024
1 parent e532ba6 commit cc8a9bb
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 33 deletions.
4 changes: 0 additions & 4 deletions tests/integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ The configuration files are divided into the following sections:
* `agents`: contains the configuration for the agents (ICA) that will be started. By default, all agents will be destroyed after the test run is finished.
* `roles`: contains the configuration for the roles (Issuer, Holder, Verifier, Admin). A role can be assigned to one or more agents that we set in `agents` section or already running locally or in the cloud.

> You could keep services and agents running for debugging purposes
> by specifying `keep_running = true` for the service or agent
> in the configuration file and setting `TESTCONTAINERS_RYUK_DISABLED` variable to `true`.
Please, check [test/resources/configs/basic.conf](./src/test/resources/configs/basic.conf) for a quick example of a basic configuration.

You could explore the `configs` directory for more complex examples.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
testImplementation("io.ktor:ktor-server-netty:2.3.0")
testImplementation("io.ktor:ktor-client-apache:2.3.0")
// RestAPI client
testImplementation("org.hyperledger.identus:cloud-agent-client-kotlin:1.39.0-e077cdd")
testImplementation("org.hyperledger.identus:cloud-agent-client-kotlin:0.0.1-SNAPSHOT")
// Test helpers library
testImplementation("io.iohk.atala:atala-automation:0.4.0")
// Hoplite for configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config.services
import com.sksamuel.hoplite.ConfigAlias
import config.VaultAuthType
import org.testcontainers.containers.ComposeContainer
import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.wait.strategy.Wait
import java.io.*

Expand All @@ -16,7 +17,6 @@ data class Agent(
@ConfigAlias("prism_node") val prismNode: VerifiableDataRegistry?,
val keycloak: Keycloak?,
val vault: Vault?,
@ConfigAlias("keep_running") override val keepRunning: Boolean = false,
) : ServiceBase() {

override val logServices = listOf("identus-cloud-agent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ data class Keycloak(
val realm: String = "atala-demo",
@ConfigAlias("client_id") val clientId: String = "cloud-agent",
@ConfigAlias("client_secret") val clientSecret: String = "cloud-agent-secret",
@ConfigAlias("keep_running") override val keepRunning: Boolean = false,
@ConfigAlias("compose_file") val keycloakComposeFile: String = "src/test/resources/containers/keycloak.yml",
@ConfigAlias("logger_name") val loggerName: String = "keycloak",
@ConfigAlias("extra_envs") val extraEnvs: Map<String, String> = emptyMap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ abstract class ServiceBase : Startable {
}

abstract val container: ComposeContainer
abstract val keepRunning: Boolean

open val logServices: List<String> = emptyList()
private val logWriters: MutableList<Writer> = mutableListOf()
Expand All @@ -41,8 +40,6 @@ abstract class ServiceBase : Startable {
logWriters.forEach {
it.close()
}
if (!keepRunning) {
container.stop()
}
container.stop()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import java.io.File
data class Vault(
@ConfigAlias("http_port") val httpPort: Int,
@ConfigAlias("vault_auth_type") val authType: VaultAuthType = VaultAuthType.APP_ROLE,
@ConfigAlias("keep_running") override val keepRunning: Boolean = false,
) : ServiceBase() {
private val logger = Logger.get<Vault>()
override val logServices: List<String> = listOf("vault")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import java.io.File
data class VerifiableDataRegistry(
@ConfigAlias("http_port") val httpPort: Int,
val version: String,
@ConfigAlias("keep_running") override val keepRunning: Boolean = false,
) : ServiceBase() {
override val logServices: List<String> = listOf("prism-node")
private val vdrComposeFile = "src/test/resources/containers/vdr.yml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class UpdateDidSteps {
Get.resource("/dids/${actor.recall<String>("shortFormDid")}"),
)
val service = SerenityRest.lastResponse().get<DIDResolutionResult>().didDocument!!.service!!
service.any { it.serviceEndpoint.value.contains(serviceUrl) }
service.any { it.serviceEndpoint.getString().contains(serviceUrl) }
},
equalTo(true),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.nimbusds.jose.JWSAlgorithm
import com.nimbusds.jose.jwk.JWK
import eu.europa.ec.eudi.openid4vci.*
import interactions.Post
import interactions.body
import io.cucumber.java.en.Then
import io.cucumber.java.en.When
import io.iohk.atala.automation.extensions.get
Expand Down Expand Up @@ -40,16 +41,13 @@ class IssueCredentialSteps {
issuer.recall("longFormDid")
}
issuer.attemptsTo(
Post.to("/oid4vci/issuers/${credentialIssuer.id}/credential-offers")
.with {
it.body(
CredentialOfferRequest(
credentialConfigurationId = configurationId,
issuingDID = did,
claims = claims,
),
)
},
Post.to("/oid4vci/issuers/${credentialIssuer.id}/credential-offers").body(
CredentialOfferRequest(
credentialConfigurationId = configurationId,
issuingDID = did,
claims = claims,
),
),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_CREATED),
)
val offerUri = SerenityRest.lastResponse().get<CredentialOfferResponse>().credentialOffer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
package steps.oid4vci

import interactions.*
import io.cucumber.java.en.*
import interactions.Delete
import interactions.Get
import interactions.Patch
import interactions.Post
import io.cucumber.java.en.Given
import io.cucumber.java.en.Then
import io.cucumber.java.en.When
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.*
import org.hyperledger.identus.client.models.AuthorizationServer
import org.hyperledger.identus.client.models.CreateCredentialIssuerRequest
import org.hyperledger.identus.client.models.CredentialIssuer
import org.hyperledger.identus.client.models.CredentialIssuer1
import org.hyperledger.identus.client.models.CredentialIssuerPage
import org.hyperledger.identus.client.models.IssuerMetadata
import org.hyperledger.identus.client.models.PatchAuthorizationServer
import org.hyperledger.identus.client.models.PatchCredentialIssuerRequest

class ManageIssuerSteps {
private val UPDATE_AUTH_SERVER_URL = "http://example.com"
Expand Down Expand Up @@ -44,7 +56,7 @@ class ManageIssuerSteps {

@Then("{actor} sees the oid4vci issuer exists on the agent")
fun issuerSeesCredentialIssuerExists(issuer: Actor) {
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer")
val credentialIssuer = issuer.recall<CredentialIssuer1>("oid4vciCredentialIssuer")
issuer.attemptsTo(
Get("/oid4vci/issuers"),
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_OK),
Expand Down Expand Up @@ -94,9 +106,26 @@ class ManageIssuerSteps {
)
}

@When("{actor} tries to create oid4vci issuer with '{}', '{}', '{}' and '{}'")
fun issuerTriesToCreateOIDCIssuer(
issuer: Actor,
id: String?,
url: String?,
clientId: String?,
clientSecret: String?
) {
println("$issuer $id $url $clientId $clientSecret")
println(url == null)
}

@Then("{actor} should see the oid4vci error '{}'")
fun issuerShouldSeeTheOIDC4VCIError(issuer: Actor, error: String) {

}

@Then("{actor} sees the oid4vci issuer updated with new values")
fun issuerSeesUpdatedCredentialIssuer(issuer: Actor) {
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer")
val credentialIssuer = issuer.recall<CredentialIssuer1>("oid4vciCredentialIssuer")
issuer.attemptsTo(
Get("/oid4vci/issuers"),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK),
Expand All @@ -123,7 +152,7 @@ class ManageIssuerSteps {

@Then("{actor} cannot see the oid4vci issuer on the agent")
fun issuerCannotSeeCredentialIssuer(issuer: Actor) {
val credentialIssuer = issuer.recall<CredentialIssuer>("oid4vciCredentialIssuer")
val credentialIssuer = issuer.recall<CredentialIssuer1>("oid4vciCredentialIssuer")
issuer.attemptsTo(
Get("/oid4vci/issuers"),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
@oid4vci
Feature: Manage OID4VCI credential issuer

Scenario: Successfully create credential issuer
Scenario: Successfully create credential issuer
When Issuer creates an oid4vci issuer
Then Issuer sees the oid4vci issuer exists on the agent
And Issuer sees the oid4vci issuer on IssuerMetadata endpoint

Scenario: Successfully update credential issuer
Scenario: Successfully update credential issuer
Given Issuer has an existing oid4vci issuer
When Issuer updates the oid4vci issuer
Then Issuer sees the oid4vci issuer updated with new values
And Issuer sees the oid4vci IssuerMetadata endpoint updated with new values

Scenario: Successfully delete credential issuer
Scenario: Successfully delete credential issuer
Given Issuer has an existing oid4vci issuer
When Issuer deletes the oid4vci issuer
Then Issuer cannot see the oid4vci issuer on the agent
And Issuer cannot see the oid4vci IssuerMetadata endpoint

@test
Scenario Outline: Create issuer with wrong data should not work
When Issuer tries to create oid4vci issuer with '<id>', '<url>', '<clientId>' and '<clientSecret>'
Then Issuer should see the oid4vci error '<error>'
Examples:
| id | url | clientId | clientSecret | error |
| null | null | null | null | |
| | | | | |
| empty | empty | empty | empty | |
| 1 | {} | null | null | |

0 comments on commit cc8a9bb

Please sign in to comment.