Skip to content

Commit

Permalink
Merge pull request mosip#1078 from nandhu-kumar/develop
Browse files Browse the repository at this point in the history
MOSIP-29513
  • Loading branch information
lsivanand authored Sep 22, 2023
2 parents 4c47fe6 + 6a45a88 commit 70d0d98
Show file tree
Hide file tree
Showing 9 changed files with 308 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3231,7 +3231,7 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {
accessToken = request.getString("idpAccessToken");
}
jsonString = request.toString();
jsonString = replaceKeywordWithValue(jsonString, "$PROOFJWT$", signJWK(clientId, accessToken, oidcJWKKey1));
jsonString = replaceKeywordWithValue(jsonString, "$PROOFJWT$", signJWK(clientId, accessToken, oidcJWKKey1, testCaseName));
}

if (jsonString.contains(GlobalConstants.REMOVE))
Expand All @@ -3240,12 +3240,15 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {
return jsonString;
}

public static String signJWK(String clientId, String accessToken, RSAKey jwkKey) {
public static String signJWK(String clientId, String accessToken, RSAKey jwkKey, String testCaseName) {
String tempUrl = getValueFromActuator(GlobalConstants.RESIDENT_DEFAULT_PROPERTIES, "mosip.iam.base.url");
int idTokenExpirySecs = Integer.parseInt(getValueFromEsignetActuator(GlobalConstants.ESIGNET_DEFAULT_PROPERTIES,
GlobalConstants.MOSIP_ESIGNET_ID_TOKEN_EXPIRE_SECONDS));
JWSSigner signer;
String proofJWT = "";
String nonce = "jwt_payload.c_nonce123";
String typ = "openid4vci-proof+jwt";
JWK jwkHeader = jwkKey.toPublicJWK();

try {
signer = new RSASSASigner(jwkKey);
Expand All @@ -3254,13 +3257,23 @@ public static String signJWK(String clientId, String accessToken, RSAKey jwkKey)
String jwtPayloadBase64 = jwtParts[1];
byte[] jwtPayloadBytes = Base64.getDecoder().decode(jwtPayloadBase64);
String jwtPayload = new String(jwtPayloadBytes, StandardCharsets.UTF_8);
JWTClaimsSet claimsSet = null;

if (testCaseName.contains("_Invalid_C_nonce_")) {
claimsSet = new JWTClaimsSet.Builder().audience(tempUrl)
.claim("nonce", nonce)
.issuer(clientId).issueTime(new Date())
.expirationTime(new Date(new Date().getTime() + idTokenExpirySecs)).build();
} else {

JWTClaimsSet claimsSet = new JWTClaimsSet.Builder().audience(tempUrl)
.claim("nonce", new ObjectMapper().readTree(jwtPayload).get("c_nonce").asText()).issuer(clientId)
.issueTime(new Date()).expirationTime(new Date(new Date().getTime() + idTokenExpirySecs)).build();
claimsSet = new JWTClaimsSet.Builder().audience(tempUrl)
.claim("nonce", new ObjectMapper().readTree(jwtPayload).get("c_nonce").asText())
.issuer(clientId).issueTime(new Date())
.expirationTime(new Date(new Date().getTime() + idTokenExpirySecs)).build();
}

SignedJWT signedJWT = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256)
.type(new JOSEObjectType("openid4vci-proof+jwt")).jwk(jwkKey.toPublicJWK()).build(), claimsSet);
.type(new JOSEObjectType(typ)).jwk(jwkHeader).build(), claimsSet);

signedJWT.sign(signer);
proofJWT = signedJWT.serialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,58 @@ AddIdentity:
}'
output: '{
"status":"ACTIVATED"
}'

ESignet_AddIdentity_Valid_Params_VCI_Vid_smoke_Pos:
endPoint: /idrepository/v1/identity/
role: idrepo
restMethod: post
inputTemplate: esignet/AddIdentity/addIdentity_$LANGNUMBER$
outputTemplate: esignet/AddIdentity/addIdentityResult
input: '{
"value": "$BIOVALUE$",
"id": "mosip.id.create",
"registrationId": "$RID$",
"biometricReferenceId": "23452353",
"UIN": "$UIN$",
"dateOfBirth": "1992/04/15",
"postalCode": "14022",
"email": "[email protected]",
"phone": "9876543210",
"referenceIdentityNumber": "6789545678878",
"version": "v1",
"introducerRID": "212124324784879",
"introducerUIN": "212124324784879",
"category": "individualBiometrics",
"requesttime": "$TIMESTAMP$"
}'
output: '{
"status":"ACTIVATED"
}'

