Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add present proof tests and bug fixes #393

Merged
merged 10 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 17 additions & 9 deletions .github/workflows/e2e-tests.yml
Expand Up @@ -57,6 +57,13 @@ jobs:
version: v2.12.2 # defaults to 'latest'
legacy: true # will also install in PATH as `docker-compose`

- name: Update .env file to the latest version
env:
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
run: |
../../infrastructure/local/update_env.sh
cat ../../infrastructure/local/.env

- name: Start services for issuer
env:
PORT: 8080
Expand Down Expand Up @@ -121,7 +128,6 @@ jobs:
TESTS_WITH_ERRORS=0
if [ -f "${JSON_RESULTS}" ]; then
TOTAL_TESTS="$(cat ${JSON_RESULTS} | jq '.results.counts.total')"
SUCCESS_TESTS="$(cat ${JSON_RESULTS} | jq '.results.counts.success')"
PENDING_TESTS="$(cat ${JSON_RESULTS} | jq '.results.counts.pending')"
SKIPPED_TESTS="$(cat ${JSON_RESULTS} | jq '.results.counts.skipped')"
IGNORED_TESTS="$(cat ${JSON_RESULTS} | jq '.results.counts.ignored')"
Expand All @@ -131,16 +137,18 @@ jobs:
CONCLUSION=success
fi
fi
echo "conclusion=${CONCLUSION}" >> $GITHUB_OUTPUT
echo "tests=${TOTAL_TESTS}" >> $GITHUB_OUTPUT
echo "failures=${FAILED_TESTS}" >> $GITHUB_OUTPUT
echo "errors=${TESTS_WITH_ERRORS}" >> $GITHUB_OUTPUT
echo "pending=${PENDING_TESTS}" >> $GITHUB_OUTPUT
echo "skipped=${SKIPPED_TESTS}" >> $GITHUB_OUTPUT
echo "ignored=${IGNORED_TESTS}" >> $GITHUB_OUTPUT
{
echo "conclusion=${CONCLUSION}";
echo "tests=${TOTAL_TESTS}";
echo "failures=${FAILED_TESTS}";
echo "errors=${TESTS_WITH_ERRORS}";
echo "pending=${PENDING_TESTS}";
echo "skipped=${SKIPPED_TESTS}";
echo "ignored=${IGNORED_TESTS}";
} >> "$GITHUB_OUTPUT"

- name: Slack Notification
if: github.ref_name == 'master'
if: github.ref_name == 'main'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: atala-qa-results
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/local/.env
@@ -1,5 +1,5 @@
MERCURY_MEDIATOR_VERSION=0.2.0
IRIS_SERVICE_VERSION=0.1.0
PRISM_AGENT_VERSION=0.40.0
PRISM_AGENT_VERSION=0.43.0
PRISM_NODE_VERSION=v2.0.0
PORT=80
1 change: 0 additions & 1 deletion tests/e2e-tests/settings.gradle.kts
@@ -1,3 +1,2 @@

rootProject.name = "e2e-tests"

8 changes: 7 additions & 1 deletion tests/e2e-tests/src/main/kotlin/api_models/Connection.kt
@@ -1,5 +1,4 @@
package api_models

