Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelavoyan committed Feb 7, 2024
1 parent 6d27e8a commit 3887f79
Show file tree
Hide file tree
Showing 31 changed files with 262 additions and 242 deletions.
4 changes: 2 additions & 2 deletions VCL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
defaultConfig {
minSdk 24
targetSdk 33
versionName "2.0.0"
versionCode 125
versionName "2.1.0"
versionCode 126
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import io.velocitycareerlabs.api.entities.VCLPushDelegate
import io.velocitycareerlabs.impl.extensions.decode
import io.velocitycareerlabs.impl.extensions.isUrlEquivalentTo
import io.velocitycareerlabs.infrastructure.resources.valid.CredentialManifestDescriptorMocks
import io.velocitycareerlabs.infrastructure.resources.valid.DidJwkMocks

import org.junit.After
import org.junit.Before
Expand All @@ -31,7 +32,8 @@ internal class VCLCredentialManifestDescriptorByDeepLinkTest {
subject = VCLCredentialManifestDescriptorByDeepLink(
deepLink = CredentialManifestDescriptorMocks.DeepLink,
issuingType = VCLIssuingType.Career,
pushDelegate = VCLPushDelegate(pushUrl = "some_url", pushToken = "some_token")
pushDelegate = VCLPushDelegate(pushUrl = "some_url", pushToken = "some_token"),
didJwk = DidJwkMocks.DidJwk
)

assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import io.velocitycareerlabs.api.entities.VCLIssuingType
import io.velocitycareerlabs.impl.extensions.encode
import io.velocitycareerlabs.impl.extensions.isUrlEquivalentTo
import io.velocitycareerlabs.infrastructure.resources.valid.CredentialManifestDescriptorMocks
import io.velocitycareerlabs.infrastructure.resources.valid.DidJwkMocks
import org.json.JSONObject
import org.junit.After
import org.junit.Before
Expand All @@ -35,7 +36,8 @@ internal class VCLCredentialManifestDescriptorByServiceTest {
service = service,
issuingType = VCLIssuingType.Career,
credentialTypes = CredentialManifestDescriptorMocks.CredentialTypesList,
pushDelegate = CredentialManifestDescriptorMocks.PushDelegate
pushDelegate = CredentialManifestDescriptorMocks.PushDelegate,
didJwk = DidJwkMocks.DidJwk
)

val credentialTypesQuery =
Expand All @@ -58,7 +60,8 @@ internal class VCLCredentialManifestDescriptorByServiceTest {
service = service,
issuingType = VCLIssuingType.Identity,
credentialTypes = CredentialManifestDescriptorMocks.CredentialTypesList,
pushDelegate = CredentialManifestDescriptorMocks.PushDelegate
pushDelegate = CredentialManifestDescriptorMocks.PushDelegate,
didJwk = DidJwkMocks.DidJwk
)

val credentialTypesQuery =
Expand All @@ -80,7 +83,8 @@ internal class VCLCredentialManifestDescriptorByServiceTest {
subject = VCLCredentialManifestDescriptorByService(
service = service,
issuingType = VCLIssuingType.Career,
pushDelegate = CredentialManifestDescriptorMocks.PushDelegate
pushDelegate = CredentialManifestDescriptorMocks.PushDelegate,
didJwk = DidJwkMocks.DidJwk
)

val credentialTypesQuery =
Expand All @@ -100,7 +104,8 @@ internal class VCLCredentialManifestDescriptorByServiceTest {
subject = VCLCredentialManifestDescriptorByService(
service = service,
issuingType = VCLIssuingType.Career,
credentialTypes = CredentialManifestDescriptorMocks.CredentialTypesList
credentialTypes = CredentialManifestDescriptorMocks.CredentialTypesList,
didJwk = DidJwkMocks.DidJwk
)

val credentialTypesQuery =
Expand All @@ -120,7 +125,8 @@ internal class VCLCredentialManifestDescriptorByServiceTest {
subject = VCLCredentialManifestDescriptorByService(
service = service,
issuingType = VCLIssuingType.Career,
pushDelegate = CredentialManifestDescriptorMocks.PushDelegate
pushDelegate = CredentialManifestDescriptorMocks.PushDelegate,
didJwk = DidJwkMocks.DidJwk
)

val credentialTypesQuery =
Expand All @@ -140,6 +146,7 @@ internal class VCLCredentialManifestDescriptorByServiceTest {
subject = VCLCredentialManifestDescriptorByService(
service = service,
issuingType = VCLIssuingType.Career,
didJwk = DidJwkMocks.DidJwk
)
val mockEndpoint = (CredentialManifestDescriptorMocks.IssuingServiceWithParamEndPoint)

Expand All @@ -152,7 +159,8 @@ internal class VCLCredentialManifestDescriptorByServiceTest {
val service =
VCLServiceCredentialAgentIssuer(JSONObject(CredentialManifestDescriptorMocks.IssuingServiceJsonStr))
subject = VCLCredentialManifestDescriptorByService(
service = service
service = service,
didJwk = DidJwkMocks.DidJwk
)
val mockEndpoint = (CredentialManifestDescriptorMocks.IssuingServiceEndPoint)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import io.velocitycareerlabs.api.entities.VCLIssuingType
import io.velocitycareerlabs.impl.extensions.encode
import io.velocitycareerlabs.impl.extensions.isUrlEquivalentTo
import io.velocitycareerlabs.infrastructure.resources.valid.CredentialManifestDescriptorMocks
import io.velocitycareerlabs.infrastructure.resources.valid.DidJwkMocks
import org.json.JSONObject
import org.junit.After
import org.junit.Before
Expand All @@ -38,7 +39,8 @@ internal class VCLCredentialManifestDescriptorRefreshTest {
credentialIds = listOf(
CredentialManifestDescriptorMocks.CredentialId1,
CredentialManifestDescriptorMocks.CredentialId2
)
),
didJwk = DidJwkMocks.DidJwk
)

val credentialTypesQuery = "${VCLCredentialManifestDescriptor.KeyRefresh}=${true}" +
Expand All @@ -58,7 +60,8 @@ internal class VCLCredentialManifestDescriptorRefreshTest {
)
subject = VCLCredentialManifestDescriptorRefresh(
service = service,
credentialIds = listOf(CredentialManifestDescriptorMocks.CredentialId1)
credentialIds = listOf(CredentialManifestDescriptorMocks.CredentialId1),
didJwk = DidJwkMocks.DidJwk
)

val credentialTypesQuery = "${VCLCredentialManifestDescriptor.KeyRefresh}=${true}" +
Expand All @@ -77,7 +80,8 @@ internal class VCLCredentialManifestDescriptorRefreshTest {
)
subject = VCLCredentialManifestDescriptorRefresh(
service = service,
credentialIds = listOf()
credentialIds = listOf(),
didJwk = DidJwkMocks.DidJwk
)

val credentialTypesQuery = "${VCLCredentialManifestDescriptor.KeyRefresh}=${true}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.velocitycareerlabs.api.entities.VCLJwt
import io.velocitycareerlabs.api.entities.VCLVerifiedProfile
import io.velocitycareerlabs.impl.extensions.toJsonObject
import io.velocitycareerlabs.infrastructure.resources.valid.CredentialManifestMocks
import io.velocitycareerlabs.infrastructure.resources.valid.DidJwkMocks
import io.velocitycareerlabs.infrastructure.resources.valid.VerifiedProfileMocks
import org.junit.Before
import org.junit.Test
Expand All @@ -25,7 +26,8 @@ class VCLCredentialManifestTest {
try {
subject = VCLCredentialManifest(
jwt = VCLJwt(encodedJwt = CredentialManifestMocks.JwtCredentialManifest1),
verifiedProfile = VCLVerifiedProfile(payload = VerifiedProfileMocks.VerifiedProfileIssuerJsonStr1.toJsonObject()!!)
verifiedProfile = VCLVerifiedProfile(payload = VerifiedProfileMocks.VerifiedProfileIssuerJsonStr1.toJsonObject()!!),
didJwk = DidJwkMocks.DidJwk
)
} catch (ex: Exception) {
assert(false) {"$ex"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ internal class VCLDeepLinkTest {

lateinit var subject: VCLDeepLink

@Before
fun setUp() {
}

@Test
fun testOpenidInitiateIssuance() {
subject = VCLDeepLink(value = DeepLinkMocks.OpenidInitiateIssuanceStrDev)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import io.velocitycareerlabs.impl.extensions.toJsonObject
import io.velocitycareerlabs.impl.jwt.local.VCLJwtSignServiceLocalImpl
import io.velocitycareerlabs.infrastructure.db.SecretStoreServiceMock
import io.velocitycareerlabs.infrastructure.resources.valid.CredentialManifestMocks
import io.velocitycareerlabs.infrastructure.resources.valid.DidJwkMocks
import io.velocitycareerlabs.infrastructure.resources.valid.VerifiedProfileMocks
import org.json.JSONArray
import org.json.JSONObject
Expand Down Expand Up @@ -69,7 +70,8 @@ class VCLFinalizeOffersDescriptorTest {
val credentialManifest =
VCLCredentialManifest(
jwt = VCLJwt(encodedJwt = CredentialManifestMocks.JwtCredentialManifest1),
verifiedProfile = VCLVerifiedProfile(VerifiedProfileMocks.VerifiedProfileIssuerJsonStr1.toJsonObject()!!)
verifiedProfile = VCLVerifiedProfile(VerifiedProfileMocks.VerifiedProfileIssuerJsonStr1.toJsonObject()!!),
didJwk = didJwk
)

subject = VCLFinalizeOffersDescriptor(
Expand All @@ -84,14 +86,14 @@ class VCLFinalizeOffersDescriptorTest {
fun testGenerateRequestBody() {
val payload = "{\"key1\": \"value1\"}".toJsonObject()
VCLJwtSignServiceLocalImpl(VCLKeyServiceLocalImpl(SecretStoreServiceMock.Instance)).sign(
didJwk = didJwk,
nonce = nonceMock,
jwtDescriptor = VCLJwtDescriptor(
payload = payload,
jti = jtiMock,
iss = issMock,
aud = audMock
)
),
nonce = nonceMock,
didJwk = didJwk
) { jwtResult ->
jwtResult.handleResult({ jwt ->
val requestBody = subject.generateRequestBody(jwt = jwt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import io.velocitycareerlabs.api.entities.*
import io.velocitycareerlabs.impl.extensions.decode
import io.velocitycareerlabs.impl.extensions.encode
import io.velocitycareerlabs.impl.extensions.isUrlEquivalentTo
import io.velocitycareerlabs.infrastructure.resources.valid.DidJwkMocks
import io.velocitycareerlabs.infrastructure.resources.valid.PresentationRequestDescriptorMocks
import org.junit.After
import org.junit.Before
Expand All @@ -28,7 +29,8 @@ class VCLPresentationRequestDescriptorTest {
fun testPresentationRequestDescriptorWithPushDelegateSuccess() {
subject = VCLPresentationRequestDescriptor(
deepLink = PresentationRequestDescriptorMocks.DeepLink,
pushDelegate = PresentationRequestDescriptorMocks.PushDelegate
pushDelegate = PresentationRequestDescriptorMocks.PushDelegate,
didJwk = DidJwkMocks.DidJwk
)

val queryParams =
Expand All @@ -45,7 +47,8 @@ class VCLPresentationRequestDescriptorTest {
@Test
fun testPresentationRequestDescriptorWithoutPushDelegateOnlySuccess() {
subject = VCLPresentationRequestDescriptor(
deepLink = PresentationRequestDescriptorMocks.DeepLink
deepLink = PresentationRequestDescriptorMocks.DeepLink,
didJwk = DidJwkMocks.DidJwk
)

assert(subject.endpoint?.decode()?.isUrlEquivalentTo(PresentationRequestDescriptorMocks.RequestUri.decode()) == true)
Expand All @@ -57,7 +60,8 @@ class VCLPresentationRequestDescriptorTest {
fun testPresentationRequestDescriptorWithQParamsWithPushDelegateSuccess() {
subject = VCLPresentationRequestDescriptor(
deepLink = PresentationRequestDescriptorMocks.DeepLinkWithQParams,
pushDelegate = PresentationRequestDescriptorMocks.PushDelegate
pushDelegate = PresentationRequestDescriptorMocks.PushDelegate,
didJwk = DidJwkMocks.DidJwk
)

val queryParams =
Expand All @@ -76,7 +80,8 @@ class VCLPresentationRequestDescriptorTest {
@Test
fun testPresentationRequestDescriptorWithQParamsWithoutPushDelegateOnlySuccess() {
subject = VCLPresentationRequestDescriptor(
deepLink = PresentationRequestDescriptorMocks.DeepLinkWithQParams
deepLink = PresentationRequestDescriptorMocks.DeepLinkWithQParams,
didJwk = DidJwkMocks.DidJwk
)

val mockEndpoint =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import io.velocitycareerlabs.api.entities.VCLVerifiedProfile
import io.velocitycareerlabs.impl.extensions.toJsonObject
import io.velocitycareerlabs.impl.extensions.toList
import io.velocitycareerlabs.infrastructure.resources.CommonMocks
import io.velocitycareerlabs.infrastructure.resources.valid.DidJwkMocks
import io.velocitycareerlabs.infrastructure.resources.valid.JwtServiceMocks
import io.velocitycareerlabs.infrastructure.resources.valid.PresentationSubmissionMocks
import io.velocitycareerlabs.infrastructure.resources.valid.VerifiedProfileMocks
Expand All @@ -38,7 +39,8 @@ class VCLSubmissionTest {
subjectIdentificationSubmission = VCLIdentificationSubmission(
VCLCredentialManifest(
jwt = CommonMocks.JWT,
verifiedProfile = VCLVerifiedProfile(VerifiedProfileMocks.VerifiedProfileIssuerJsonStr1.toJsonObject()!!)
verifiedProfile = VCLVerifiedProfile(VerifiedProfileMocks.VerifiedProfileIssuerJsonStr1.toJsonObject()!!),
didJwk = DidJwkMocks.DidJwk
),
PresentationSubmissionMocks.SelectionsList
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ class JwtSignServiceLocalTest {
@Test
fun testSignFullParams() {
subject.sign(
didJwk = didJwk,
nonce = nonceMock,
jwtDescriptor = VCLJwtDescriptor(
payload = payloadMock,
jti = jtiMock,
iss = issMock,
aud = audMock
)
) { jwtResult ->
),
nonce = nonceMock,
didJwk = didJwk
) { jwtResult ->
jwtResult.handleResult({ jwt ->
assert(jwt.kid == didJwk.kid)

Expand All @@ -80,14 +80,14 @@ class JwtSignServiceLocalTest {
@Test
fun testSignPartialParams1() {
subject.sign(
didJwk = didJwk,
nonce = nonceMock,
jwtDescriptor = VCLJwtDescriptor(
payload = payloadMock,
jti = jtiMock,
iss = issMock,
aud = audMock
)
),
nonce = nonceMock,
didJwk = didJwk
) { jwtResult ->
jwtResult.handleResult({ jwt ->
assert(jwt.kid?.isBlank() == false)
Expand All @@ -110,13 +110,13 @@ class JwtSignServiceLocalTest {
@Test
fun testSignPartialParams2() {
subject.sign(
didJwk = didJwk,
jwtDescriptor = VCLJwtDescriptor(
payload = payloadMock,
jti = jtiMock,
iss = issMock,
aud = audMock
)
),
didJwk = didJwk
) { jwtResult ->
jwtResult.handleResult({ jwt ->
assert(jwt.kid?.isBlank() == false)
Expand All @@ -139,12 +139,12 @@ class JwtSignServiceLocalTest {
@Test
fun testSignPartialParams3() {
subject.sign(
didJwk = didJwk,
jwtDescriptor = VCLJwtDescriptor(
payload = payloadMock,
iss = issMock,
aud = audMock
)
),
didJwk = didJwk
) { jwtResult ->
jwtResult.handleResult({ jwt ->
assert(jwt.kid?.isBlank() == false)
Expand All @@ -167,11 +167,11 @@ class JwtSignServiceLocalTest {
@Test
fun testSignPartialParams4() {
subject.sign(
didJwk = didJwk,
jwtDescriptor = VCLJwtDescriptor(
payload = payloadMock,
iss = issMock
)
),
didJwk = didJwk
) { jwtResult ->
jwtResult.handleResult({ jwt ->
assert(jwt.kid?.isBlank() == false)
Expand All @@ -194,10 +194,10 @@ class JwtSignServiceLocalTest {
@Test
fun testSignPartParams5() {
subject.sign(
didJwk = didJwk,
jwtDescriptor = VCLJwtDescriptor(
iss = issMock
)
),
didJwk = didJwk
) { jwtResult ->
jwtResult.handleResult({ jwt ->
assert(jwt.kid?.isBlank() == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class JwtVerifyServiceLocalTest {
@Test
fun testSignAndVerify() {
jwtSignServiceLocalImpl.sign(
didJwk = didJwk,
nonce = nonceMock,
jwtDescriptor = VCLJwtDescriptor(
payload = payloadMock,
jti = jtiMock,
iss = issMock,
aud = audMock
)
) { jwtResult ->
),
nonce = nonceMock,
didJwk = didJwk
) { jwtResult ->
jwtResult.handleResult({ jwt ->
assert(jwt.kid == didJwk.kid)

Expand Down
Loading

0 comments on commit 3887f79

Please sign in to comment.