ESignet_AddIdentity_Valid_Params_VCI_Vid_Inv_Scen_smoke_Pos:
endPoint: /idrepository/v1/identity/
role: idrepo
restMethod: post
inputTemplate: esignet/AddIdentity/addIdentity_$LANGNUMBER$
outputTemplate: esignet/AddIdentity/addIdentityResult
input: '{
"value": "$BIOVALUE$",
"id": "mosip.id.create",
"registrationId": "$RID$",
"biometricReferenceId": "23452353",
"UIN": "$UIN$",
"dateOfBirth": "1992/04/15",
"postalCode": "14022",
"email": "ESignet_AddIdentity_Valid_Params_VCI_Vid_Inv_Scen_smoke_Pos@mosip.net",
"phone": "9876543210",
"referenceIdentityNumber": "6789545678878",
"version": "v1",
"introducerRID": "212124324784879",
"introducerUIN": "212124324784879",
"category": "individualBiometrics",
"requesttime": "$TIMESTAMP$"
}'
output: '{
"status":"ACTIVATED"
}'
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,72 @@ GenerateVID:
"sendOtpResTemplate":"esignet/SendOTPRes/createSendOTPResult",
"maskedEmail": "$IGNORE$"
}
}'

ESignetRes_Generate_Perpetual_VID_VCI_Valid_Smoke_sid:
endPoint: /resident/v1/vid
role: resident
restMethod: post
inputTemplate: esignet/GenerateVID/createGenerateVID
outputTemplate: esignet/GenerateVID/createGenerateVIDResult
input: '{
"transactionID": "$TRANSACTIONID$",
"individualId": "$ID:AddIdentity_Valid_Params_VCI_Vid_smoke_Pos_UIN$",
"individualIdType": "UIN",
"requesttime": "$TIMESTAMP$",
"id": "mosip.resident.vid",
"version": "v1",
"vidType": "Perpetual",
"otp": "$ID:AddIdentity_Valid_Params_VCI_Vid_smoke_Pos_EMAIL$",
"sendOtp":{
"transactionID": "$TRANSACTIONID$",
"requestTime": "$TIMESTAMP$",
"individualId": "$ID:AddIdentity_Valid_Params_VCI_Vid_smoke_Pos_UIN$",
"individualIdType": "UIN",
"sendOtpReqTemplate": "esignet/SendOTPRes/createSendOTP",
"sendOtpEndPoint": "/resident/v1/req/otp"
}
}'
output: '{
"vid": "$IGNORE$",
"message": "Notification has been sent to the provided contact detail(s)",
"sendOtpResp":{
"maskedMobile": "XXXXXX3210",
"sendOtpResTemplate":"esignet/SendOTPRes/createSendOTPResult",
"maskedEmail": "$IGNORE$"
}
}'

ESignetRes_Generate_Perpetual_VID_VCI_Invalid_Scen_Smoke_sid:
endPoint: /resident/v1/vid
role: resident
restMethod: post
inputTemplate: esignet/GenerateVID/createGenerateVID
outputTemplate: esignet/GenerateVID/createGenerateVIDResult
input: '{
"transactionID": "$TRANSACTIONID$",
"individualId": "$ID:AddIdentity_Valid_Params_VCI_Vid_Inv_Scen_smoke_Pos_UIN$",
"individualIdType": "UIN",
"requesttime": "$TIMESTAMP$",
"id": "mosip.resident.vid",
"version": "v1",
"vidType": "Perpetual",
"otp": "$ID:AddIdentity_Valid_Params_VCI_Vid_Inv_Scen_smoke_Pos_EMAIL$",
"sendOtp":{
"transactionID": "$TRANSACTIONID$",
"requestTime": "$TIMESTAMP$",
"individualId": "$ID:AddIdentity_Valid_Params_VCI_Vid_Inv_Scen_smoke_Pos_UIN$",
"individualIdType": "UIN",
"sendOtpReqTemplate": "esignet/SendOTPRes/createSendOTP",
"sendOtpEndPoint": "/resident/v1/req/otp"
}
}'
output: '{
"vid": "$IGNORE$",
"message": "Notification has been sent to the provided contact detail(s)",
"sendOtpResp":{
"maskedMobile": "XXXXXX3210",
"sendOtpResTemplate":"esignet/SendOTPRes/createSendOTPResult",
"maskedEmail": "$IGNORE$"
}
}'
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,39 @@ AuthenticateUserVCI:
}
}'

ESignet_AuthenticateUserVCI_Vid_Otp_Valid_Smoke:
endPoint: /v1/esignet/authorization/authenticate
role: resident
restMethod: post
checkErrorsOnlyInResponse: true
validityCheckRequired: true
inputTemplate: esignet/VCI/AuthenticateUserVCI/AuthenticateUserVCI
outputTemplate: esignet/VCI/AuthenticateUserVCI/AuthenticateUserVCIResultResult
input: '{
"encodedHash": "$ID:OAuthDetailsRequest_VCI_Vid_all_Valid_Smoke_sid_encodedResp$",
"requestTime": "$TIMESTAMP$",
"transactionId": "$ID:OAuthDetailsRequest_VCI_Vid_all_Valid_Smoke_sid_transactionId$",
"individualId": "$ID:Generate_Perpetual_VID_VCI_Valid_Smoke_sid_vid$",
"authFactorType" : "OTP",
"challenge" : "$ID:AddIdentity_Valid_Params_VCI_Vid_smoke_Pos_EMAIL$",
"sendOtp":{
"encodedHash": "$ID:OAuthDetailsRequest_VCI_Vid_all_Valid_Smoke_sid_encodedResp$",
"requestTime": "$TIMESTAMP$",
"transactionId": "$ID:OAuthDetailsRequest_VCI_Vid_all_Valid_Smoke_sid_transactionId$",
"individualId": "$ID:Generate_Perpetual_VID_VCI_Valid_Smoke_sid_vid$",
"otpChannels": [{channel: "email"},{channel: "phone"}],
"sendOtpReqTemplate": "esignet/SendOtp/SendOtp",
"sendOtpEndPoint": "/v1/esignet/authorization/send-otp"
}
}'
output: '{
"sendOtpResp":{
"maskedMobile": "XXXXXX3210",
"sendOtpResTemplate":"esignet/SendOtp/SendOtpResult",
"maskedEmail": "$IGNORE$"
}
}'