data class Connection(
var connectionId: String = "",
var createdAt: String = "",
Expand All @@ -13,3 +12,10 @@ data class Connection(
var theirDid: String = "",
var role: String = "",
)

object ConnectionState {
const val INVITATION_GENERATED = "InvitationGenerated"
const val CONNECTION_REQUEST_PENDING = "ConnectionRequestPending"
const val CONNECTION_RESPONSE_SENT = "ConnectionResponseSent"
const val CONNECTION_RESPONSE_RECEIVED = "ConnectionResponseReceived"
}
@@ -1,6 +1,5 @@
package api_models

data class CreateManagedDidRequest(
val documentTemplate: DocumentTemplate
val documentTemplate: DocumentTemplate,
)

4 changes: 2 additions & 2 deletions tests/e2e-tests/src/main/kotlin/api_models/Credential.kt
Expand Up @@ -11,8 +11,8 @@ data class Credential(
var subjectId: String = "",
var updatedAt: String = "",
var validityPeriod: Int = 0,
var claims: LinkedHashMap<String,String> = LinkedHashMap(),
var claims: LinkedHashMap<String, String> = LinkedHashMap(),
var jwtCredential: String = "",
var issuingDID: String = "",
var connectionId: String = ""
var connectionId: String = "",
)
Expand Up @@ -10,5 +10,5 @@ data class CredentialSchema(
var kind: String? = null,
var self: String? = null,
var attributes: List<String>? = listOf(""),
var tags: List<String>? = listOf("")
var tags: List<String>? = listOf(""),
)
6 changes: 3 additions & 3 deletions tests/e2e-tests/src/main/kotlin/api_models/DidDocument.kt
Expand Up @@ -13,15 +13,15 @@ data class W3cCompatibleDid(
var id: String? = null,
var keyAgreement: List<String>? = null,
var service: List<DidDocumentService>? = null,
var verificationMethod: List<DidDocumentAuthentication>? = null
var verificationMethod: List<DidDocumentAuthentication>? = null,
)

data class DidDocumentAuthentication(
var controller: String? = null,
var id: String? = null,
var publicKeyJwk: PublicKeyJwk? = null,
var type: String? = null,
var uri: String? = null
var uri: String? = null,
)

data class PublicKeyJwk(
Expand All @@ -33,7 +33,7 @@ data class PublicKeyJwk(

data class DidDocumentMetadata(
var canonicalId: String? = null,
var deactivated: Boolean? = null
var deactivated: Boolean? = null,
)

data class DidDocumentService(
Expand Down
Expand Up @@ -2,5 +2,5 @@ package api_models

data class DocumentTemplate(
val publicKeys: List<PublicKey>,
val services: List<Service>
val services: List<Service>,
)
2 changes: 1 addition & 1 deletion tests/e2e-tests/src/main/kotlin/api_models/Invitation.kt
Expand Up @@ -4,5 +4,5 @@ data class Invitation(
var id: String = "",
var from: String = "",
var invitationUrl: String = "",
var type: String = ""
var type: String = "",
)
2 changes: 1 addition & 1 deletion tests/e2e-tests/src/main/kotlin/api_models/ManagedDid.kt
Expand Up @@ -3,5 +3,5 @@ package api_models
data class ManagedDid(
var did: String = "",
var longFormDid: String = "",
var status: String = ""
var status: String = "",
)
Expand Up @@ -4,5 +4,5 @@ data class PresentationProof(
var presentationId: String? = null,
var status: String? = null,
var proofs: List<String>? = null,
var data: List<String>? = null
var data: List<String>? = null,
)
4 changes: 2 additions & 2 deletions tests/e2e-tests/src/main/kotlin/api_models/PublicKey.kt
Expand Up @@ -4,13 +4,13 @@ import com.fasterxml.jackson.annotation.JsonValue

data class PublicKey(
val id: String,
val purpose: Purpose
val purpose: Purpose,
)

enum class Purpose(@JsonValue val value: String) {
AUTHENTICATION("authentication"),
ASSERTION_METHOD("assertionMethod"),
KEY_AGREEMENT("keyAgreement"),
CAPABILITY_INVOCATION("capabilityInvocation"),
CAPABILITY_DELEGATION("capabilityDelegation")
CAPABILITY_DELEGATION("capabilityDelegation"),
}
2 changes: 1 addition & 1 deletion tests/e2e-tests/src/main/kotlin/api_models/Service.kt
Expand Up @@ -3,5 +3,5 @@ package api_models
data class Service(
val id: String,
val type: String,
val serviceEndpoint: List<String>
val serviceEndpoint: List<String>,
)
5 changes: 3 additions & 2 deletions tests/e2e-tests/src/test/kotlin/common/Agents.kt
Expand Up @@ -20,8 +20,9 @@ object Agents {
SerenityRest.setDefaultRequestSpecification(
RequestSpecBuilder().addHeader(
Environments.AGENT_AUTH_HEADER,
Environments.AGENT_AUTH_KEY)
.build()
Environments.AGENT_AUTH_KEY,
)
.build(),
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e-tests/src/test/kotlin/common/CredentialSchemas.kt
Expand Up @@ -10,7 +10,7 @@ object CredentialSchemas {
description = "Simple student credentials schema",
attributes = listOf("name", "age"),
tags = listOf("school", "students"),
version = "1.0"
version = "1.0",
)
}
val STUDENT_SCHEMA = CredentialSchema(
Expand All @@ -19,6 +19,6 @@ object CredentialSchemas {
description = "Simple student credentials schema",
attributes = listOf("name", "age"),
tags = listOf("school", "students"),
version = "1.0"
version = "1.0",
)
}
6 changes: 3 additions & 3 deletions tests/e2e-tests/src/test/kotlin/common/Utils.kt
Expand Up @@ -21,7 +21,7 @@ object Utils {
return SerenityRest.lastResponse().jsonPath().getList(path, clazz.java)
}

fun toJsonPath(any: Any) : DocumentContext {
fun toJsonPath(any: Any): DocumentContext {
val json = ObjectMapper().writeValueAsString(any)
return JsonPath.parse(json)
}
Expand All @@ -30,7 +30,7 @@ object Utils {
blockToWait: () -> Boolean,
errorMessage: String,
poolInterval: FixedPollInterval = FixedPollInterval(Duration.ofSeconds(7L)),
timeout: Duration = Duration.ofSeconds(120L)
timeout: Duration = Duration.ofSeconds(120L),
) {
try {
Awaitility.await().withPollInterval(poolInterval)
Expand All @@ -41,7 +41,7 @@ object Utils {
}
} catch (err: ConditionTimeoutException) {
throw ConditionTimeoutException(
errorMessage
errorMessage,
)
}
}
Expand Down
33 changes: 16 additions & 17 deletions tests/e2e-tests/src/test/kotlin/features/CommonSteps.kt
@@ -1,6 +1,7 @@
package features

import api_models.Connection
import api_models.ConnectionState
import api_models.Credential
import common.Agents.Acme
import common.Agents.Bob
Expand All @@ -24,7 +25,7 @@ class CommonSteps {
@Before
fun setStage() {
createAgents()
val cast = object: Cast() {
val cast = object : Cast() {
override fun getActors(): MutableList<Actor> {
return mutableListOf(Acme, Bob, Mallory, Faber)
}
Expand All @@ -34,20 +35,20 @@ class CommonSteps {

@ParameterType(".*")
fun actor(actorName: String): Actor {
return OnStage.theActorCalled(actorName);
return OnStage.theActorCalled(actorName)
}

@Given("{actor} has an issued credential from {actor}")
fun holderHasIssuedCredentialFromIssuer(holder: Actor, issuer: Actor) {
holder.attemptsTo(
Get.resource("/issue-credentials/records")
Get.resource("/issue-credentials/records"),
)
holder.should(
ResponseConsequence.seeThatResponse("Credential records") {
ResponseConsequence.seeThatResponse {
it.statusCode(SC_OK)
}
},
)
val receivedCredential = lastResponseList("items", Credential::class).findLast { credential ->
val receivedCredential = lastResponseList("contents", Credential::class).findLast { credential ->
credential.protocolState == "CredentialReceived"
}

Expand All @@ -66,30 +67,29 @@ class CommonSteps {
@Given("{actor} and {actor} have an existing connection")
fun actorsHaveExistingConnection(inviter: Actor, invitee: Actor) {
inviter.attemptsTo(
Get.resource("/connections")
Get.resource("/connections"),
)
inviter.should(
ResponseConsequence.seeThatResponse("Get connections") {
it.statusCode(200)
}
ResponseConsequence.seeThatResponse {
it.statusCode(SC_OK)
},
)
val inviterConnection = lastResponseList("contents", Connection::class).firstOrNull {
it.label == "Connection with ${invitee.name}" &&
(it.state == "ConnectionResponseSent" || it.state == "ConnectionResponseReceived")
it.label == "Connection with ${invitee.name}" && it.state == ConnectionState.CONNECTION_RESPONSE_SENT
}

var inviteeConnection: Connection? = null
if (inviterConnection != null) {
invitee.attemptsTo(
Get.resource("/connections")
Get.resource("/connections"),
)
invitee.should(
ResponseConsequence.seeThatResponse("Get connections") {
ResponseConsequence.seeThatResponse {
it.statusCode(SC_OK)
}
},
)
inviteeConnection = lastResponseList("contents", Connection::class).firstOrNull {
it.theirDid == inviterConnection.myDid
it.theirDid == inviterConnection.myDid && it.state == ConnectionState.CONNECTION_RESPONSE_RECEIVED
}
}

Expand All @@ -102,7 +102,6 @@ class CommonSteps {
connectionSteps.inviteeReceivesTheConnectionInvitation(invitee, inviter)
connectionSteps.inviteeSendsAConnectionRequestToInviter(invitee, inviter)
connectionSteps.inviterReceivesTheConnectionRequest(inviter)
connectionSteps.inviterSendsAConnectionResponseToInvitee(inviter, invitee)
connectionSteps.inviteeReceivesTheConnectionResponse(invitee)
connectionSteps.inviterAndInviteeHaveAConnection(inviter, invitee)
}
Expand Down