diff --git a/VCL/src/test/java/io/velocitycareerlabs/infrastructure/resources/CommonMocks.kt b/VCL/src/test/java/io/velocitycareerlabs/infrastructure/resources/CommonMocks.kt index ab5f568..9162fe6 100644 --- a/VCL/src/test/java/io/velocitycareerlabs/infrastructure/resources/CommonMocks.kt +++ b/VCL/src/test/java/io/velocitycareerlabs/infrastructure/resources/CommonMocks.kt @@ -8,6 +8,9 @@ package io.velocitycareerlabs.infrastructure.resources import io.velocitycareerlabs.api.entities.VCLJwt +import io.velocitycareerlabs.api.entities.VCLToken + + class CommonMocks { companion object { @@ -23,5 +26,7 @@ class CommonMocks { val DID5 = "did:ion:EiAbP9xvCYnUOiLwqgbkV4auH_26Pv7BT2pYYT3masvvh5" val JWT = VCLJwt("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c") + + var Token = VCLToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c") } } \ No newline at end of file diff --git a/VCL/src/test/java/io/velocitycareerlabs/usecases/GenerateOffersUseCaseTest.kt b/VCL/src/test/java/io/velocitycareerlabs/usecases/GenerateOffersUseCaseTest.kt index 5249282..7291a9b 100644 --- a/VCL/src/test/java/io/velocitycareerlabs/usecases/GenerateOffersUseCaseTest.kt +++ b/VCL/src/test/java/io/velocitycareerlabs/usecases/GenerateOffersUseCaseTest.kt @@ -21,6 +21,8 @@ import io.velocitycareerlabs.infrastructure.resources.valid.DidJwkMocks import io.velocitycareerlabs.infrastructure.resources.valid.GenerateOffersMocks import io.velocitycareerlabs.infrastructure.resources.valid.VerifiedProfileMocks import org.junit.Test +import org.skyscreamer.jsonassert.JSONAssert +import org.skyscreamer.jsonassert.JSONCompareMode internal class GenerateOffersUseCaseTest { @@ -48,16 +50,17 @@ internal class GenerateOffersUseCaseTest { subject1.generateOffers( generateOffersDescriptor = generateOffersDescriptor, - sessionToken = VCLToken(value = "") + sessionToken = CommonMocks.Token ) { it.handleResult( { offers -> - assert( - offers.all.toString().toCharArray().sort() == - GenerateOffersMocks.Offers.toJsonArray().toString().toCharArray() - .sort() + JSONAssert.assertEquals( + offers.all.map { it.payload }.toJsonArray(), + GenerateOffersMocks.Offers.toJsonArray(), + JSONCompareMode.LENIENT ) assert(offers.challenge == GenerateOffersMocks.Challenge) + assert(offers.sessionToken.value == CommonMocks.Token.value) }, { assert(false) { "${it.toJsonObject()}" } @@ -86,11 +89,12 @@ internal class GenerateOffersUseCaseTest { subject2.generateOffers( generateOffersDescriptor = generateOffersDescriptor, - sessionToken = VCLToken(value = "") + sessionToken = CommonMocks.Token ) { it.handleResult( { offers -> assert(offers.all == listOf()) + assert(offers.sessionToken.value == CommonMocks.Token.value) }, { assert(false) { "${it.toJsonObject()}" } @@ -119,11 +123,12 @@ internal class GenerateOffersUseCaseTest { subject3.generateOffers( generateOffersDescriptor = generateOffersDescriptor, - sessionToken = VCLToken(value = "") + sessionToken = CommonMocks.Token ) { it.handleResult( { offers -> assert(offers.all == listOf()) + assert(offers.sessionToken.value == CommonMocks.Token.value) }, { assert(false) { "${it.toJsonObject()}" } diff --git a/app/src/main/java/com/vcl/wallet/MainActivity.kt b/app/src/main/java/com/vcl/wallet/MainActivity.kt index 1f7c50e..72e417d 100644 --- a/app/src/main/java/com/vcl/wallet/MainActivity.kt +++ b/app/src/main/java/com/vcl/wallet/MainActivity.kt @@ -79,24 +79,28 @@ class MainActivity : AppCompatActivity() { binding.generateDidJwk.setOnClickListener { generateDidJwk() } +// val initializationDescriptor = VCLInitializationDescriptor( +// environment = environment, +// xVnfProtocolVersion = VCLXVnfProtocolVersion.XVnfProtocolVersion2, +// cryptoServicesDescriptor = VCLCryptoServicesDescriptor( +// cryptoServiceType = VCLCryptoServiceType.Remote, +// remoteCryptoServicesUrlsDescriptor = VCLRemoteCryptoServicesUrlsDescriptor( +// keyServiceUrls = VCLKeyServiceUrls( +// createDidKeyServiceUrl = Constants.getCreateDidKeyServiceUrl(environment = environment) +// ), +// jwtServiceUrls = VCLJwtServiceUrls( +// jwtSignServiceUrl = Constants.getJwtSignServiceUrl(environment = environment), +// jwtVerifyServiceUrl = Constants.getJwtVerifyServiceUrl(environment = environment) +// ) +// ) +// ) +// ) + val initializationDescriptor = VCLInitializationDescriptor( + environment = environment + ) vcl.initialize( context = this.applicationContext, - initializationDescriptor = VCLInitializationDescriptor( - environment = environment, - xVnfProtocolVersion = VCLXVnfProtocolVersion.XVnfProtocolVersion2, - cryptoServicesDescriptor = VCLCryptoServicesDescriptor( - cryptoServiceType = VCLCryptoServiceType.Remote, - remoteCryptoServicesUrlsDescriptor = VCLRemoteCryptoServicesUrlsDescriptor( - keyServiceUrls = VCLKeyServiceUrls( - createDidKeyServiceUrl = Constants.getCreateDidKeyServiceUrl(environment = environment) - ), - jwtServiceUrls = VCLJwtServiceUrls( - jwtSignServiceUrl = Constants.getJwtSignServiceUrl(environment = environment), - jwtVerifyServiceUrl = Constants.getJwtVerifyServiceUrl(environment = environment) - ) - ) - ) - ), + initializationDescriptor = initializationDescriptor, successHandler = { Log.d(TAG, "VCL Initialization succeed!")