ESignet_AuthenticateUserVCI_uin_Otp_1stLang_Valid_Smoke:
endPoint: /v1/esignet/authorization/authenticate
role: resident
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ AuthorizationCodeVCI:
output: '{
}'

ESignet_AuthorizationCode_VCI_Vid_All_Valid_Smoke_sid:
endPoint: /v1/esignet/authorization/auth-code
role: resident
restMethod: post
checkErrorsOnlyInResponse: true
validityCheckRequired: true
inputTemplate: esignet/VCI/AuthorizationCodeVCI/AuthorizationCodeVCI
outputTemplate: esignet/VCI/AuthorizationCodeVCI/AuthorizationCodeVCIResult
input: '{
"encodedHash": "$ID:OAuthDetailsRequest_VCI_Vid_all_Valid_Smoke_sid_encodedResp$",
"requestTime": "$TIMESTAMP$",
"transactionId": "$ID:OAuthDetailsRequest_VCI_Vid_all_Valid_Smoke_sid_transactionId$"
}'
output: '{
}'

ESignet_AuthorizationCode_VCI_uin_All_1stLang_Valid_Smoke_sid:
endPoint: /v1/esignet/authorization/auth-code
role: resident
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ GenerateTokenVCI:
"token_type": "Bearer"
}'

ESignet_GenerateTokenVCI_Vid_Valid_Smoke_sid:
endPoint: /v1/esignet/oauth/v2/token
role: resident
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCI/GenerateTokenVCI/GenerateTokenVCI
outputTemplate: esignet/VCI/GenerateTokenVCI/GenerateTokenVCIResult
input: '{
"grant_type": "authorization_code",
"code": "$ID:AuthorizationCode_VCI_Vid_All_Valid_Smoke_sid_code$",
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"client_assertion": "$CLIENT_ASSERTION_JWK$",
"redirect_uri": "$IDPREDIRECTURI$",
"code_verifier": "$CODEVERIFIER$"
}'
output: '{
"token_type": "Bearer"
}'

ESignet_GenerateTokenVCI_uin_1stLang_Valid_Smoke_sid:
endPoint: /v1/esignet/oauth/v2/token
role: resident
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,45 @@ GetCredential:
"proof_jwt": "$PROOFJWT$"
}'
output: '{
}'

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

ESignet_GetCredential_Vid_IdpAccessToken_all_Valid_Smoke:
endPoint: /v1/esignet/vci/credential
role: resident
checkErrorsOnlyInResponse: true
restMethod: post
validityCheckRequired: true
inputTemplate: esignet/VCI/GetCredential/GetCredential
outputTemplate: esignet/VCI/GetCredential/GetCredentialResult
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:GenerateTokenVCI_Vid_Valid_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
"@context": [{context: "$VCICONTEXTURL$"}],
"proof_type": "jwt",
"proof_jwt": "$PROOFJWT$"
}'
output: '{
}'
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,32 @@ OAuthDetailsRequestVCI:
}'
output: '{

}'

ESignet_OAuthDetailsRequest_VCI_Vid_all_Valid_Smoke_sid:
endPoint: /v1/esignet/authorization/v2/oauth-details
role: resident
restMethod: post
checkErrorsOnlyInResponse: true
inputTemplate: esignet/VCI/OAuthDetailsRequestVCI/OAuthDetailsRequestVCI
outputTemplate: esignet/VCI/OAuthDetailsRequestVCI/OAuthDetailsRequestVCIResult
input: '{
"requestTime": "$TIMESTAMP$",
"clientId": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"scope": "mosip_identity_vc_ldp",
"responseType": "code",
"redirectUri": "$IDPREDIRECTURI$",
"display": "popup",
"prompt": "login",
"acrValues": "mosip:idp:acr:generated-code mosip:idp:acr:linked-wallet mosip:idp:acr:biometrics",
"nonce": "973eieljzng",
"state": "eree2311",
"claimsLocales": "en",
"codeChallenge": "$CODECHALLENGE$",
"codeChallengeMethod": "S256"
}'
output: '{

}'

ESignet_OAuthDetailsRequest_VCI_uin_1stLang_all_Valid_Smoke_sid:
Expand Down
Loading

0 comments on commit 70d0d98

Please sign in to comment.