diff --git a/.github/workflows/chart-lint-publish.yml b/.github/workflows/chart-lint-publish.yml index 80f2b96c2..f0b733345 100644 --- a/.github/workflows/chart-lint-publish.yml +++ b/.github/workflows/chart-lint-publish.yml @@ -6,7 +6,7 @@ on: pull_request: types: [opened, reopened, synchronize] paths: - - 'charts/**' + - 'helm/**' workflow_dispatch: inputs: IGNORE_CHARTS: diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml index c8a4b17cb..d5a4ae04b 100644 --- a/.github/workflows/push-trigger.yml +++ b/.github/workflows/push-trigger.yml @@ -130,14 +130,61 @@ jobs: GPG_SECRET: ${{ secrets.GPG_SECRET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - build-dockers_apitest_esignet: + build-apitest-esignet-local: needs: build-maven-apitest-esignet + runs-on: ubuntu-latest + env: + NAMESPACE: ${{ secrets.dev_namespace_docker_hub }} + SERVICE_NAME: apitest-esignet + SERVICE_LOCATION: apitest + BUILD_ARTIFACT: apitest-esignet-local + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + ref: ${{ github.ref }} + java-version: 11 + server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Setup the settings file for ossrh server + run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false sonar . https://sonarcloud.io false " > $GITHUB_WORKSPACE/settings.xml + - name: Build Automationtests with Maven + run: | + cd ${{ env.SERVICE_LOCATION}} + mvn clean package -s $GITHUB_WORKSPACE/settings.xml + - name: Copy configuration files to target directory. + run: | + cp -r ${{ env.SERVICE_LOCATION}}/target/classes/config ${{ env.SERVICE_LOCATION}}/target/config + cp -r ${{ env.SERVICE_LOCATION}}/testNgXmlFiles ${{ env.SERVICE_LOCATION}}/target/testNgXmlFiles + - name: Ready the springboot artifacts + if: ${{ !contains(github.ref, 'master') || !contains(github.ref, 'main') }} + run: | + ## FIND JARS & COPY ONLY EXECUTABLE JARs STORED UNDER TARGET DIRECTORY + find ${{ env.SERVICE_LOCATION }} -path '*/target/*' -exec zip ${{ env.BUILD_ARTIFACT }}.zip {} + + - name: Upload the springboot jars + if: ${{ !contains(github.ref, 'master') || !contains(github.ref, 'main') }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_ARTIFACT }} + path: ${{ env.BUILD_ARTIFACT }}.zip + - uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,message,author,commit,workflow,job # selectable (default: repo,message) + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required + if: failure() # Pick up events even if the job fails or is canceled. + + build-dockers_apitest_esignet: + needs: build-apitest-esignet-local strategy: matrix: include: - SERVICE_LOCATION: 'apitest' SERVICE_NAME: 'apitest-esignet' - BUILD_ARTIFACT: 'apitest-esignet' + BUILD_ARTIFACT: 'apitest-esignet-local' + ONLY_DOCKER: true fail-fast: false name: ${{ matrix.SERVICE_NAME }} uses: mosip/kattu/.github/workflows/docker-build.yml@master @@ -145,6 +192,7 @@ jobs: SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }} SERVICE_NAME: ${{ matrix.SERVICE_NAME }} BUILD_ARTIFACT: ${{ matrix.BUILD_ARTIFACT }} + ONLY_DOCKER: ${{ matrix.ONLY_DOCKER }} secrets: DEV_NAMESPACE_DOCKER_HUB: ${{ secrets.DEV_NAMESPACE_DOCKER_HUB }} ACTOR_DOCKER_HUB: ${{ secrets.ACTOR_DOCKER_HUB }} @@ -164,4 +212,4 @@ jobs: OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} GPG_SECRET: ${{ secrets.GPG_SECRET }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/apitest/Dockerfile b/apitest/Dockerfile index bc00e7589..287c09bd2 100644 --- a/apitest/Dockerfile +++ b/apitest/Dockerfile @@ -37,7 +37,7 @@ WORKDIR /home/${container_user} ENV work_dir=/home/${container_user} -ADD ./target/ $work_dir +ADD ./apitest/target/ $work_dir ADD entrypoint.sh $work_dir/entrypoint.sh diff --git a/apitest/pom.xml b/apitest/pom.xml index 84dbc0e7e..9f32a2da2 100644 --- a/apitest/pom.xml +++ b/apitest/pom.xml @@ -8,7 +8,7 @@ apitest-esignet Parent project of apitest-esignet https://github.com/mosip/esignet - 1.2.0.1-SNAPSHOT + 1.2.1-SNAPSHOT @@ -386,9 +386,9 @@ - io.mosip.testrig.apirig.automationtests.commons + io.mosip.testrig.apirig.apitest.commons apitest-commons - 1.2.0.1-SNAPSHOT + 1.2.1-SNAPSHOT diff --git a/apitest/src/main/java/io/mosip/testrig/apirig/testscripts/EsignetBioAuth.java b/apitest/src/main/java/io/mosip/testrig/apirig/testscripts/EsignetBioAuth.java index c89d990c9..060265d6a 100644 --- a/apitest/src/main/java/io/mosip/testrig/apirig/testscripts/EsignetBioAuth.java +++ b/apitest/src/main/java/io/mosip/testrig/apirig/testscripts/EsignetBioAuth.java @@ -111,12 +111,20 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad request.remove(GlobalConstants.IDENTITYREQUEST); } identityRequest = buildIdentityRequest(identityRequest); + identityRequest = inputJsonKeyWordHandeler(identityRequest, testCaseName); JSONObject identityReqJson = new JSONObject(identityRequest); identityRequestTemplate = identityReqJson.getString("identityRequestTemplate"); identityReqJson.remove("identityRequestTemplate"); identityRequestEncUrl = identityReqJson.getString("identityRequestEncUrl"); identityReqJson.remove("identityRequestEncUrl"); + + if (identityReqJson.has("transactionId")) { + String oidcTransactionId = AdminTestUtil.getAuthTransactionId(identityReqJson.getString("transactionId")); + if (oidcTransactionId != null && !oidcTransactionId.isBlank()) + identityReqJson.put("transactionId", oidcTransactionId); + } + identityRequest = getJsonFromTemplate(identityReqJson.toString(), identityRequestTemplate); if (identityRequest.contains("$DOMAINURI$")) { String domainUrl = ApplnURI.replace("api-internal", GlobalConstants.ESIGNET); @@ -187,7 +195,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad } catch (SkipException e) { throw new SkipException(e.getMessage()); } catch (Exception e) { - logger.error(e.getMessage()); + throw new AdminTestException(e.getMessage()); } } diff --git a/apitest/src/main/resources/esignet/AddIdentity/AddIdentity.yml b/apitest/src/main/resources/esignet/AddIdentity/AddIdentity.yml index bc572f354..c57883c96 100644 --- a/apitest/src/main/resources/esignet/AddIdentity/AddIdentity.yml +++ b/apitest/src/main/resources/esignet/AddIdentity/AddIdentity.yml @@ -269,6 +269,33 @@ AddIdentity: "status":"ACTIVATED" }' + ESignet_AddIdentity_Linked_Consent_User2_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_Linked_Consent_User2_smoke_Pos@mosip.net", + "phone": "9876543210", + "referenceIdentityNumber": "6789545678878", + "version": "v1", + "introducerRID": "212124324784879", + "introducerUIN": "212124324784879", + "category": "individualBiometrics", + "requesttime": "$TIMESTAMP$" +}' + output: '{ + "status":"ACTIVATED" +}' + ESignet_AddIdentity_Linked_Consent_Vid_smoke_Pos: endPoint: /idrepository/v1/identity/ role: idrepo @@ -296,6 +323,33 @@ AddIdentity: "status":"ACTIVATED" }' + ESignet_AddIdentity_Linked_Consent_User2_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": "ESignet_AddIdentity_Linked_Consent_User2_Vid_smoke_Pos@mosip.net", + "phone": "9876543210", + "referenceIdentityNumber": "6789545678878", + "version": "v1", + "introducerRID": "212124324784879", + "introducerUIN": "212124324784879", + "category": "individualBiometrics", + "requesttime": "$TIMESTAMP$" +}' + output: '{ + "status":"ACTIVATED" +}' + ESignet_AddIdentity_BioAuth_smoke_Pos: endPoint: /idrepository/v1/identity/ role: idrepo diff --git a/apitest/src/main/resources/esignet/AuthenticateUser/AuthenticateUser.yml b/apitest/src/main/resources/esignet/AuthenticateUser/AuthenticateUser.yml index ed16bd8e1..2930bd815 100644 --- a/apitest/src/main/resources/esignet/AuthenticateUser/AuthenticateUser.yml +++ b/apitest/src/main/resources/esignet/AuthenticateUser/AuthenticateUser.yml @@ -227,7 +227,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "IDA-OTA-004", + "errorCode": "IDA-OTA-012", "errorMessage": "$IGNORE$" } ], @@ -749,6 +749,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_length checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -773,7 +774,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -788,6 +789,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -827,6 +829,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -890,7 +893,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -905,6 +908,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_length checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -929,7 +933,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -968,7 +972,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "IDA-OTA-004", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -983,6 +987,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -1022,6 +1027,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -1085,7 +1091,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "IDA-OTA-004", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -1703,7 +1709,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -1718,6 +1724,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -1757,6 +1764,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -1796,6 +1804,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_length checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -1820,7 +1829,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -1835,6 +1844,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_length,invalid_auth_factor_type_format checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -1859,7 +1869,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -1898,7 +1908,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "IDA-OTA-004", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], @@ -1913,6 +1923,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -1952,6 +1963,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -1991,6 +2003,7 @@ AuthenticateUser: endPoint: /v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_length checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/AuthenticateUser/AuthenticateUser @@ -2015,7 +2028,7 @@ AuthenticateUser: output: '{ "errors": [ { - "errorCode": "IDA-OTA-004", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ], diff --git a/apitest/src/main/resources/esignet/BioAuthIdp/BioAuthIdp.yml b/apitest/src/main/resources/esignet/BioAuthIdp/BioAuthIdp.yml index 6a3da0d16..5c53cb466 100644 --- a/apitest/src/main/resources/esignet/BioAuthIdp/BioAuthIdp.yml +++ b/apitest/src/main/resources/esignet/BioAuthIdp/BioAuthIdp.yml @@ -30,7 +30,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467171", "type": "Face", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_13all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -70,7 +70,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_2all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -109,7 +109,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_3all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -148,7 +148,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_4all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -187,7 +187,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_5all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -226,7 +226,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_6all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -265,7 +265,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_7all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -304,7 +304,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_8all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -343,7 +343,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_9all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -382,7 +382,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_10all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -421,7 +421,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Iris", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_11all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -460,7 +460,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Iris", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_12all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -499,7 +499,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467171", "type": "Face", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_14all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -538,7 +538,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_15all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -577,7 +577,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_16all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -616,7 +616,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_17all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -655,7 +655,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_18all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -694,7 +694,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_19all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -733,7 +733,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_20all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -772,7 +772,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_21all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -811,7 +811,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_22all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -850,7 +850,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Finger", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_23all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -889,7 +889,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Iris", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_24all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } @@ -928,7 +928,7 @@ BioAuth: "model": "4d36e96c-e325-11ce-bfc1-08002be10318", "serialNo": "78467175", "type": "Iris", - "transactionId": "$TRANSACTIONID$", + "transactionId": "$ID:OAuthDetailsRequest_25all_Valid_Smoke_sid_transactionId$", "identityRequestTemplate": "esignet/BioAuthIdp/BioAuthIdentityEncrypt", "identityRequestEncUrl": "/idauthentication/v1/internal/encrypt" } diff --git a/apitest/src/main/resources/esignet/BioAuthIdp/BioNonAuth.yml b/apitest/src/main/resources/esignet/BioAuthIdp/BioNonAuth.yml index 90e63d63a..6190e08d9 100644 --- a/apitest/src/main/resources/esignet/BioAuthIdp/BioNonAuth.yml +++ b/apitest/src/main/resources/esignet/BioAuthIdp/BioNonAuth.yml @@ -425,7 +425,7 @@ BioNonAuth: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ] @@ -943,7 +943,7 @@ BioNonAuth: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch", + "errorCode": "invalid_challenge_length", "errorMessage": "$IGNORE$" } ] diff --git a/apitest/src/main/resources/esignet/GenerateLinkCode/GenerateLinkCode.yml b/apitest/src/main/resources/esignet/GenerateLinkCode/GenerateLinkCode.yml index 51efc7617..3329a181d 100644 --- a/apitest/src/main/resources/esignet/GenerateLinkCode/GenerateLinkCode.yml +++ b/apitest/src/main/resources/esignet/GenerateLinkCode/GenerateLinkCode.yml @@ -91,38 +91,6 @@ GenerateLinkCode: }' output: '{ -}' - - ESignet_GenerateLinkCode_Consent_uin_SameClaim_NoBinding_all_Valid_Smoke_sid: - endPoint: /v1/esignet/linked-authorization/link-code - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - validityCheckRequired: true - inputTemplate: esignet/GenerateLinkCode/GenerateLinkCode - outputTemplate: esignet/GenerateLinkCode/GenerateLinkCodeResult - input: '{ - "requestTime": "$TIMESTAMP$", - "transactionId": "$ID:OAuthDetailsRequest_LinkAuth_Consent_SameClaim_Uin_NoBinding_Valid_Smoke_sid_transactionId$" -}' - output: '{ - -}' - - ESignet_GenerateLinkCode_Consent_Vid_SameClaim_NoBinding_all_Valid_Smoke_sid: - endPoint: /v1/esignet/linked-authorization/link-code - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - validityCheckRequired: true - inputTemplate: esignet/GenerateLinkCode/GenerateLinkCode - outputTemplate: esignet/GenerateLinkCode/GenerateLinkCodeResult - input: '{ - "requestTime": "$TIMESTAMP$", - "transactionId": "$ID:OAuthDetailsRequest_LinkAuth_Consent_SameClaim_Uin_NoBinding_Valid_Smoke_sid_transactionId$" -}' - output: '{ - }' ESignet_GenerateLinkCode_Invalid_RequestTime_Neg: diff --git a/apitest/src/main/resources/esignet/GenerateVID/createGenerateVID.yml b/apitest/src/main/resources/esignet/GenerateVID/createGenerateVID.yml index f3e3729c8..f234de51b 100644 --- a/apitest/src/main/resources/esignet/GenerateVID/createGenerateVID.yml +++ b/apitest/src/main/resources/esignet/GenerateVID/createGenerateVID.yml @@ -454,6 +454,41 @@ GenerateVID: } }' + ESignetRes_Generate_Perpetual_VID_Linked_Consent_User2_Valid_Smoke_sid: + endPoint: /resident/v1/vid + role: resident + checkErrorsOnlyInResponse: true + restMethod: post + inputTemplate: esignet/GenerateVID/createGenerateVID + outputTemplate: esignet/GenerateVID/createGenerateVIDResult + input: '{ + "transactionID": "$TRANSACTIONID$", + "individualId": "$ID:AddIdentity_Linked_Consent_User2_Vid_smoke_Pos_UIN$", + "individualIdType": "UIN", + "requesttime": "$TIMESTAMP$", + "id": "mosip.resident.vid", + "version": "v1", + "vidType": "Perpetual", + "otp": "$ID:AddIdentity_Linked_Consent_User2_Vid_smoke_Pos_EMAIL$", + "sendOtp":{ + "transactionID": "$TRANSACTIONID$", + "requestTime": "$TIMESTAMP$", + "individualId": "$ID:AddIdentity_Linked_Consent_User2_Vid_smoke_Pos_UIN$", + "individualIdType": "UIN", + "sendOtpReqTemplate": "esignet/SendOTPRes/createSendOTP", + "sendOtpEndPoint": "/resident/v1/req/otp" + } + }' + output: '{ + "vid": "$IGNORE$", + "message": "$IGNORE$", + "sendOtpResp":{ + "maskedMobile": "$IGNORE$", + "sendOtpResTemplate":"esignet/SendOTPRes/createSendOTPResult", + "maskedEmail": "$IGNORE$" + } +}' + ESignetRes_Generate_Perpetual_VID_VCI_Valid_Smoke_sid: endPoint: /resident/v1/vid role: resident diff --git a/apitest/src/main/resources/esignet/GetLinkStatus/GetLinkStatus.yml b/apitest/src/main/resources/esignet/GetLinkStatus/GetLinkStatus.yml index 8b5e23458..fb4cf57f5 100644 --- a/apitest/src/main/resources/esignet/GetLinkStatus/GetLinkStatus.yml +++ b/apitest/src/main/resources/esignet/GetLinkStatus/GetLinkStatus.yml @@ -97,40 +97,6 @@ GetLinkStatus: }' output: '{ -}' - - ESignet_GetLinkStatus_Consent_uin_SameClaim_NoBinding_all_Valid_Smoke: - endPoint: /v1/esignet/linked-authorization/link-status - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - validityCheckRequired: true - inputTemplate: esignet/GetLinkStatus/GetLinkStatus - outputTemplate: esignet/GetLinkStatus/GetLinkStatusResult - input: '{ - "requestTime": "$TIMESTAMP$", - "transactionId": "$ID:OAuthDetailsRequest_LinkAuth_Consent_SameClaim_Uin_NoBinding_Valid_Smoke_sid_transactionId$", - "linkCode": "$ID:GenerateLinkCode_Consent_uin_SameClaim_NoBinding_all_Valid_Smoke_sid_linkCode$" -}' - output: '{ - -}' - - ESignet_GetLinkStatus_Consent_Vid_SameClaim_NoBinding_all_Valid_Smoke: - endPoint: /v1/esignet/linked-authorization/link-status - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - validityCheckRequired: true - inputTemplate: esignet/GetLinkStatus/GetLinkStatus - outputTemplate: esignet/GetLinkStatus/GetLinkStatusResult - input: '{ - "requestTime": "$TIMESTAMP$", - "transactionId": "$ID:OAuthDetailsRequest_LinkAuth_Consent_SameClaim_Vid_NoBinding_Valid_Smoke_sid_transactionId$", - "linkCode": "$ID:GenerateLinkCode_Consent_Vid_SameClaim_NoBinding_all_Valid_Smoke_sid_linkCode$" -}' - output: '{ - }' ESignet_GetLinkStatus_Invalid_RequestTime_Neg: diff --git a/apitest/src/main/resources/esignet/LinkTransaction/LinkTransaction.yml b/apitest/src/main/resources/esignet/LinkTransaction/LinkTransaction.yml index cf130f1dc..b9aad43a5 100644 --- a/apitest/src/main/resources/esignet/LinkTransaction/LinkTransaction.yml +++ b/apitest/src/main/resources/esignet/LinkTransaction/LinkTransaction.yml @@ -91,38 +91,6 @@ LinkTransaction: }' output: '{ -}' - - ESignet_LinkTransaction_Consent_uin_SameClaim_NoBinding_all_Valid_Smoke_sid: - endPoint: /v1/esignet/linked-authorization/link-transaction - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - validityCheckRequired: true - inputTemplate: esignet/LinkTransaction/LinkTransaction - outputTemplate: esignet/LinkTransaction/LinkTransactionResult - input: '{ - "requestTime": "$TIMESTAMP$", - "linkCode": "$ID:GenerateLinkCode_Consent_uin_SameClaim_NoBinding_all_Valid_Smoke_sid_linkCode$" -}' - output: '{ - -}' - - ESignet_LinkTransaction_Consent_Vid_SameClaim_NoBinding_all_Valid_Smoke_sid: - endPoint: /v1/esignet/linked-authorization/link-transaction - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - validityCheckRequired: true - inputTemplate: esignet/LinkTransaction/LinkTransaction - outputTemplate: esignet/LinkTransaction/LinkTransactionResult - input: '{ - "requestTime": "$TIMESTAMP$", - "linkCode": "$ID:GenerateLinkCode_Consent_Vid_SameClaim_NoBinding_all_Valid_Smoke_sid_linkCode$" -}' - output: '{ - }' ESignet_LinkTransaction_Invalid_RequestTime_Neg: diff --git a/apitest/src/main/resources/esignet/LinkedAuthenticationWla/LinkedAuthenticationWla.yml b/apitest/src/main/resources/esignet/LinkedAuthenticationWla/LinkedAuthenticationWla.yml index a4b844f70..9a3e3d6a9 100644 --- a/apitest/src/main/resources/esignet/LinkedAuthenticationWla/LinkedAuthenticationWla.yml +++ b/apitest/src/main/resources/esignet/LinkedAuthenticationWla/LinkedAuthenticationWla.yml @@ -112,7 +112,7 @@ LinkedAuthenticationWla: input: '{ "requestTime": "$TIMESTAMP$", "linkTransactionId": "$ID:LinkTransaction_Consent_uin_User2_all_Valid_Smoke_sid_linkTransactionId$", - "individualId": "$ID:AddIdentity_Linked_Consent_smoke_Pos_UIN$", + "individualId": "$ID:AddIdentity_Linked_Consent_User2_smoke_Pos_UIN$", "authFactorType": "WLA", "challenge": "$WLATOKENCONSENTUSER2$", "format": "jwt", @@ -120,7 +120,7 @@ LinkedAuthenticationWla: "apiKey": "$ID:GenerateApiKeyKyc_Valid_Smoke_sid_apiKey$", "partnerId": "$ID:PartnerSelfRegistration_Kyc_Valid_Smoke_sid_partnerId$", "requestTime": "$TIMESTAMP$", - "individualId": "$ID:AddIdentity_Linked_Consent_smoke_Pos_UIN$", + "individualId": "$ID:AddIdentity_Linked_Consent_User2_smoke_Pos_UIN$", "otpChannels": [{channel: "email"},{channel: "phone"}], "sendOtpReqTemplate": "esignet/SendBindingOtp/SendBindingOtp", "sendOtpEndPoint": "/v1/esignet/binding/binding-otp", @@ -129,11 +129,11 @@ LinkedAuthenticationWla: "apiKey": "$ID:GenerateApiKeyKyc_Valid_Smoke_sid_apiKey$", "partnerId": "$ID:PartnerSelfRegistration_Kyc_Valid_Smoke_sid_partnerId$", "requestTime": "$TIMESTAMP$", - "individualId": "$ID:AddIdentity_Linked_Consent_smoke_Pos_UIN$", + "individualId": "$ID:AddIdentity_Linked_Consent_User2_smoke_Pos_UIN$", "authFactorType1": "WLA", "format1": "jwt", "authFactorType": "OTP", - "challenge": "$ID:AddIdentity_Linked_Consent_smoke_Pos_EMAIL$", + "challenge": "$ID:AddIdentity_Linked_Consent_User2_smoke_Pos_EMAIL$", "format": "alpha-numeric", "publicKey": "$BINDINGCONSENTUSER2JWKKEY$", "validateOtpReqTemplate": "esignet/WalletBinding/WalletBinding", @@ -163,7 +163,7 @@ LinkedAuthenticationWla: input: '{ "requestTime": "$TIMESTAMP$", "linkTransactionId": "$ID:LinkTransaction_Consent_Vid_User2_all_Valid_Smoke_sid_linkTransactionId$", - "individualId": "$ID:Generate_Perpetual_VID_Linked_Consent_Valid_Smoke_sid_vid$", + "individualId": "$ID:Generate_Perpetual_VID_Linked_Consent_User2_Valid_Smoke_sid_vid$", "authFactorType": "WLA", "challenge": "$WLATOKENCONSENTVIDUSER2$", "format": "jwt", @@ -171,7 +171,7 @@ LinkedAuthenticationWla: "apiKey": "$ID:GenerateApiKeyKyc_Valid_Smoke_sid_apiKey$", "partnerId": "$ID:PartnerSelfRegistration_Kyc_Valid_Smoke_sid_partnerId$", "requestTime": "$TIMESTAMP$", - "individualId": "$ID:Generate_Perpetual_VID_Linked_Consent_Valid_Smoke_sid_vid$", + "individualId": "$ID:Generate_Perpetual_VID_Linked_Consent_User2_Valid_Smoke_sid_vid$", "otpChannels": [{channel: "email"},{channel: "phone"}], "sendOtpReqTemplate": "esignet/SendBindingOtp/SendBindingOtp", "sendOtpEndPoint": "/v1/esignet/binding/binding-otp", @@ -180,11 +180,11 @@ LinkedAuthenticationWla: "apiKey": "$ID:GenerateApiKeyKyc_Valid_Smoke_sid_apiKey$", "partnerId": "$ID:PartnerSelfRegistration_Kyc_Valid_Smoke_sid_partnerId$", "requestTime": "$TIMESTAMP$", - "individualId": "$ID:Generate_Perpetual_VID_Linked_Consent_Valid_Smoke_sid_vid$", + "individualId": "$ID:Generate_Perpetual_VID_Linked_Consent_User2_Valid_Smoke_sid_vid$", "authFactorType1": "WLA", "format1": "jwt", "authFactorType": "OTP", - "challenge": "$ID:AddIdentity_Linked_Consent_Vid_smoke_Pos_EMAIL$", + "challenge": "$ID:AddIdentity_Linked_Consent_User2_Vid_smoke_Pos_EMAIL$", "format": "alpha-numeric", "publicKey": "$BINDINGCONSENTVIDUSER2JWKKEY$", "validateOtpReqTemplate": "esignet/WalletBinding/WalletBinding", diff --git a/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWla.hbs b/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWla.hbs deleted file mode 100644 index 86c04fe41..000000000 --- a/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWla.hbs +++ /dev/null @@ -1,14 +0,0 @@ -{ - "requestTime": "{{requestTime}}", - "request": { - "linkedTransactionId": "{{linkTransactionId}}", - "individualId": "{{individualId}}", - "challengeList": [ - { - "authFactorType": "{{authFactorType}}", - "challenge": "{{challenge}}", - "format": "{{format}}" - } - ] - } -} \ No newline at end of file diff --git a/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWla.yml b/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWla.yml deleted file mode 100644 index 2cc6f8468..000000000 --- a/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWla.yml +++ /dev/null @@ -1,40 +0,0 @@ -LinkedAuthenticationWlaNoBinding: - ESignet_LinkedAuthenticationWlaNoBinding_Consent_SameClaim_uin_SCert_all_Valid_Smoke: - endPoint: /v1/esignet/linked-authorization/v2/authenticate - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - validityCheckRequired: true - inputTemplate: esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWla - outputTemplate: esignet/LinkedConsent/LinkedAuthenticationConsentWla/LinkedAuthenticationConsentWlaResult - input: '{ - "requestTime": "$TIMESTAMP$", - "linkTransactionId": "$ID:LinkTransaction_Consent_uin_SameClaim_NoBinding_all_Valid_Smoke_sid_linkTransactionId$", - "individualId": "$ID:AddIdentity_Linked_Consent_smoke_Pos_UIN$", - "authFactorType": "WLA", - "challenge": "$WLATOKENCONSENT$", - "format": "jwt" -}' - output: '{ - "consentAction": "NOCAPTURE" -}' - - ESignet_LinkedAuthenticationWlaNoBinding_Consent_SameClaim_Vid_SCert_all_Valid_Smoke: - endPoint: /v1/esignet/linked-authorization/v2/authenticate - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - validityCheckRequired: true - inputTemplate: esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWla - outputTemplate: esignet/LinkedConsent/LinkedAuthenticationConsentWla/LinkedAuthenticationConsentWlaResult - input: '{ - "requestTime": "$TIMESTAMP$", - "linkTransactionId": "$ID:LinkTransaction_Consent_Vid_SameClaim_NoBinding_all_Valid_Smoke_sid_linkTransactionId$", - "individualId": "$ID:Generate_Perpetual_VID_Linked_Consent_Valid_Smoke_sid_vid$", - "authFactorType": "WLA", - "challenge": "$WLATOKENCONSENTVID$", - "format": "jwt" -}' - output: '{ - "consentAction": "NOCAPTURE" -}' \ No newline at end of file diff --git a/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWlaResult.hbs b/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWlaResult.hbs deleted file mode 100644 index 9e26dfeeb..000000000 --- a/apitest/src/main/resources/esignet/LinkedAuthenticationWlaNoBinding/LinkedAuthenticationWlaResult.hbs +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/apitest/src/main/resources/esignet/OAuthDetailsRequestLinked/OAuthDetailsRequest.yml b/apitest/src/main/resources/esignet/OAuthDetailsRequestLinked/OAuthDetailsRequest.yml index 3d676e4ea..82113bf71 100644 --- a/apitest/src/main/resources/esignet/OAuthDetailsRequestLinked/OAuthDetailsRequest.yml +++ b/apitest/src/main/resources/esignet/OAuthDetailsRequestLinked/OAuthDetailsRequest.yml @@ -141,54 +141,6 @@ OAuthDetailsRequestLinked: }' output: '{ -}' - - ESignet_OAuthDetailsRequest_LinkAuth_Consent_SameClaim_Uin_NoBinding_Valid_Smoke_sid: - endPoint: /v1/esignet/authorization/oauth-details - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - inputTemplate: esignet/OAuthDetailsRequest/OAuthDetailsRequest - outputTemplate: esignet/OAuthDetailsRequest/OAuthDetailsRequestResult - input: '{ - "requestTime": "$TIMESTAMP$", - "clientId": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$", - "scope": "openid resident-service profile", - "responseType": "code", - "redirectUri": "$IDPREDIRECTURI$", - "display": "popup", - "prompt": "login", - "acrValues": "mosip:idp:acr:linked-wallet", - "nonce": "973eieljzng", - "state": "eree2311", - "claimsLocales": "en" -}' - output: '{ - -}' - - ESignet_OAuthDetailsRequest_LinkAuth_Consent_SameClaim_Vid_NoBinding_Valid_Smoke_sid: - endPoint: /v1/esignet/authorization/oauth-details - role: resident - checkErrorsOnlyInResponse: true - restMethod: post - inputTemplate: esignet/OAuthDetailsRequest/OAuthDetailsRequest - outputTemplate: esignet/OAuthDetailsRequest/OAuthDetailsRequestResult - input: '{ - "requestTime": "$TIMESTAMP$", - "clientId": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$", - "scope": "openid resident-service profile", - "responseType": "code", - "redirectUri": "$IDPREDIRECTURI$", - "display": "popup", - "prompt": "login", - "acrValues": "mosip:idp:acr:linked-wallet", - "nonce": "973eieljzng", - "state": "eree2311", - "claimsLocales": "en" -}' - output: '{ - }' ESignet_OAuthDetailsRequest_LinkAuth_Other_Valid_Smoke_sid: diff --git a/apitest/src/main/resources/esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC.yml b/apitest/src/main/resources/esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC.yml index e85b18acf..ba0890e9f 100644 --- a/apitest/src/main/resources/esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC.yml +++ b/apitest/src/main/resources/esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC.yml @@ -228,6 +228,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_length checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -244,7 +245,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch" + "errorCode": "invalid_challenge_length" } ] }' @@ -253,6 +254,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -278,6 +280,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -303,6 +306,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_length checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -319,7 +323,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch" + "errorCode": "invalid_challenge_length" } ] }' @@ -328,6 +332,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_length checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -344,7 +349,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "auth_factor_mismatch" + "errorCode": "invalid_challenge_length" } ] }' @@ -353,6 +358,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -378,6 +384,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -403,6 +410,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -478,6 +486,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -519,7 +528,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "auth_failed" + "errorCode": "invalid_challenge_length" } ] }' @@ -553,6 +562,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -578,6 +588,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -603,6 +614,7 @@ AuthenticateUserSunBirdRCNegTC: endPoint: $ESIGNETMOCKBASEURL$/v1/esignet/authorization/authenticate role: resident restMethod: post + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true inputTemplate: esignet/SunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC/AuthenticateUserSunBirdRCNegTC @@ -689,7 +701,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format" + "errorCode": "invalid_auth_factor_type_format" } ] }' @@ -714,7 +726,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format" + "errorCode": "invalid_auth_factor_type_format" } ] }' @@ -739,7 +751,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format" + "errorCode": "invalid_auth_factor_type_format" } ] }' @@ -764,7 +776,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format" + "errorCode": "invalid_auth_factor_type_format" } ] }' @@ -789,7 +801,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format" + "errorCode": "invalid_auth_factor_type_format" } ] }' @@ -814,7 +826,7 @@ AuthenticateUserSunBirdRCNegTC: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format" + "errorCode": "invalid_auth_factor_type_format" } ] }' diff --git a/apitest/src/main/resources/esignet/VCINegTC/GetCredential/GetCredential.yml b/apitest/src/main/resources/esignet/VCINegTC/GetCredential/GetCredential.yml index 88eb08b85..9057a5242 100644 --- a/apitest/src/main/resources/esignet/VCINegTC/GetCredential/GetCredential.yml +++ b/apitest/src/main/resources/esignet/VCINegTC/GetCredential/GetCredential.yml @@ -122,7 +122,7 @@ GetCredentialNegTC: "proof_jwt": "$PROOFJWT$" }' output: '{ - "error": "unknown_error" + "error": "not_implemented" }' ESignet_GetCredential_uin_IdpAccessToken_Inval2_Format_Neg: @@ -143,7 +143,7 @@ GetCredentialNegTC: "proof_jwt": "$PROOFJWT$" }' output: '{ - "error": "unknown_error" + "error": "not_implemented" }' ESignet_GetCredential_uin_IdpAccessToken_Inval3_Format_Neg: diff --git a/apitest/src/main/resources/esignet/VCIVidNegTC/GetCredential/GetCredential.yml b/apitest/src/main/resources/esignet/VCIVidNegTC/GetCredential/GetCredential.yml index a1bdfee29..6fc0afa15 100644 --- a/apitest/src/main/resources/esignet/VCIVidNegTC/GetCredential/GetCredential.yml +++ b/apitest/src/main/resources/esignet/VCIVidNegTC/GetCredential/GetCredential.yml @@ -122,7 +122,7 @@ GetCredentialVidNegTC: "proof_jwt": "$PROOFJWT$" }' output: '{ - "error": "unknown_error" + "error": "not_implemented" }' ESignet_GetCredential_Vid_IdpAccessToken_Inval2_Format_Neg: @@ -143,7 +143,7 @@ GetCredentialVidNegTC: "proof_jwt": "$PROOFJWT$" }' output: '{ - "error": "unknown_error" + "error": "not_implemented" }' ESignet_GetCredential_Vid_IdpAccessToken_Inval3_Format_Neg: @@ -831,5 +831,5 @@ GetCredentialVidNegTC: "proof_jwt": "$PROOFJWT$" }' output: '{ - "error":"invalid_proof" + "error":"vci_exchange_failed" }' \ No newline at end of file diff --git a/apitest/src/main/resources/esignet/WalletBinding/WalletBinding.yml b/apitest/src/main/resources/esignet/WalletBinding/WalletBinding.yml index 581782171..c5e5f8037 100644 --- a/apitest/src/main/resources/esignet/WalletBinding/WalletBinding.yml +++ b/apitest/src/main/resources/esignet/WalletBinding/WalletBinding.yml @@ -522,8 +522,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_auth_factor_type_or_challenge_format", - "errorMessage": "request.challengeList[0].authFactorType: invalid_auth_factor_type" + "errorCode": "invalid_challenge_length" } ], "sendOtpResp": { @@ -536,6 +535,7 @@ WalletBinding: ESignet_WalletBinding_uin_Missing_AuthFactorType_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -565,8 +565,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_auth_factor_type", - "errorMessage": "request.challengeList[0].authFactorType: invalid_auth_factor_type" + "errorCode": "invalid_auth_factor_type" } ], "sendOtpResp": { @@ -579,6 +578,7 @@ WalletBinding: ESignet_WalletBinding_uin_EmptyVal_AuthFactorType_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -608,8 +608,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_auth_factor_type", - "errorMessage": "request.challengeList[0].authFactorType: invalid_auth_factor_type" + "errorCode": "invalid_auth_factor_type" } ], "sendOtpResp": { @@ -622,6 +621,7 @@ WalletBinding: ESignet_WalletBinding_uin_SpaceVal_AuthFactorType_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -694,8 +694,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "binding_auth_failed", - "errorMessage": "request.challengeList[0].challenge: invalid_challenge" + "errorCode": "invalid_challenge_length" } ], "sendOtpResp": { @@ -708,6 +707,7 @@ WalletBinding: ESignet_WalletBinding_uin_EmptyVal_Challenge_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -751,6 +751,7 @@ WalletBinding: ESignet_WalletBinding_uin_Missing_Challenge_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -794,6 +795,7 @@ WalletBinding: ESignet_WalletBinding_uin_SpaceVal_Challenge_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -866,8 +868,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_auth_factor_type_or_challenge_format", - "errorMessage": "request.format: unsupported_challenge_format" + "errorCode": "invalid_auth_factor_type_format" } ], "sendOtpResp": { @@ -880,6 +881,7 @@ WalletBinding: ESignet_WalletBinding_uin_Missing_Formate_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -909,8 +911,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format", - "errorMessage": "request.format: unsupported_challenge_format" + "errorCode": "invalid_challenge_format" } ], "sendOtpResp": { @@ -923,6 +924,7 @@ WalletBinding: ESignet_WalletBinding_uin_SpaceVal_Formate_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -966,6 +968,7 @@ WalletBinding: ESignet_WalletBinding_uin_Empty_Formate_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -995,8 +998,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format", - "errorMessage": "unsupported_challenge_format" + "errorCode": "invalid_challenge_format" } ], "sendOtpResp": { @@ -1807,8 +1809,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_auth_factor_type_or_challenge_format", - "errorMessage": "request.challengeList[0].authFactorType: invalid_auth_factor_type" + "errorCode": "invalid_challenge_length" } ], "sendOtpResp": { @@ -1821,6 +1822,7 @@ WalletBinding: ESignet_WalletBinding_Vid_Missing_AuthFactorType_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -1850,8 +1852,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_auth_factor_type", - "errorMessage": "request.challengeList[0].authFactorType: invalid_auth_factor_type" + "errorCode": "invalid_auth_factor_type" } ], "sendOtpResp": { @@ -1864,6 +1865,7 @@ WalletBinding: ESignet_WalletBinding_Vid_EmptyVal_AuthFactorType_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_auth_factor_type checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -1908,6 +1910,7 @@ WalletBinding: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth checkErrorsOnlyInResponse: true + allowedErrorCodes: invalid_auth_factor_type,invalid_auth_factor_type_format,invalid_challenge_length validityCheckRequired: true restMethod: post inputTemplate: esignet/WalletBinding/WalletBinding @@ -1979,8 +1982,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "binding_auth_failed", - "errorMessage": "request.challengeList[0].challenge: invalid_challenge" + "errorCode": "invalid_challenge_length" } ], "sendOtpResp": { @@ -1993,6 +1995,7 @@ WalletBinding: ESignet_WalletBinding_Vid_EmptyVal_Challenge_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -2036,6 +2039,7 @@ WalletBinding: ESignet_WalletBinding_Vid_Missing_Challenge_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -2079,6 +2083,7 @@ WalletBinding: ESignet_WalletBinding_Vid_SpaceVal_Challenge_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -2151,8 +2156,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_auth_factor_type_or_challenge_format", - "errorMessage": "request.format: unsupported_challenge_format" + "errorCode": "invalid_auth_factor_type_format" } ], "sendOtpResp": { @@ -2165,6 +2169,7 @@ WalletBinding: ESignet_WalletBinding_Vid_Missing_Formate_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -2208,6 +2213,7 @@ WalletBinding: ESignet_WalletBinding_Vid_SpaceVal_Formate_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -2251,6 +2257,7 @@ WalletBinding: ESignet_WalletBinding_Vid_Empty_Formate_Neg: endPoint: /v1/esignet/binding/wallet-binding role: mobileauth + allowedErrorCodes: invalid_challenge_format checkErrorsOnlyInResponse: true validityCheckRequired: true restMethod: post @@ -2280,8 +2287,7 @@ WalletBinding: output: '{ "errors": [ { - "errorCode": "invalid_challenge_format", - "errorMessage": "unsupported_challenge_format" + "errorCode": "invalid_challenge_format" } ], "sendOtpResp": { diff --git a/apitest/testNgXmlFiles/esignetSuite.xml b/apitest/testNgXmlFiles/esignetSuite.xml index 6f264a27e..eccd90d9b 100644 --- a/apitest/testNgXmlFiles/esignetSuite.xml +++ b/apitest/testNgXmlFiles/esignetSuite.xml @@ -5,11 +5,7 @@ - - - - + + - org.modelmapper - modelmapper - 3.1.1 + org.mapstruct + mapstruct + 1.5.5.Final + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.version} + + true + ${maven.compiler.source} + ${maven.compiler.target} + + + org.mapstruct + mapstruct-processor + 1.5.5.Final + + + + + + \ No newline at end of file diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/config/ModelMapperConfig.java b/consent-service-impl/src/main/java/io/mosip/esignet/config/ModelMapperConfig.java deleted file mode 100644 index 32c99cd43..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/config/ModelMapperConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.config; - - -import org.modelmapper.ModelMapper; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ModelMapperConfig { - - @Bean - public ModelMapper modelMapper() { - return new ModelMapper(); - } - -} diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/entity/ConsentDetail.java b/consent-service-impl/src/main/java/io/mosip/esignet/entity/ConsentDetail.java index 4f0073f51..ff296dce9 100644 --- a/consent-service-impl/src/main/java/io/mosip/esignet/entity/ConsentDetail.java +++ b/consent-service-impl/src/main/java/io/mosip/esignet/entity/ConsentDetail.java @@ -17,7 +17,6 @@ import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_CLAIM; import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_CLIENT_ID; -@Data @NoArgsConstructor @AllArgsConstructor @Entity @@ -79,4 +78,92 @@ public boolean equals(Object o) { public int hashCode() { return getClass().hashCode(); } + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public @NotNull(message = INVALID_CLIENT_ID) String getClientId() { + return clientId; + } + + public void setClientId(@NotNull(message = INVALID_CLIENT_ID) String clientId) { + this.clientId = clientId; + } + + public @NotNull String getPsuToken() { + return psuToken; + } + + public void setPsuToken(@NotNull String psuToken) { + this.psuToken = psuToken; + } + + public @NotNull(message = INVALID_CLAIM) String getClaims() { + return claims; + } + + public void setClaims(@NotNull(message = INVALID_CLAIM) String claims) { + this.claims = claims; + } + + public @NotNull String getAuthorizationScopes() { + return authorizationScopes; + } + + public void setAuthorizationScopes(@NotNull String authorizationScopes) { + this.authorizationScopes = authorizationScopes; + } + + public @NotNull LocalDateTime getCreatedtimes() { + return createdtimes; + } + + public void setCreatedtimes(@NotNull LocalDateTime createdtimes) { + this.createdtimes = createdtimes; + } + + public LocalDateTime getExpiredtimes() { + return expiredtimes; + } + + public void setExpiredtimes(LocalDateTime expiredtimes) { + this.expiredtimes = expiredtimes; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } + + public String getAcceptedClaims() { + return acceptedClaims; + } + + public void setAcceptedClaims(String acceptedClaims) { + this.acceptedClaims = acceptedClaims; + } + + public String getPermittedScopes() { + return permittedScopes; + } + + public void setPermittedScopes(String permittedScopes) { + this.permittedScopes = permittedScopes; + } } diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/entity/ConsentHistory.java b/consent-service-impl/src/main/java/io/mosip/esignet/entity/ConsentHistory.java index 52823d34d..592013f14 100644 --- a/consent-service-impl/src/main/java/io/mosip/esignet/entity/ConsentHistory.java +++ b/consent-service-impl/src/main/java/io/mosip/esignet/entity/ConsentHistory.java @@ -19,7 +19,6 @@ import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_CLAIM; import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_CLIENT_ID; -@Data @NoArgsConstructor @AllArgsConstructor @Entity @@ -75,4 +74,92 @@ public boolean equals(Object o) { public int hashCode() { return getClass().hashCode(); } + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public @NotNull(message = INVALID_CLIENT_ID) String getClientId() { + return clientId; + } + + public void setClientId(@NotNull(message = INVALID_CLIENT_ID) String clientId) { + this.clientId = clientId; + } + + public @NotNull String getPsuToken() { + return psuToken; + } + + public void setPsuToken(@NotNull String psuToken) { + this.psuToken = psuToken; + } + + public @NotNull(message = INVALID_CLAIM) String getClaims() { + return claims; + } + + public void setClaims(@NotNull(message = INVALID_CLAIM) String claims) { + this.claims = claims; + } + + public @NotNull String getAuthorizationScopes() { + return authorizationScopes; + } + + public void setAuthorizationScopes(@NotNull String authorizationScopes) { + this.authorizationScopes = authorizationScopes; + } + + public @NotNull LocalDateTime getCreatedtimes() { + return createdtimes; + } + + public void setCreatedtimes(@NotNull LocalDateTime createdtimes) { + this.createdtimes = createdtimes; + } + + public LocalDateTime getExpiredtimes() { + return expiredtimes; + } + + public void setExpiredtimes(LocalDateTime expiredtimes) { + this.expiredtimes = expiredtimes; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } + + public String getAcceptedClaims() { + return acceptedClaims; + } + + public void setAcceptedClaims(String acceptedClaims) { + this.acceptedClaims = acceptedClaims; + } + + public String getPermittedScopes() { + return permittedScopes; + } + + public void setPermittedScopes(String permittedScopes) { + this.permittedScopes = permittedScopes; + } } diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/ConsentMapper.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/ConsentMapper.java index 5c7ed9448..f781eb379 100644 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/ConsentMapper.java +++ b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/ConsentMapper.java @@ -1,50 +1,74 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ package io.mosip.esignet.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.mosip.esignet.api.dto.Claims; import io.mosip.esignet.core.dto.ConsentDetail; import io.mosip.esignet.core.dto.UserConsent; +import io.mosip.esignet.core.exception.EsignetException; import io.mosip.esignet.entity.ConsentHistory; -import io.mosip.esignet.mapper.converter.*; -import org.modelmapper.ModelMapper; +import org.apache.commons.lang3.StringUtils; +import org.mapstruct.Mapper; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_CLAIM; +import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_PERMITTED_SCOPE; +@Mapper(componentModel = "spring") +public abstract class ConsentMapper { + @Autowired + protected ObjectMapper objectMapper; -public class ConsentMapper { + public abstract io.mosip.esignet.entity.ConsentDetail toEntity(UserConsent userConsent); - private ConsentMapper(){} + public abstract ConsentDetail toDto(io.mosip.esignet.entity.ConsentDetail consentDetail); - private static final ModelMapper modelMapper = new ModelMapper(); + public abstract ConsentHistory toConsentHistoryEntity(UserConsent userConsent); + + public String convertClaimsToString(Claims claims) { + try { + return claims != null ? objectMapper.writeValueAsString(claims) : ""; + } catch (JsonProcessingException e) { + throw new EsignetException(INVALID_CLAIM); + } + } - static { - ObjectMapper objectMapper = new ObjectMapper(); - modelMapper.addConverter(new ClaimsToStringConverter(objectMapper)); - modelMapper.addConverter(new StringToClaimsConverter(objectMapper)); - modelMapper.addConverter(new MapToStringConverter(objectMapper)); - modelMapper.addConverter(new StringToMapConverter(objectMapper)); - modelMapper.addConverter(new ListToStringConverter()); - modelMapper.addConverter(new StringToListConverter()); - modelMapper.addMappings(new CustomConsentRequestMapping()); - modelMapper.addMappings(new CustomConsentHistoryMapping()); + public Claims convertStringToClaims(String claims) { + try { + return StringUtils.isNotBlank(claims) ? objectMapper.readValue(claims, Claims.class) : null; + } catch (JsonProcessingException e) { + throw new EsignetException(INVALID_CLAIM); + } } - public static io.mosip.esignet.entity.ConsentDetail toEntity(ConsentDetail consentDetailDTo) { - return modelMapper.map(consentDetailDTo, io.mosip.esignet.entity.ConsentDetail.class); + public String convertListToString(List list) { + return list == null ? "" : String.join(",", list); } - public static io.mosip.esignet.entity.ConsentDetail toEntity(UserConsent userConsent) { - return modelMapper.map(userConsent, io.mosip.esignet.entity.ConsentDetail.class); + public List convertStringToList(String value) { + return StringUtils.isEmpty(value) ? List.of(): Arrays.asList(value.split(",")); } - public static ConsentDetail toDto(io.mosip.esignet.entity.ConsentDetail consentDetail) { - return modelMapper.map(consentDetail, ConsentDetail.class); + public String convertMapToString(Map map) { + try{ + return map!=null?objectMapper.writeValueAsString(map):""; + }catch (JsonProcessingException e) { + throw new EsignetException(INVALID_PERMITTED_SCOPE); + } } - public static ConsentHistory toConsentHistoryEntity(UserConsent userConsent){ - return modelMapper.map(userConsent, ConsentHistory.class); + public Map convertStringToMap(String value) { + try{ + return StringUtils.isNotBlank(value) ? objectMapper.readValue(value,Map.class): Collections.emptyMap(); + } catch (JsonProcessingException e) { + throw new EsignetException(INVALID_PERMITTED_SCOPE); + } } } diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/CustomConsentHistoryMapping.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/CustomConsentHistoryMapping.java deleted file mode 100644 index 6e1b5d1ad..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/CustomConsentHistoryMapping.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.mapper; - -import io.mosip.esignet.core.dto.UserConsent; -import io.mosip.esignet.entity.ConsentHistory; -import org.modelmapper.PropertyMap; - -public class CustomConsentHistoryMapping extends PropertyMap { - @Override - protected void configure() { - // Skip the 'id' field when mapping - skip().setId(null); - } -} - - diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/CustomConsentRequestMapping.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/CustomConsentRequestMapping.java deleted file mode 100644 index 3de2f4f34..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/CustomConsentRequestMapping.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.mapper; - -import io.mosip.esignet.core.dto.UserConsent; -import io.mosip.esignet.entity.ConsentDetail; -import org.modelmapper.PropertyMap; - -public class CustomConsentRequestMapping extends PropertyMap { - @Override - protected void configure() { - // Skip the 'id' field when mapping - skip().setId(null); - } -} - - diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/ClaimsToStringConverter.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/ClaimsToStringConverter.java deleted file mode 100644 index 961768890..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/ClaimsToStringConverter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.mapper.converter; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.mosip.esignet.api.dto.Claims; -import io.mosip.esignet.core.exception.EsignetException; -import lombok.extern.slf4j.Slf4j; -import org.modelmapper.Converter; -import org.modelmapper.spi.MappingContext; - -import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_CLAIM; - -@Slf4j -public class ClaimsToStringConverter implements Converter { - private final ObjectMapper objectMapper; - - public ClaimsToStringConverter(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - - @Override - public String convert(MappingContext context) { - Claims claims = context.getSource(); - try { - return claims != null ? objectMapper.writeValueAsString(claims) : ""; - } catch (JsonProcessingException e) { - throw new EsignetException(INVALID_CLAIM); - } - } -} \ No newline at end of file diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/ListToStringConverter.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/ListToStringConverter.java deleted file mode 100644 index ec9664ed5..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/ListToStringConverter.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.mapper.converter; - -import org.modelmapper.Converter; -import org.modelmapper.spi.MappingContext; - -import java.util.List; - -public class ListToStringConverter implements Converter, String> { - @Override - public String convert(MappingContext, String> context) { - List source = context.getSource(); - return source == null ? "" : String.join(",", context.getSource()); - } -} \ No newline at end of file diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/MapToStringConverter.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/MapToStringConverter.java deleted file mode 100644 index 5e832d45d..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/MapToStringConverter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.mapper.converter; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.mosip.esignet.core.exception.EsignetException; -import org.modelmapper.Converter; -import org.modelmapper.spi.MappingContext; - -import java.util.Map; - -import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_PERMITTED_SCOPE; - -public class MapToStringConverter implements Converter,String> { - - private final ObjectMapper objectMapper; - - public MapToStringConverter(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - - @Override - public String convert(MappingContext, String> mappingContext) { - Map map = mappingContext.getSource(); - try{ - return map!=null?objectMapper.writeValueAsString(map):""; - }catch (JsonProcessingException e) { - throw new EsignetException(INVALID_PERMITTED_SCOPE); - } - } -} \ No newline at end of file diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToClaimsConverter.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToClaimsConverter.java deleted file mode 100644 index 921ac5d18..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToClaimsConverter.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.mapper.converter; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.mosip.esignet.api.dto.Claims; -import io.mosip.esignet.core.exception.EsignetException; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.modelmapper.Converter; -import org.modelmapper.spi.MappingContext; - -import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_CLAIM; - -@Slf4j -public class StringToClaimsConverter implements Converter -{ - private final ObjectMapper objectMapper; - - public StringToClaimsConverter(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - - @Override - public Claims convert(MappingContext context) { - String claims = context.getSource(); - try { - return StringUtils.isNotBlank(claims) ? objectMapper.readValue(claims, Claims.class) : null; - } catch (JsonProcessingException e) { - throw new EsignetException(INVALID_CLAIM); - } - } -} diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToListConverter.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToListConverter.java deleted file mode 100644 index 2edf94a8c..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToListConverter.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.mapper.converter; - -import org.apache.commons.lang3.StringUtils; -import org.modelmapper.Converter; -import org.modelmapper.spi.MappingContext; - -import java.util.Arrays; -import java.util.List; - -public class StringToListConverter implements Converter> { - @Override - public List convert(MappingContext> context) { - String source = context.getSource(); - return StringUtils.isEmpty(source) ? List.of(): Arrays.asList(context.getSource().split(",")); - } -} diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToMapConverter.java b/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToMapConverter.java deleted file mode 100644 index b7951e29f..000000000 --- a/consent-service-impl/src/main/java/io/mosip/esignet/mapper/converter/StringToMapConverter.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.mapper.converter; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.mosip.esignet.core.exception.EsignetException; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.modelmapper.Converter; -import org.modelmapper.spi.MappingContext; - -import java.util.Collections; -import java.util.Map; - -import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_PERMITTED_SCOPE; - -@Slf4j -public class StringToMapConverter implements Converter> { - - private final ObjectMapper objectMapper; - - public StringToMapConverter(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - - @Override - public Map convert(MappingContext> mappingContext) { - String authorizeScopes= mappingContext.getSource(); - try{ - return StringUtils.isNotBlank(authorizeScopes) ? objectMapper.readValue(authorizeScopes,Map.class): Collections.emptyMap(); - } catch (JsonProcessingException e) { - throw new EsignetException(INVALID_PERMITTED_SCOPE); - } - } -} diff --git a/consent-service-impl/src/main/java/io/mosip/esignet/services/ConsentServiceImpl.java b/consent-service-impl/src/main/java/io/mosip/esignet/services/ConsentServiceImpl.java index ec0c48a9d..37f4e3977 100644 --- a/consent-service-impl/src/main/java/io/mosip/esignet/services/ConsentServiceImpl.java +++ b/consent-service-impl/src/main/java/io/mosip/esignet/services/ConsentServiceImpl.java @@ -45,6 +45,9 @@ public class ConsentServiceImpl implements ConsentService { @Value("${mosip.esignet.audit.claim-name:preferred_username}") private String claimName; + @Autowired + private ConsentMapper consentMapper; + @Override public Optional getUserConsent(UserConsentRequest userConsentRequest) { @@ -52,7 +55,7 @@ public Optional getUserConsent(UserConsentRequest userConsentRequ findByClientIdAndPsuToken(userConsentRequest.getClientId(), userConsentRequest.getPsuToken()); if (consentOptional.isPresent()) { - ConsentDetail consentDetailDto = ConsentMapper.toDto( consentOptional.get()); + ConsentDetail consentDetailDto = consentMapper.toDto( consentOptional.get()); return Optional.of(consentDetailDto); } @@ -73,14 +76,14 @@ public ConsentDetail saveUserConsent(UserConsent userConsent) { } LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC); //convert ConsentRequest to Entity - ConsentHistory consentHistory = ConsentMapper.toConsentHistoryEntity(userConsent); + ConsentHistory consentHistory = consentMapper.toConsentHistoryEntity(userConsent); consentHistory.setCreatedtimes(now); consentHistoryRepository.save(consentHistory); - io.mosip.esignet.entity.ConsentDetail consentDetail =ConsentMapper.toEntity(userConsent); + io.mosip.esignet.entity.ConsentDetail consentDetail = consentMapper.toEntity(userConsent); consentDetail.setCreatedtimes(now); - ConsentDetail consentDetailDto =ConsentMapper.toDto(consentRepository.save(consentDetail)); + ConsentDetail consentDetailDto = consentMapper.toDto(consentRepository.save(consentDetail)); auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), Action.SAVE_USER_CONSENT, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(userConsent.getClientId()), null); diff --git a/consent-service-impl/src/test/java/io/mosip/esignet/ConsentServiceImplTest.java b/consent-service-impl/src/test/java/io/mosip/esignet/ConsentServiceImplTest.java index c030c5cd3..46999ccac 100644 --- a/consent-service-impl/src/test/java/io/mosip/esignet/ConsentServiceImplTest.java +++ b/consent-service-impl/src/test/java/io/mosip/esignet/ConsentServiceImplTest.java @@ -5,25 +5,29 @@ */ package io.mosip.esignet; +import com.fasterxml.jackson.databind.ObjectMapper; import io.mosip.esignet.api.dto.ClaimDetail; import io.mosip.esignet.api.dto.Claims; import io.mosip.esignet.api.spi.AuditPlugin; import io.mosip.esignet.core.dto.UserConsent; import io.mosip.esignet.core.dto.UserConsentRequest; +import io.mosip.esignet.core.exception.EsignetException; import io.mosip.esignet.entity.ConsentDetail; import io.mosip.esignet.entity.ConsentHistory; +import io.mosip.esignet.mapper.ConsentMapperImpl; import io.mosip.esignet.repository.ConsentHistoryRepository; import io.mosip.esignet.repository.ConsentRepository; import io.mosip.esignet.services.ConsentServiceImpl; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; -import org.modelmapper.MappingException; +import org.springframework.test.util.ReflectionTestUtils; import java.time.LocalDateTime; import java.util.HashMap; @@ -31,6 +35,7 @@ import java.util.Optional; import java.util.UUID; +import static io.mosip.esignet.core.constants.ErrorConstants.INVALID_CLAIM; import static org.mockito.Mockito.doNothing; @Slf4j @@ -50,7 +55,14 @@ public class ConsentServiceImplTest { @InjectMocks ConsentServiceImpl consentService; + @InjectMocks + ConsentMapperImpl consentMapper; + @Before + public void initialize() { + ReflectionTestUtils.setField(consentMapper, "objectMapper", new ObjectMapper()); + ReflectionTestUtils.setField(consentService, "consentMapper", consentMapper); + } @Test public void getUserConsent_withValidDetails_thenPass() throws Exception{ @@ -95,8 +107,8 @@ public void getUserConsent_withInValidClaimsDetails_thenFail() { try{ Optional userConsentDto = consentService.getUserConsent(userConsentRequest); Assert.fail(); - }catch (MappingException e){ - Assert.assertTrue(true); + }catch (EsignetException e){ + Assert.assertTrue(e.getErrorCode().equals(INVALID_CLAIM)); } } diff --git a/esignet-core/src/main/java/io/mosip/esignet/core/constants/Constants.java b/esignet-core/src/main/java/io/mosip/esignet/core/constants/Constants.java index 1e5e3923e..e8260c4fa 100644 --- a/esignet-core/src/main/java/io/mosip/esignet/core/constants/Constants.java +++ b/esignet-core/src/main/java/io/mosip/esignet/core/constants/Constants.java @@ -23,6 +23,8 @@ public class Constants { public static final String LINKED_SESSION_CACHE = "linked"; public static final String LINKED_CODE_CACHE = "linkedcode"; public static final String AUTH_CODE_GENERATED_CACHE = "authcodegenerated"; + public static final String RATE_LIMIT_CACHE = "apiRateLimit"; + public static final String BLOCKED_CACHE = "blocked"; public static final String ROOT_KEY = "ROOT"; public static final String OIDC_PARTNER_APP_ID = "OIDC_PARTNER"; diff --git a/esignet-core/src/main/java/io/mosip/esignet/core/constants/ErrorConstants.java b/esignet-core/src/main/java/io/mosip/esignet/core/constants/ErrorConstants.java index d60d1dc55..e6031df54 100644 --- a/esignet-core/src/main/java/io/mosip/esignet/core/constants/ErrorConstants.java +++ b/esignet-core/src/main/java/io/mosip/esignet/core/constants/ErrorConstants.java @@ -84,4 +84,7 @@ public class ErrorConstants { public static final String PROOF_HEADER_INVALID_ALG = "proof_header_invalid_alg"; public static final String PROOF_HEADER_INVALID_KEY = "proof_header_invalid_key"; public static final String PROOF_HEADER_AMBIGUOUS_KEY = "proof_header_ambiguous_key"; + public static final String NO_ATTEMPTS_LEFT = "no_attempts_left"; + public static final String INDIVIDUAL_ID_BLOCKED = "individual_id_blocked"; + public static final String TOO_EARLY_ATTEMPT = "too_early_attempt"; } diff --git a/esignet-core/src/main/java/io/mosip/esignet/core/dto/ApiRateLimit.java b/esignet-core/src/main/java/io/mosip/esignet/core/dto/ApiRateLimit.java new file mode 100644 index 000000000..24d968bd3 --- /dev/null +++ b/esignet-core/src/main/java/io/mosip/esignet/core/dto/ApiRateLimit.java @@ -0,0 +1,27 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +package io.mosip.esignet.core.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.concurrent.ConcurrentHashMap; + +@Data +public class ApiRateLimit implements Serializable { + + ConcurrentHashMap count = new ConcurrentHashMap<>(); + ConcurrentHashMap lastInvocation = new ConcurrentHashMap<>(); + + public void increment(int apiCode) { + count.compute(apiCode, (k, v) -> (v == null) ? 1 : v + 1); + lastInvocation.compute(apiCode, (k, v) -> (v == null) ? 0 : v); + } + + public void updateLastInvocation(int apiCode) { + lastInvocation.compute(apiCode, (k, v) -> System.currentTimeMillis()/1000 ); + } +} diff --git a/esignet-core/src/main/java/io/mosip/esignet/core/dto/OIDCTransaction.java b/esignet-core/src/main/java/io/mosip/esignet/core/dto/OIDCTransaction.java index 8dbf205ac..70e0e755c 100644 --- a/esignet-core/src/main/java/io/mosip/esignet/core/dto/OIDCTransaction.java +++ b/esignet-core/src/main/java/io/mosip/esignet/core/dto/OIDCTransaction.java @@ -50,6 +50,7 @@ public class OIDCTransaction implements Serializable { String state; String individualId; + String individualIdHash; String oauthDetailsHash; ConsentAction consentAction; diff --git a/esignet-service/src/main/java/io/mosip/esignet/advice/HeaderValidationFilter.java b/esignet-service/src/main/java/io/mosip/esignet/advice/HeaderValidationFilter.java index 444882965..974e29bfa 100644 --- a/esignet-service/src/main/java/io/mosip/esignet/advice/HeaderValidationFilter.java +++ b/esignet-service/src/main/java/io/mosip/esignet/advice/HeaderValidationFilter.java @@ -2,12 +2,15 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.mosip.esignet.core.constants.ErrorConstants; import io.mosip.esignet.core.dto.Error; import io.mosip.esignet.core.dto.OIDCTransaction; +import io.mosip.esignet.core.dto.ApiRateLimit; import io.mosip.esignet.core.dto.ResponseWrapper; import io.mosip.esignet.core.exception.EsignetException; import io.mosip.esignet.core.exception.InvalidTransactionException; import io.mosip.esignet.core.util.IdentityProviderUtil; +import io.mosip.esignet.services.AuthorizationHelperService; import io.mosip.esignet.services.CacheUtilService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -39,6 +42,18 @@ public class HeaderValidationFilter extends OncePerRequestFilter { @Value("#{${mosip.esignet.header-filter.paths-to-validate}}") private List pathsToValidate; + @Value("${mosip.esignet.send-otp.attempts:3}") + private int sendOtpAttempts; + + @Value("${mosip.esignet.authenticate.attempts:3}") + private int authenticateAttempts; + + @Value("${mosip.esignet.send-otp.invocation-gap-secs:1}") + private int sendOtpInvocationGapInSeconds; + + @Value("${mosip.esignet.authenticate.invocation-gap-secs:1}") + private int authenticateInvocationGapInSeconds; + @Autowired private CacheUtilService cacheUtilService; @@ -48,6 +63,7 @@ public class HeaderValidationFilter extends OncePerRequestFilter { @Autowired private MessageSource messageSource; + @Override protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException { final String path = request.getRequestURI(); @@ -59,7 +75,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse final String path = request.getRequestURI(); try { - log.info("Started to validate {} for oauth-details headers", path); + log.debug("Started to validate {} for oauth-details headers", path); final String transactionId = request.getHeader(HEADER_OAUTH_DETAILS_KEY); final String hashValue = request.getHeader(HEADER_OAUTH_DETAILS_HASH); OIDCTransaction transaction = path.endsWith("auth-code") ? cacheUtilService.getAuthenticatedTransaction(transactionId) : @@ -67,7 +83,9 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse if(transaction == null) { throw new InvalidTransactionException(); } + if(transaction.getOauthDetailsHash().equals(hashValue)) { + validateApiRateLimits(path, transactionId, transaction.getIndividualIdHash()); filterChain.doFilter(request, response); return; } @@ -101,4 +119,58 @@ private String getMessage(String errorCode) { } return errorCode; } + + private void validateApiRateLimits(String path, String transactionId, String individualIdHash) { + int apiCode = path.endsWith("send-otp") ? 1 : path.endsWith("authenticate")? 2 : 3; + + ApiRateLimit apiRateLimit = null; + try { + switch (apiCode) { + case 1: + apiRateLimit = cacheUtilService.getApiRateLimitTransaction(transactionId); + apiRateLimit = checkRateLimit(1, apiRateLimit, sendOtpAttempts, sendOtpInvocationGapInSeconds, individualIdHash); + break; + case 2: + apiRateLimit = cacheUtilService.getApiRateLimitTransaction(transactionId); + apiRateLimit = checkRateLimit(2, apiRateLimit, authenticateAttempts, authenticateInvocationGapInSeconds, individualIdHash); + break; + } + } finally { + if(apiRateLimit != null) { + cacheUtilService.saveApiRateLimit(transactionId, apiRateLimit); + } + } + } + + private ApiRateLimit checkRateLimit(int apiCode, ApiRateLimit apiRateLimit, int attemptsLimit, int invocationGapInSeconds, + String individualIdHash) { + if(apiRateLimit == null) { + apiRateLimit = new ApiRateLimit(); + } + apiRateLimit.increment(apiCode); + if(apiRateLimit.getCount().get(apiCode) > attemptsLimit) { + blockIndividualId(individualIdHash); + throw new EsignetException(ErrorConstants.NO_ATTEMPTS_LEFT); + } + + //Reason for invocation time gap check is to deny bot actions, but if we introduce incremental blockage + //of the individual on wrong attempts - by itself could be a way to mitigate bot actions. TBD + //TODO Need enhance this logic to handle invocation gaps w.r.t auth-factor used in authenticate request + //TODO Logic to check invocation gaps between send-otp and authenticate endpoints + /*try { + long currentTimeInSeconds = System.currentTimeMillis()/1000; + if((currentTimeInSeconds - apiRateLimit.getLastInvocation().get(apiCode)) < invocationGapInSeconds) { + throw new EsignetException(ErrorConstants.TOO_EARLY_ATTEMPT); + } + } finally { + apiRateLimit.updateLastInvocation(apiCode); + }*/ + return apiRateLimit; + } + + private void blockIndividualId(String individualIdHash) { + if(individualIdHash != null) { + cacheUtilService.blockIndividualId(individualIdHash); + } + } } diff --git a/esignet-service/src/main/resources/application-local.properties b/esignet-service/src/main/resources/application-local.properties index 1ea3111b6..2698b2ffd 100644 --- a/esignet-service/src/main/resources/application-local.properties +++ b/esignet-service/src/main/resources/application-local.properties @@ -47,8 +47,8 @@ mosip.esignet.header-filter.paths-to-validate={'${server.servlet.path}/authoriza '${server.servlet.path}/authorization/auth-code'} #This property is used for captcha validation and allowed values are send-otp and pwd. -#captcha validation is enabled for send-otp and pwd. -mosip.esignet.captcha.required=send-otp,pwd +#captcha validation is enabled for send-otp and pwd. Default value= send-otp,pwd +mosip.esignet.captcha.required= ## ------------------------------------------ e-Signet binding --------------------------------------------------------- @@ -161,7 +161,8 @@ mosip.esignet.cache.security.secretkey.reference-id=TRANSACTION_CACHE mosip.esignet.cache.security.algorithm-name=AES/ECB/PKCS5Padding mosip.esignet.cache.names=clientdetails,preauth,authenticated,authcodegenerated,userinfo,linkcodegenerated,linked,linkedcode,\ - linkedauth,consented,vcissuance + linkedauth,consented,vcissuance,apiRateLimit,blocked + #spring.cache.type=redis #spring.cache.cache-names=${mosip.esignet.cache.names} @@ -171,11 +172,12 @@ mosip.esignet.cache.names=clientdetails,preauth,authenticated,authcodegenerated, spring.cache.type=simple mosip.esignet.cache.key.hash.algorithm=SHA3-256 mosip.esignet.cache.size={'clientdetails' : 200, 'preauth': 200, 'authenticated': 200, 'authcodegenerated': 200, 'userinfo': 200, \ - 'linkcodegenerated' : 500, 'linked': 200 , 'linkedcode': 200, 'linkedauth' : 200 , 'consented' :200, 'vcissuance':100 } + 'linkcodegenerated' : 500, 'linked': 200 , 'linkedcode': 200, 'linkedauth' : 200 , 'consented' :200, 'vcissuance':100, \ + 'apiRateLimit' : 500, 'blocked': 500 } mosip.esignet.cache.expire-in-seconds={'clientdetails' : 86400, 'preauth': 180, 'authenticated': ${mosip.esignet.authentication-expire-in-secs}, \ 'authcodegenerated': 60, 'userinfo': ${mosip.esignet.access-token-expire-seconds}, 'linkcodegenerated' : ${mosip.esignet.link-code-expire-in-secs}, \ 'linked': 60 , 'linkedcode': ${mosip.esignet.link-code-expire-in-secs}, 'linkedauth' : ${mosip.esignet.authentication-expire-in-secs}, \ - 'consented': 120, 'vcissuance': ${mosip.esignet.access-token-expire-seconds} } + 'consented': 120, 'vcissuance': ${mosip.esignet.access-token-expire-seconds}, 'apiRateLimit' : 180, 'blocked': 300 } ## ------------------------------------------ Discovery openid-configuration ------------------------------------------- mosipbox.public.url=http://localhost:8088 @@ -289,22 +291,28 @@ mosip.esignet.ui.signup.config={'signup.banner': true, 'signup.url': 'http://loc mosip.esignet.ui.forgot-password.config={'forgot-password': true, 'forgot-password.url': 'http://localhost:3000/forgot-password'} -mosip.esignet.authenticator.default.auth-factor.kba.field-details={{'id':'policyNumber', 'type':'text', 'format':'', 'maxLength': 50, 'regex': '^\\s*[+-]?(\\d+|\\d*\\.\\d+|\\d+\\.\\d*)([Ee][+-]?\\d*)?\\s*$'},{'id':'fullName', 'type':'text', 'format':'', 'maxLength': 50, 'regex': '^[A-Za-z\\s]{1,}[\\.]{0,1}[A-Za-z\\s]{0,}$'},{'id':'dob', 'type':'date', 'format':'dd/mm/yyyy'}} -mosip.esignet.authenticator.default.auth-factor.kba.individual-id-field=policyNumber +mosip.esignet.authenticator.default.auth-factor.kba.field-details={} +mosip.esignet.authenticator.default.auth-factor.kba.individual-id-field= +## Configuration Map input to UI at the start of every transaction. mosip.esignet.ui.config.key-values={'sbi.env': 'Developer', 'sbi.timeout.DISC': 30, \ - 'sbi.timeout.DINFO': 30, 'sbi.timeout.CAPTURE': 30, 'sbi.capture.count.face': 1, 'sbi.capture.count.finger': 2, \ + 'sbi.timeout.DINFO': 30, 'sbi.timeout.CAPTURE': 30, 'sbi.capture.count.face': 1, 'sbi.capture.count.finger': 1, \ 'sbi.capture.count.iris': 1, 'sbi.capture.score.face': 70, 'sbi.capture.score.finger':70, 'sbi.capture.score.iris':70, \ - 'send.otp.channels':'email,phone', 'consent.screen.timeout-in-secs':${mosip.esignet.authentication-expire-in-secs}, \ - 'consent.screen.timeout-buffer-in-secs': 5, 'sbi.port.range': '4501-4600', 'sbi.bio.subtypes.iris': 'UNKNOWN', 'sbi.bio.subtypes.finger': 'UNKNOWN', \ - 'resend.otp.delay.secs': 120, 'captcha.enable': ${mosip.esignet.captcha.required}, 'captcha.sitekey': '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', \ - 'linked-transaction-expire-in-secs': 120, 'wallet.qr-code-buffer-in-secs': 10, 'auth.txnid.length': 10, \ - 'otp.length': 6, 'password.regex': '^.{8,20}$', \ 'password.max-length': 20, \ 'username.regex': '^[1-9][0-9]{7,8}$',\ 'username.prefix': '+855', \ - 'username.postfix': '', \ 'username.max-length': 9, \ 'username.input-type': 'number', \ 'wallet.config': ${mosip.esignet.ui.wallet.config},\ - 'signup.config': ${mosip.esignet.ui.signup.config}, \ + 'resend.otp.delay.secs': ${mosip.kernel.otp.expiry-time}, 'send.otp.channels' : '${mosip.esignet.authenticator.ida.otp-channels}', \ + 'captcha.sitekey' : '${mosip.esignet.captcha-validator.site-key}', 'captcha.enable' : '${mosip.esignet.captcha.required}', \ + 'auth.txnid.length' : '${mosip.esignet.auth-txn-id-length}', 'consent.screen.timeout-in-secs':${mosip.esignet.authentication-expire-in-secs}, \ + 'consent.screen.timeout-buffer-in-secs': 5, 'linked-transaction-expire-in-secs': 240, 'sbi.port.range': '4501-4600', \ + 'sbi.bio.subtypes.iris': 'UNKNOWN', 'sbi.bio.subtypes.finger': 'UNKNOWN', 'wallet.qr-code-buffer-in-secs': 10, 'otp.length': 6, \'password.regex': '^.{8,20}$', \ + 'password.max-length': 20, \ + 'username.regex': '^[1-9][0-9]{7,8}$',\ + 'username.prefix': '+855', \ + 'username.postfix': '@phone', \ + 'username.max-length': 9, \ + 'username.input-type': 'number', 'wallet.config': ${mosip.esignet.ui.wallet.config}, \'signup.config': ${mosip.esignet.ui.signup.config}, \ 'forgot-password.config': ${mosip.esignet.ui.forgot-password.config}, \ - 'auth.factor.kba.individual-id-field' : ${mosip.esignet.authenticator.default.auth-factor.kba.individual-id-field},\ - 'auth.factor.kba.field-details':${mosip.esignet.authenticator.default.auth-factor.kba.field-details}} + 'error.banner.close-timer': 10,\ + 'auth.factor.kba.individual-id-field' : '${mosip.esignet.authenticator.default.auth-factor.kba.individual-id-field}',\ + 'auth.factor.kba.field-details': ${mosip.esignet.authenticator.default.auth-factor.kba.field-details} } ## ---------------------------------------------- VCI ------------------------------------------------------------------ diff --git a/esignet-service/src/test/java/io/mosip/esignet/advice/HeaderValidationFilterTest.java b/esignet-service/src/test/java/io/mosip/esignet/advice/HeaderValidationFilterTest.java new file mode 100644 index 000000000..118c6c94a --- /dev/null +++ b/esignet-service/src/test/java/io/mosip/esignet/advice/HeaderValidationFilterTest.java @@ -0,0 +1,209 @@ +package io.mosip.esignet.advice; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.mosip.esignet.core.constants.ErrorConstants; +import io.mosip.esignet.core.dto.ApiRateLimit; +import io.mosip.esignet.core.dto.Error; +import io.mosip.esignet.core.dto.OIDCTransaction; +import io.mosip.esignet.core.dto.ResponseWrapper; +import io.mosip.esignet.services.CacheUtilService; +import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.context.MessageSource; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.test.util.ReflectionTestUtils; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; + +import java.io.IOException; +import java.util.Arrays; + +import static org.mockito.Mockito.*; + +@Slf4j +@RunWith(MockitoJUnitRunner.class) +public class HeaderValidationFilterTest { + + @Mock + FilterChain filterChain; + + @InjectMocks + private HeaderValidationFilter headerValidationFilter; + + @Mock + CacheUtilService cacheUtilService; + + @Mock + MessageSource messageSource; + + private ObjectMapper objectMapper = new ObjectMapper(); + + @Before + public void setUp() { + ReflectionTestUtils.setField(headerValidationFilter, "pathsToValidate", + Arrays.asList("/v1/esignet/authorization/send-otp", + "/v1/esignet/authorization/authenticate")); + ReflectionTestUtils.setField(headerValidationFilter, "objectMapper", objectMapper); + ReflectionTestUtils.setField(headerValidationFilter, "authenticateAttempts", 3); + ReflectionTestUtils.setField(headerValidationFilter, "sendOtpAttempts", 3); + ReflectionTestUtils.setField(headerValidationFilter, "sendOtpInvocationGapInSeconds", 3); + ReflectionTestUtils.setField(headerValidationFilter, "authenticateInvocationGapInSeconds", 3); + } + + @Test + public void doFilter_withNoHeader_thenFail() throws ServletException, IOException { + MockHttpServletRequest request = new MockHttpServletRequest(); + MockHttpServletResponse response = new MockHttpServletResponse(); + when(cacheUtilService.getPreAuthTransaction(null)).thenReturn(null); + headerValidationFilter.doFilterInternal(request, response, filterChain); + ResponseWrapper responseWrapper = objectMapper.readValue(response.getContentAsString(), ResponseWrapper.class); + Assert.assertNotNull(responseWrapper.getErrors()); + Assert.assertEquals(ErrorConstants.INVALID_TRANSACTION, ((Error)responseWrapper.getErrors().get(0)).getErrorCode()); + } + + @Test + public void doFilter_withInvalidTransactionId_thenFail() throws ServletException, IOException { + MockHttpServletRequest request = new MockHttpServletRequest(); + MockHttpServletResponse response = new MockHttpServletResponse(); + when(cacheUtilService.getPreAuthTransaction("oauth-details-key")).thenReturn(null); + request.addHeader("oauth-details-hash", "oauth-details-hash"); + request.addHeader("oauth-details-key", "oauth-details-key"); + headerValidationFilter.doFilterInternal(request, response, filterChain); + ResponseWrapper responseWrapper = objectMapper.readValue(response.getContentAsString(), ResponseWrapper.class); + Assert.assertNotNull(responseWrapper.getErrors()); + Assert.assertEquals(ErrorConstants.INVALID_TRANSACTION, ((Error)responseWrapper.getErrors().get(0)).getErrorCode()); + } + + @Test + public void doFilter_withInvalidHeader_thenFail() throws ServletException, IOException { + MockHttpServletRequest request = new MockHttpServletRequest(); + MockHttpServletResponse response = new MockHttpServletResponse(); + OIDCTransaction oidcTransaction = new OIDCTransaction(); + oidcTransaction.setOauthDetailsHash("oauth-details-hash"); + when(cacheUtilService.getPreAuthTransaction("oauth-details-key")).thenReturn(oidcTransaction); + request.addHeader("oauth-details-hash", "oauth-details-hash11"); + request.addHeader("oauth-details-key", "oauth-details-key"); + + headerValidationFilter.doFilterInternal(request, response, filterChain); + ResponseWrapper responseWrapper = objectMapper.readValue(response.getContentAsString(), ResponseWrapper.class); + Assert.assertNotNull(responseWrapper.getErrors()); + Assert.assertEquals(ErrorConstants.INVALID_REQUEST, ((Error)responseWrapper.getErrors().get(0)).getErrorCode()); + } + + @Test + public void doFilter_withValidHeader_thenPass() throws ServletException, IOException { + MockHttpServletRequest request = new MockHttpServletRequest(); + MockHttpServletResponse response = new MockHttpServletResponse(); + OIDCTransaction oidcTransaction = new OIDCTransaction(); + oidcTransaction.setOauthDetailsHash("oauth-details-hash"); + when(cacheUtilService.getPreAuthTransaction("oauth-details-key")).thenReturn(oidcTransaction); + request.addHeader("oauth-details-hash", "oauth-details-hash"); + request.addHeader("oauth-details-key", "oauth-details-key"); + + headerValidationFilter.doFilterInternal(request, response, filterChain); + verify(cacheUtilService, times(1)).getPreAuthTransaction("oauth-details-key"); + } + + @Test + public void doFilter_forGetAuthCode_thenPass() throws ServletException, IOException { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setRequestURI("/v1/esignet/authorization/auth-code"); + MockHttpServletResponse response = new MockHttpServletResponse(); + + OIDCTransaction oidcTransaction = new OIDCTransaction(); + oidcTransaction.setOauthDetailsHash("oauth-details-hash"); + when(cacheUtilService.getAuthenticatedTransaction("oauth-details-key")).thenReturn(oidcTransaction); + request.addHeader("oauth-details-hash", "oauth-details-hash"); + request.addHeader("oauth-details-key", "oauth-details-key"); + + headerValidationFilter.doFilterInternal(request, response, filterChain); + verify(cacheUtilService, times(0)).getPreAuthTransaction("oauth-details-key"); + verify(cacheUtilService, times(1)).getAuthenticatedTransaction("oauth-details-key"); + } + + @Test + public void doFilter_withinApiRateLimit_thenPass() throws ServletException, IOException { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setRequestURI("/v1/esignet/authorization/send-otp"); + MockHttpServletResponse response = new MockHttpServletResponse(); + request.addHeader("oauth-details-hash", "oauth-details-hash"); + request.addHeader("oauth-details-key", "oauth-details-key"); + + OIDCTransaction oidcTransaction = new OIDCTransaction(); + oidcTransaction.setOauthDetailsHash("oauth-details-hash"); + when(cacheUtilService.getPreAuthTransaction("oauth-details-key")).thenReturn(oidcTransaction); + + headerValidationFilter.doFilterInternal(request, response, filterChain); + verify(cacheUtilService, times(1)).getPreAuthTransaction("oauth-details-key"); + verify(cacheUtilService, times(0)).getAuthenticatedTransaction("oauth-details-key"); + verify(cacheUtilService, times(1)).getApiRateLimitTransaction("oauth-details-key"); + } + + @Test + public void doFilter_exceedApiRateLimit_thenFail() throws ServletException, IOException { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setRequestURI("/v1/esignet/authorization/send-otp"); + MockHttpServletResponse response = new MockHttpServletResponse(); + request.addHeader("oauth-details-hash", "oauth-details-hash"); + request.addHeader("oauth-details-key", "oauth-details-key"); + + OIDCTransaction oidcTransaction = new OIDCTransaction(); + oidcTransaction.setOauthDetailsHash("oauth-details-hash"); + oidcTransaction.setIndividualIdHash("test"); + when(cacheUtilService.getPreAuthTransaction("oauth-details-key")).thenReturn(oidcTransaction); + ApiRateLimit apiRateLimit = new ApiRateLimit(); + apiRateLimit.increment(1); + apiRateLimit.increment(1); + apiRateLimit.increment(1); + when(cacheUtilService.getApiRateLimitTransaction("oauth-details-key")).thenReturn(apiRateLimit); + + headerValidationFilter.doFilterInternal(request, response, filterChain); + verify(cacheUtilService, times(1)).getPreAuthTransaction("oauth-details-key"); + verify(cacheUtilService, times(0)).getAuthenticatedTransaction("oauth-details-key"); + verify(cacheUtilService, times(1)).getApiRateLimitTransaction("oauth-details-key"); + verify(cacheUtilService, times(1)).blockIndividualId("test"); + verify(cacheUtilService, times(1)).saveApiRateLimit("oauth-details-key", apiRateLimit); + + ResponseWrapper responseWrapper = objectMapper.readValue(response.getContentAsString(), ResponseWrapper.class); + Assert.assertNotNull(responseWrapper.getErrors()); + Assert.assertEquals(ErrorConstants.NO_ATTEMPTS_LEFT, ((Error)responseWrapper.getErrors().get(0)).getErrorCode()); + } + + @Ignore + @Test + public void doFilter_exceedInvocationGapLimit_thenFail() throws ServletException, IOException { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setRequestURI("/v1/esignet/authorization/authenticate"); + MockHttpServletResponse response = new MockHttpServletResponse(); + request.addHeader("oauth-details-hash", "oauth-details-hash"); + request.addHeader("oauth-details-key", "oauth-details-key"); + + OIDCTransaction oidcTransaction = new OIDCTransaction(); + oidcTransaction.setOauthDetailsHash("oauth-details-hash"); + oidcTransaction.setIndividualIdHash("test"); + when(cacheUtilService.getPreAuthTransaction("oauth-details-key")).thenReturn(oidcTransaction); + ApiRateLimit apiRateLimit = new ApiRateLimit(); + apiRateLimit.increment(2); + apiRateLimit.updateLastInvocation(2); + when(cacheUtilService.getApiRateLimitTransaction("oauth-details-key")).thenReturn(apiRateLimit); + + headerValidationFilter.doFilterInternal(request, response, filterChain); + verify(cacheUtilService, times(1)).getPreAuthTransaction("oauth-details-key"); + verify(cacheUtilService, times(0)).getAuthenticatedTransaction("oauth-details-key"); + verify(cacheUtilService, times(1)).getApiRateLimitTransaction("oauth-details-key"); + verify(cacheUtilService, times(1)).saveApiRateLimit("oauth-details-key", apiRateLimit); + + ResponseWrapper responseWrapper = objectMapper.readValue(response.getContentAsString(), ResponseWrapper.class); + Assert.assertNotNull(responseWrapper.getErrors()); + Assert.assertEquals(ErrorConstants.TOO_EARLY_ATTEMPT, ((Error)responseWrapper.getErrors().get(0)).getErrorCode()); + } +} diff --git a/esignet-service/src/test/resources/application-test.properties b/esignet-service/src/test/resources/application-test.properties index bc0829d1f..f3dab74cd 100644 --- a/esignet-service/src/test/resources/application-test.properties +++ b/esignet-service/src/test/resources/application-test.properties @@ -127,7 +127,7 @@ mosip.esignet.cache.store.individual-id=true mosip.esignet.cache.security.secretkey.reference-id=TRANSACTION_CACHE mosip.esignet.cache.security.algorithm-name=AES/ECB/PKCS5Padding -mosip.esignet.cache.names=clientdetails,preauth,authenticated,authcodegenerated,userinfo,linkcodegenerated,linked,linkedcode,linkedauth,consented +mosip.esignet.cache.names=clientdetails,preauth,authenticated,authcodegenerated,userinfo,linkcodegenerated,linked,linkedcode,linkedauth,consented,apiRateLimit,blocked #spring.cache.type=redis #spring.cache.cache-names=${mosip.esignet.cache.names} @@ -137,10 +137,10 @@ mosip.esignet.cache.names=clientdetails,preauth,authenticated,authcodegenerated, spring.cache.type=simple mosip.esignet.cache.key.hash.algorithm=SHA3-256 mosip.esignet.cache.size={'clientdetails' : 200, 'preauth': 200, 'authenticated': 200, 'authcodegenerated': 200, 'userinfo': 200, \ - 'linkcodegenerated' : 500, 'linked': 200 , 'linkedcode': 200, 'linkedauth' : 200 , 'consented' :200 } + 'linkcodegenerated' : 500, 'linked': 200 , 'linkedcode': 200, 'linkedauth' : 200 , 'consented' :200, 'apiRateLimit' : 500, 'blocked': 500 } mosip.esignet.cache.expire-in-seconds={'clientdetails' : 86400, 'preauth': 180, 'authenticated': 120, 'authcodegenerated': 60, \ 'userinfo': ${mosip.esignet.access-token.expire.seconds}, 'linkcodegenerated' : ${mosip.esignet.link-code-expire-in-secs}, \ - 'linked': 60 , 'linkedcode': ${mosip.esignet.link-code-expire-in-secs}, 'linkedauth' : 60, 'consented': 120 } + 'linked': 60 , 'linkedcode': ${mosip.esignet.link-code-expire-in-secs}, 'linkedauth' : 60, 'consented': 120, 'apiRateLimit' : 180, 'blocked': 300 } ## ------------------------------------------ Discovery openid-configuration ------------------------------------------- mosipbox.public.url=http://localhost:8088 diff --git a/helm/esignet/install.sh b/helm/esignet/install.sh index b33ab19ff..9a31afe71 100755 --- a/helm/esignet/install.sh +++ b/helm/esignet/install.sh @@ -83,8 +83,37 @@ function installing_esignet() { ENABLE_INSECURE='--set enable_insecure=true'; fi + default_enable_volume=false + read -p "Would you like to enable volume (true/false) : [ default : false ] : " enable_volume + enable_volume=${enable_volume:-$default_enable_volume} + + ESIGNET_HELM_ARGS='' + if [[ $enable_volume == 'true' ]]; then + + default_volume_size=100M + read -p "Provide the size for volume [ default : 100M ]" volume_size + volume_size=${volume_size:-$default_volume_size} + + default_volume_mount_path='/home/mosip/config/' + read -p "Provide the mount path for volume [ default : '/home/mosip/config/' ] : " volume_mount_path + volume_mount_path=${volume_mount_path:-$default_volume_mount_path} + + PVC_CLAIM_NAME='esignet' + ESIGNET_HELM_ARGS="--set persistence.enabled=true \ + --set volumePermissions.enabled=true \ + --set persistence.mountDir=\"$volume_mount_path\" \ + --set persistence.size=$volume_size \ + --set springConfigNameEnv='esignet' \ + --set activeProfileEnv=default \ + --set persistence.pvc_claim_name=\"$PVC_CLAIM_NAME\" \ + --set extraEnvVarsCM={'global','config-server-share','artifactory-share'} \ + " + fi + echo "ESIGNET HELM ARGS $ESIGNET_HELM_ARGS" + + echo Installing esignet - helm -n $NS install esignet mosip/esignet --version $CHART_VERSION $ENABLE_INSECURE + helm -n $NS install esignet mosip/esignet $ESIGNET_HELM_ARGS --version $CHART_VERSION $ENABLE_INSECURE kubectl -n $NS get deploy -o name | xargs -n1 -t kubectl -n $NS rollout status diff --git a/helm/esignet/templates/deployment.yaml b/helm/esignet/templates/deployment.yaml index ca588c994..8e3306fe8 100644 --- a/helm/esignet/templates/deployment.yaml +++ b/helm/esignet/templates/deployment.yaml @@ -57,18 +57,20 @@ spec: initContainers: {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }} - name: volume-permissions - image: {{ include "esignet.volumePermissions.image" . }} + image: {{ template "esignet.image" . }} imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }} command: - - %%commands%% + - /bin/bash + - -c + - chown -R 1001:1001 {{ .Values.persistence.mountDir }} securityContext: runAsUser: 0 {{- if .Values.volumePermissions.resources }} resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }} {{- end }} volumeMounts: - - name: foo - mountPath: bar + - name: {{ .Values.persistence.volume_name }} + mountPath: {{ .Values.persistence.mountDir }} {{- end }} {{- if .Values.enable_insecure }} {{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }} @@ -92,8 +94,18 @@ spec: env: - name: container_user value: {{ .Values.containerSecurityContext.runAsUser }} + {{- if .Values.additionalResources.javaOpts }} - name: JDK_JAVA_OPTIONS value: {{ .Values.additionalResources.javaOpts }} + {{- end }} + {{- if .Values.springConfigNameEnv }} + - name: spring_config_name_env + value: {{ .Values.springConfigNameEnv }} + {{- end }} + {{- if .Values.activeProfileEnv }} + - name: active_profile_env + value: {{ .Values.activeProfileEnv }} + {{- end}} {{- if .Values.extraEnvVars }} {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }} {{- end }} @@ -136,6 +148,10 @@ spec: name: cacerts subPath: cacerts {{- end }} + {{- if .Values.persistence.enabled }} + - name: {{ .Values.persistence.volume_name }} + mountPath: {{ .Values.persistence.mountDir }} + {{- end }} {{- if .Values.sidecars }} {{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }} {{- end }} @@ -144,3 +160,8 @@ spec: - name: cacerts emptyDir: {} {{- end }} + {{- if .Values.persistence.enabled }} + - name: {{ .Values.persistence.volume_name }} + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim | default .Values.persistence.pvc_claim_name }} + {{ end }} diff --git a/helm/esignet/templates/pvc.yaml b/helm/esignet/templates/pvc.yaml new file mode 100644 index 000000000..1a7a90992 --- /dev/null +++ b/helm/esignet/templates/pvc.yaml @@ -0,0 +1,32 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ .Values.persistence.pvc_claim_name }} + namespace: {{ .Release.Namespace | quote }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + annotations: + {{- if .Values.commonAnnotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} + "helm.sh/resource-policy": keep +spec: + accessModes: + {{- if not (empty .Values.persistence.accessModes) }} + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + {{- else }} + - {{ .Values.persistence.accessModes | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} + {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 2 }} + {{- if .Values.persistence.dataSource }} + dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.dataSource "context" $) | nindent 4 }} + {{- end }} +{{- end }} diff --git a/helm/esignet/values.yaml b/helm/esignet/values.yaml index 29213d153..3ec75affd 100644 --- a/helm/esignet/values.yaml +++ b/helm/esignet/values.yaml @@ -53,7 +53,7 @@ service: image: registry: docker.io repository: mosipqa/esignet - tag: 1.0.0 + tag: develop ## Specify a imagePullPolicy ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images @@ -333,11 +333,14 @@ persistence: ## ReadWriteMany not supported by AWS gp2 storageClass: accessModes: - - ReadWriteOnce + - ReadWriteMany size: 10M + # existingClaim: pkcs12-keys.p12 existingClaim: # Dir where config and keys are written inside container - mountDir: + mountDir: /home/mosip/config/ + volume_name: config + # pvc_claim_name: pkcs12-keys.p12 ## Init containers parameters: ## volumePermissions: Change the owner and group of the persistent volume mountpoint to runAsUser:fsGroup values from the securityContext section. @@ -454,3 +457,5 @@ istio: prefix: /v1/esignet/ enable_insecure: false +springConfigNameEnv: +activeProfileEnv: \ No newline at end of file diff --git a/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java b/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java index 3d4d38a86..10fe7dab8 100644 --- a/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java +++ b/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java @@ -145,6 +145,12 @@ public OtpResponse sendOtp(OtpRequest otpRequest) throws EsignetException { if(transaction == null) throw new InvalidTransactionException(); + transaction = cacheUtilService.updateIndividualIdHashInPreAuthCache(otpRequest.getTransactionId(), + otpRequest.getIndividualId()); + + if(cacheUtilService.isIndividualIdBlocked(transaction.getIndividualIdHash())) + throw new EsignetException(ErrorConstants.INDIVIDUAL_ID_BLOCKED); + SendOtpResult sendOtpResult = authorizationHelperService.delegateSendOtpRequest(otpRequest, transaction); OtpResponse otpResponse = new OtpResponse(); otpResponse.setTransactionId(otpRequest.getTransactionId()); @@ -226,6 +232,11 @@ private OIDCTransaction authenticate(AuthRequest authRequest, boolean checkConse if(transaction == null) throw new InvalidTransactionException(); + transaction = cacheUtilService.updateIndividualIdHashInPreAuthCache(authRequest.getTransactionId(), + authRequest.getIndividualId()); + if(cacheUtilService.isIndividualIdBlocked(transaction.getIndividualIdHash())) + throw new EsignetException(ErrorConstants.INDIVIDUAL_ID_BLOCKED); + //Validate provided challenge list auth-factors with resolved auth-factors for the transaction. Set> providedAuthFactors = authorizationHelperService.getProvidedAuthFactors(transaction, authRequest.getChallengeList()); diff --git a/oidc-service-impl/src/main/java/io/mosip/esignet/services/CacheUtilService.java b/oidc-service-impl/src/main/java/io/mosip/esignet/services/CacheUtilService.java index e612df4ad..ef7b3fce4 100644 --- a/oidc-service-impl/src/main/java/io/mosip/esignet/services/CacheUtilService.java +++ b/oidc-service-impl/src/main/java/io/mosip/esignet/services/CacheUtilService.java @@ -7,16 +7,21 @@ import io.mosip.esignet.core.dto.OIDCTransaction; import io.mosip.esignet.core.dto.LinkTransactionMetadata; +import io.mosip.esignet.core.dto.ApiRateLimit; import io.mosip.esignet.core.exception.DuplicateLinkCodeException; import io.mosip.esignet.core.constants.Constants; +import io.mosip.esignet.core.util.IdentityProviderUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Caching; import org.springframework.stereotype.Service; +import static io.mosip.esignet.core.util.IdentityProviderUtil.ALGO_SHA3_256; + @Slf4j @Service @@ -104,6 +109,23 @@ public OIDCTransaction updateTransactionAndEvictLinkCode(String transactionId, S return oidcTransaction; } + @CachePut(value = Constants.RATE_LIMIT_CACHE, key = "#transactionId") + public ApiRateLimit saveApiRateLimit(String transactionId, ApiRateLimit apiRateLimit) { + return apiRateLimit; + } + + @Cacheable(value = Constants.BLOCKED_CACHE, key = "#individualIdHash") + public String blockIndividualId(String individualIdHash) { + return individualIdHash; + } + + @CachePut(value = Constants.PRE_AUTH_SESSION_CACHE, key = "#transactionId") + public OIDCTransaction updateIndividualIdHashInPreAuthCache(String transactionId, String individualId) { + OIDCTransaction oidcTransaction = cacheManager.getCache(Constants.PRE_AUTH_SESSION_CACHE).get(transactionId, OIDCTransaction.class);//NOSONAR getCache() will not be returning null here. + oidcTransaction.setIndividualIdHash(IdentityProviderUtil.generateB64EncodedHash(ALGO_SHA3_256, individualId)); + return oidcTransaction; + } + //------------------------------------------------------------------------------------------------------------------ public OIDCTransaction getPreAuthTransaction(String transactionId) { @@ -141,4 +163,13 @@ public OIDCTransaction getLinkedSessionTransaction(String linkTransactionId) { public OIDCTransaction getLinkedAuthTransaction(String linkTransactionId) { return cacheManager.getCache(Constants.LINKED_AUTH_CACHE).get(linkTransactionId, OIDCTransaction.class); //NOSONAR getCache() will not be returning null here. } + + public ApiRateLimit getApiRateLimitTransaction(String transactionId) { + return cacheManager.getCache(Constants.RATE_LIMIT_CACHE).get(transactionId, ApiRateLimit.class); //NOSONAR getCache() will not be returning null here. + } + + public boolean isIndividualIdBlocked(String individualIdHash) { + String idHash = cacheManager.getCache(Constants.BLOCKED_CACHE).get(individualIdHash, String.class); //NOSONAR getCache() will not be returning null here. + return idHash != null; + } } diff --git a/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java b/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java index 8f2c7e931..26efdad6e 100644 --- a/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java +++ b/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java @@ -739,8 +739,11 @@ public void authenticate_withInvalidTransaction_thenFail() { @Test public void authenticate_multipleRegisteredAcrsWithSingleFactor_thenPass() throws EsignetException, KycAuthException { String transactionId = "test-transaction"; + String individualId = "23423434234"; when(cacheUtilService.getPreAuthTransaction(transactionId)).thenReturn(createIdpTransaction( new String[]{"mosip:idp:acr:generated-code", "mosip:idp:acr:static-code"})); + when(cacheUtilService.updateIndividualIdHashInPreAuthCache(transactionId, individualId)).thenReturn(createIdpTransaction( + new String[]{"mosip:idp:acr:generated-code", "mosip:idp:acr:static-code"})); List> allAuthFactors=new ArrayList<>(); allAuthFactors.add(getAuthFactors("mosip:idp:acr:generated-code")); @@ -755,7 +758,7 @@ public void authenticate_multipleRegisteredAcrsWithSingleFactor_thenPass() throw AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); - authRequest.setIndividualId("23423434234"); + authRequest.setIndividualId(individualId); List authChallenges = new ArrayList<>(); authChallenges.add(getAuthChallengeDto("OTP")); authRequest.setChallengeList(authChallenges); @@ -768,8 +771,11 @@ public void authenticate_multipleRegisteredAcrsWithSingleFactor_thenPass() throw @Test public void authenticate_multipleRegisteredAcrsWithInvalidSingleFactor_thenFail() throws EsignetException { String transactionId = "test-transaction"; + String individualId = "23423434234"; when(cacheUtilService.getPreAuthTransaction(transactionId)).thenReturn(createIdpTransaction( new String[]{"mosip:idp:acr:generated-code", "mosip:idp:acr:static-code"})); + when(cacheUtilService.updateIndividualIdHashInPreAuthCache(transactionId, individualId)).thenReturn(createIdpTransaction( + new String[]{"mosip:idp:acr:generated-code", "mosip:idp:acr:static-code"})); List> allAuthFactors=new ArrayList<>(); allAuthFactors.add(getAuthFactors("mosip:idp:acr:generated-code")); @@ -779,7 +785,7 @@ public void authenticate_multipleRegisteredAcrsWithInvalidSingleFactor_thenFail( AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); - authRequest.setIndividualId("23423434234"); + authRequest.setIndividualId(individualId); List authChallenges = new ArrayList<>(); authChallenges.add(getAuthChallengeDto("BIO")); authRequest.setChallengeList(authChallenges); @@ -795,8 +801,11 @@ public void authenticate_multipleRegisteredAcrsWithInvalidSingleFactor_thenFail( @Test public void authenticate_multipleRegisteredAcrsWithMultiFactor_thenPass() throws EsignetException, KycAuthException { String transactionId = "test-transaction"; + String individualId = "23423434234"; when(cacheUtilService.getPreAuthTransaction(transactionId)).thenReturn(createIdpTransaction( new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:static-code"})); + when(cacheUtilService.updateIndividualIdHashInPreAuthCache(transactionId, individualId)).thenReturn(createIdpTransaction( + new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:static-code"})); List> allAuthFactors=new ArrayList<>(); allAuthFactors.add(getAuthFactors("mosip:idp:acr:biometrics-generated-code")); @@ -811,7 +820,7 @@ public void authenticate_multipleRegisteredAcrsWithMultiFactor_thenPass() throws AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); - authRequest.setIndividualId("23423434234"); + authRequest.setIndividualId(individualId); List authChallenges = new ArrayList<>(); authChallenges.add(getAuthChallengeDto("OTP")); authChallenges.add(getAuthChallengeDto("BIO")); @@ -825,8 +834,11 @@ public void authenticate_multipleRegisteredAcrsWithMultiFactor_thenPass() throws @Test public void authenticate_multipleRegisteredAcrsWithInvalidMultiFactor_thenPass() throws EsignetException { String transactionId = "test-transaction"; + String individualId = "23423434234"; when(cacheUtilService.getPreAuthTransaction(transactionId)).thenReturn(createIdpTransaction( new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:linked-wallet"})); + when(cacheUtilService.updateIndividualIdHashInPreAuthCache(transactionId, individualId)).thenReturn(createIdpTransaction( + new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:linked-wallet"})); List> allAuthFactors=new ArrayList<>(); allAuthFactors.add(getAuthFactors("mosip:idp:acr:biometrics-generated-code")); @@ -836,7 +848,7 @@ public void authenticate_multipleRegisteredAcrsWithInvalidMultiFactor_thenPass() AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); - authRequest.setIndividualId("23423434234"); + authRequest.setIndividualId(individualId); List authChallenges = new ArrayList<>(); authChallenges.add(getAuthChallengeDto("OTP")); authChallenges.add(getAuthChallengeDto("PIN")); @@ -868,8 +880,11 @@ public void authenticateV2_withInvalidTransaction_thenFail() { @Test public void authenticateV2_multipleRegisteredAcrsWithSingleFactor_thenPass() throws EsignetException, KycAuthException { String transactionId = "test-transaction"; + String individualId = "23423434234"; when(cacheUtilService.getPreAuthTransaction(transactionId)).thenReturn(createIdpTransaction( new String[]{"mosip:idp:acr:generated-code", "mosip:idp:acr:static-code"})); + when(cacheUtilService.updateIndividualIdHashInPreAuthCache(transactionId, individualId)).thenReturn(createIdpTransaction( + new String[]{"mosip:idp:acr:generated-code", "mosip:idp:acr:static-code"})); List> allAuthFactors=new ArrayList<>(); allAuthFactors.add(getAuthFactors("mosip:idp:acr:generated-code")); @@ -884,7 +899,7 @@ public void authenticateV2_multipleRegisteredAcrsWithSingleFactor_thenPass() thr AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); - authRequest.setIndividualId("23423434234"); + authRequest.setIndividualId(individualId); List authChallenges = new ArrayList<>(); authChallenges.add(getAuthChallengeDto("OTP")); authRequest.setChallengeList(authChallenges); @@ -897,18 +912,21 @@ public void authenticateV2_multipleRegisteredAcrsWithSingleFactor_thenPass() thr @Test public void authenticateV2_multipleRegisteredAcrsWithInvalidSingleFactor_thenFail() throws EsignetException { String transactionId = "test-transaction"; + String individualId = "23423434234"; when(cacheUtilService.getPreAuthTransaction(transactionId)).thenReturn(createIdpTransaction( new String[]{"mosip:idp:acr:generated-code", "mosip:idp:acr:static-code"})); + when(cacheUtilService.updateIndividualIdHashInPreAuthCache(transactionId, individualId)).thenReturn(createIdpTransaction( + new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:static-code"})); List> allAuthFactors=new ArrayList<>(); allAuthFactors.add(getAuthFactors("mosip:idp:acr:generated-code")); allAuthFactors.add(getAuthFactors("mosip:idp:acr:static-code")); - when(authenticationContextClassRefUtil.getAuthFactors(new String[]{"mosip:idp:acr:generated-code", - "mosip:idp:acr:static-code"})).thenReturn(allAuthFactors); + /*when(authenticationContextClassRefUtil.getAuthFactors(new String[]{"mosip:idp:acr:generated-code", + "mosip:idp:acr:static-code"})).thenReturn(allAuthFactors);*/ AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); - authRequest.setIndividualId("23423434234"); + authRequest.setIndividualId(individualId); List authChallenges = new ArrayList<>(); authChallenges.add(getAuthChallengeDto("BIO")); authRequest.setChallengeList(authChallenges); @@ -925,8 +943,11 @@ public void authenticateV2_multipleRegisteredAcrsWithInvalidSingleFactor_thenFai public void authenticateV2_multipleRegisteredAcrsWithMultiFactor_thenPass() throws EsignetException, KycAuthException { String transactionId = "test-transaction"; String consentAction="Capture"; + String individualId = "23423434234"; when(cacheUtilService.getPreAuthTransaction(transactionId)).thenReturn(createIdpTransaction( new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:static-code"})); + when(cacheUtilService.updateIndividualIdHashInPreAuthCache(transactionId, individualId)).thenReturn(createIdpTransaction( + new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:static-code"})); List> allAuthFactors=new ArrayList<>(); allAuthFactors.add(getAuthFactors("mosip:idp:acr:biometrics-generated-code")); @@ -941,7 +962,7 @@ public void authenticateV2_multipleRegisteredAcrsWithMultiFactor_thenPass() thro AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); - authRequest.setIndividualId("23423434234"); + authRequest.setIndividualId(individualId); List authChallenges = new ArrayList<>(); authChallenges.add(getAuthChallengeDto("OTP")); authChallenges.add(getAuthChallengeDto("BIO")); @@ -956,14 +977,17 @@ public void authenticateV2_multipleRegisteredAcrsWithMultiFactor_thenPass() thro @Test public void authenticateV2_multipleRegisteredAcrsWithInvalidMultiFactor_thenFail() throws EsignetException { String transactionId = "test-transaction"; + String individualId = "23423434234"; when(cacheUtilService.getPreAuthTransaction(transactionId)).thenReturn(createIdpTransaction( new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:linked-wallet"})); + when(cacheUtilService.updateIndividualIdHashInPreAuthCache(transactionId, individualId)).thenReturn(createIdpTransaction( + new String[]{"mosip:idp:acr:biometrics-generated-code", "mosip:idp:acr:static-code"})); List> allAuthFactors=new ArrayList<>(); allAuthFactors.add(getAuthFactors("mosip:idp:acr:biometrics-generated-code")); allAuthFactors.add(getAuthFactors("mosip:idp:acr:linked-wallet")); - when(authenticationContextClassRefUtil.getAuthFactors(new String[]{"mosip:idp:acr:biometrics-generated-code", - "mosip:idp:acr:linked-wallet"})).thenReturn(allAuthFactors); + /*when(authenticationContextClassRefUtil.getAuthFactors(new String[]{"mosip:idp:acr:biometrics-generated-code", + "mosip:idp:acr:linked-wallet"})).thenReturn(allAuthFactors);*/ AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); diff --git a/oidc-ui/Dockerfile b/oidc-ui/Dockerfile index f0e0ffa23..9e296e92f 100644 --- a/oidc-ui/Dockerfile +++ b/oidc-ui/Dockerfile @@ -24,7 +24,7 @@ ENV DEFAULT_ID_PROVIDER_NAME=$defaultIdProviderName ENV PUBLIC_URL=_PUBLIC_URL_ COPY package*.json ./ -RUN npm install +RUN npm install --legacy-peer-deps #Copy the working directory COPY . ./ RUN npm run build diff --git a/oidc-ui/public/manifest.json b/oidc-ui/public/manifest.json index fe6916994..2c4bd3aec 100644 --- a/oidc-ui/public/manifest.json +++ b/oidc-ui/public/manifest.json @@ -1,16 +1,6 @@ { "short_name": "eSignet", "name": "eSignet", - "icons": [ - { - "src": "favicon.ico", - "type": "image/x-icon" - }, - { - "src": "logo.png", - "type": "image/png" - } - ], "start_url": ".", "display": "standalone", "theme_color": "#000000", diff --git a/oidc-ui/src/common/ErrorBanner.js b/oidc-ui/src/common/ErrorBanner.js index 76ff72146..6a9c02001 100644 --- a/oidc-ui/src/common/ErrorBanner.js +++ b/oidc-ui/src/common/ErrorBanner.js @@ -19,12 +19,14 @@ const ErrorBanner = ({ "flex justify-between items-center px-2 sm:px-5 lg:-mx-5 md:-mx-4 sm:-mx-3 -mx-3 error-banner " + customClass } + id="error-banner" > -
{t(errorCode)}
+
{t(errorCode)}
); diff --git a/oidc-ui/src/components/Background.js b/oidc-ui/src/components/Background.js index d2b97f825..64e42d662 100644 --- a/oidc-ui/src/components/Background.js +++ b/oidc-ui/src/components/Background.js @@ -45,10 +45,10 @@ export default function Background({ >
-

+

{heading}

-

{subheading}

+

{subheading}

-

{t("noAccount")}

+

{t("noAccount")}

handleSignup()}>{t("signup_for_unified_login")}
}
diff --git a/oidc-ui/src/services/api.service.js b/oidc-ui/src/services/api.service.js index af522b6d7..9e5276df9 100644 --- a/oidc-ui/src/services/api.service.js +++ b/oidc-ui/src/services/api.service.js @@ -24,9 +24,7 @@ const allErrorStatusCodes = [ // Create own axios instance with defaults. export const ApiService = axios.create({ withCredentials: true, - baseURL: API_BASE_URL, - signal: AbortSignal.timeout(5 * 60 * 1000), - timeout: 5 * 60 * 1000 + baseURL: API_BASE_URL }); export const setupResponseInterceptor = (navigate) => {