Skip to content

Commit

Permalink
Merge pull request #1089 from nandhu-kumar/develop
Browse files Browse the repository at this point in the history
MOSIP-29513
  • Loading branch information
lsivanand authored Sep 26, 2023
2 parents 40d6bc4 + 42779a1 commit a59e49e
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3264,25 +3264,39 @@ public static String signJWK(String clientId, String accessToken, RSAKey jwkKey,

if (testCaseName.contains("_Invalid_C_nonce_"))
nonce = "jwt_payload.c_nonce123";
if (testCaseName.contains("_Empty_Typ_"))
else if (testCaseName.contains("_Empty_C_nonce_"))
nonce = "";
else if (testCaseName.contains("_SpaceVal_C_nonce_"))
nonce = " ";
else if (testCaseName.contains("_Empty_Typ_"))
typ = "";
if (testCaseName.contains("_Invalid_Typ_"))
else if (testCaseName.contains("_SpaceVal_Typ_"))
typ = " ";
else if (testCaseName.contains("_Invalid_Typ_"))
typ = "openid4vci-123@proof+jwt";
else if (testCaseName.contains("_Invalid_JwkHeader_"))
jwkHeader = RSAKey.parse(getJWKKey(oidcJWK2)).toPublicJWK();
else if (testCaseName.contains("_Invalid_Aud_"))
tempUrl = "sdfaf";
else if (testCaseName.contains("_Invalid_Iss_"))
clientId = "sdfdsg";
else if (testCaseName.contains("_Invalid_Exp_"))
idTokenExpirySecs = 0;

claimsSet = new JWTClaimsSet.Builder().audience(tempUrl).claim("nonce", nonce).issuer(clientId)
.issueTime(new Date()).expirationTime(new Date(new Date().getTime() + idTokenExpirySecs)).build();

if (testCaseName.contains("_Missing_Typ_")) {
signedJWT = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).jwk(jwkHeader).build(), claimsSet);
} else if (testCaseName.contains("_Missing_JwkHeader_")) {
signedJWT = new SignedJWT(
new JWSHeader.Builder(JWSAlgorithm.RS256).jwk(jwkHeader).build(),
claimsSet);
new JWSHeader.Builder(JWSAlgorithm.RS256).type(new JOSEObjectType(typ)).build(), claimsSet);
} else {
signedJWT = new SignedJWT(
new JWSHeader.Builder(JWSAlgorithm.RS256).type(new JOSEObjectType(typ)).jwk(jwkHeader).build(),
claimsSet);
}


signedJWT.sign(signer);
proofJWT = signedJWT.serialize();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,48 @@ GetCredentialNegTC:
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_Empty_C_nonce_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCINegTC/GetCredential/GetCredential
outputTemplate: esignet/error2
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_uin_NegCredScen9_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_SpaceVal_C_nonce_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCINegTC/GetCredential/GetCredential
outputTemplate: esignet/error2
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_uin_NegCredScen9_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_Empty_Typ_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
Expand All @@ -582,6 +624,27 @@ GetCredentialNegTC:
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_SpaceVal_Typ_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCINegTC/GetCredential/GetCredential
outputTemplate: esignet/error2
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_uin_NegCredScen9_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_Invalid_Typ_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
Expand Down Expand Up @@ -622,4 +685,109 @@ GetCredentialNegTC:
}'
output: '{
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_Invalid_JwkHeader_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCINegTC/GetCredential/GetCredential
outputTemplate: esignet/error2
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_uin_NegCredScen9_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_Missing_JwkHeader_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCINegTC/GetCredential/GetCredential
outputTemplate: esignet/error2
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_uin_NegCredScen9_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_Invalid_Aud_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCINegTC/GetCredential/GetCredential
outputTemplate: esignet/error2
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_uin_NegCredScen9_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_Invalid_Iss_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCINegTC/GetCredential/GetCredential
outputTemplate: esignet/error2
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_uin_NegCredScen9_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
"error":"invalid_proof"
}'

ESignet_GetCredential_uin_IdpAccessToken_Invalid_Exp_Neg:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCINegTC/GetCredential/GetCredential
outputTemplate: esignet/error2
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_uin_NegCredScen9_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
"error":"invalid_proof"
}'
38 changes: 38 additions & 0 deletions automationtests/testNgXmlFiles/esignetSuite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,44 @@
<class name="io.mosip.testrig.apirig.testscripts.SimplePost" />
</classes>
</test>
<test name="OAuthDetailsRequestVCIVid">
<parameter name="ymlFile"
value="esignet/VCIVid/OAuthDetailsRequestVCI/OAuthDetailsRequestVCI.yml" />
<parameter name="idKeyName" value="transactionId,encodedResp" />
<classes>
<class name="io.mosip.testrig.apirig.testscripts.SimplePostForAutoGenId" />
</classes>
</test>
<test name="AuthenticateUserVCIVid">
<parameter name="ymlFile"
value="esignet/VCIVid/AuthenticateUserVCI/AuthenticateUserVCI.yml" />
<classes>
<class name="io.mosip.testrig.apirig.testscripts.PostWithAutogenIdWithOtpGenerate" />
</classes>
</test>
<test name="AuthorizationCodeVCIVid">
<parameter name="ymlFile"
value="esignet/VCIVid/AuthorizationCodeVCI/AuthorizationCodeVCI.yml" />
<parameter name="idKeyName" value="code" />
<classes>
<class name="io.mosip.testrig.apirig.testscripts.SimplePostForAutoGenId" />
</classes>
</test>
<test name="GenerateTokenVCIVid">
<parameter name="ymlFile"
value="esignet/VCIVid/GenerateTokenVCI/GenerateTokenVCI.yml" />
<parameter name="idKeyName" value="access_token" />
<classes>
<class name="io.mosip.testrig.apirig.testscripts.SimplePostForAutoGenIdForUrlEncoded" />
</classes>
</test>
<test name="GetCredentialVid">
<parameter name="ymlFile"
value="esignet/VCIVid/GetCredential/GetCredential.yml" />
<classes>
<class name="io.mosip.testrig.apirig.testscripts.SimplePost" />
</classes>
</test>
<test name="OAuthDetailsRequestVCINegTC">
<parameter name="ymlFile"
value="esignet/VCINegTC/OAuthDetailsRequestVCI/OAuthDetailsRequestVCI.yml" />
Expand Down

0 comments on commit a59e49e

Please sign in to comment.