Skip to content

Commit

Permalink
Merge pull request #284 from Backbase/CB-10685-add-user-profile-data-…
Browse files Browse the repository at this point in the history
…for-transaction-signing-2

CB-10685 Add user profile data for TX2
  • Loading branch information
PasupuletiRohini authored Apr 22, 2024
2 parents b4dafcf + f9897ed commit cd62d2d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.backbase.ct.bbfuel.client.user;

import static org.apache.http.HttpStatus.SC_CREATED;
import static org.apache.http.HttpStatus.SC_NO_CONTENT;

import com.backbase.ct.bbfuel.client.common.RestClient;
import com.backbase.ct.bbfuel.config.BbFuelConfiguration;
import com.backbase.ct.bbfuel.data.UserProfileData;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import javax.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class UserMockRestClient extends RestClient {

private final BbFuelConfiguration config;
private static final String SERVICE_VERSION = "v2";
private static final String ENDPOINT_ADD_USER_PROFILE_DATA = "/users/profile/mock/%s";

@PostConstruct
public void init() {
setBaseUri(config.getDbs().getUsermock());
setVersion(SERVICE_VERSION);
}

public void addUserProfileData(String userId) {
Response response = addPhoneAndElectronicAddressesData(userId);
if (response.statusCode() == SC_NO_CONTENT) {
log.info("User profile data is updated for user [{}]", userId);
} else if (response.statusCode() == SC_CREATED) {
log.info("User profile data is added for user [{}]", userId);
} else {
log.info("User profile data could not be added for user [{}]", userId);
}
}

private Response addPhoneAndElectronicAddressesData(String userId) {
return requestSpec()
.given()
.contentType(ContentType.JSON)
.body(UserProfileData.getPhoneAndElectronicAddressData())
.put(String.format(getPath(ENDPOINT_ADD_USER_PROFILE_DATA), userId))
.andReturn();
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/backbase/ct/bbfuel/config/DbsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class DbsConfig {
*/
private String user;

/**
* URI to user mock.
*/
private String usermock;

/**
* URI to legalentity.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.backbase.ct.bbfuel.client.common.LoginRestClient;
import com.backbase.ct.bbfuel.client.legalentity.LegalEntityPresentationRestClient;
import com.backbase.ct.bbfuel.client.user.UserIntegrationRestClient;
import com.backbase.ct.bbfuel.client.user.UserMockRestClient;
import com.backbase.ct.bbfuel.client.user.UserPresentationRestClient;
import com.backbase.ct.bbfuel.data.LegalEntitiesAndUsersDataGenerator;
import com.backbase.ct.bbfuel.dto.LegalEntityWithUsers;
Expand All @@ -37,6 +38,7 @@ public class LegalEntitiesAndUsersConfigurator {
private final LoginRestClient loginRestClient;
private final UserContextPresentationRestClient userContextPresentationRestClient;
private final UserIntegrationRestClient userIntegrationRestClient;
private final UserMockRestClient userMockRestClient;
private final UserPresentationRestClient userPresentationRestClient;
private final LegalEntityPresentationRestClient legalEntityPresentationRestClient;
private final LegalEntityService legalEntityService;
Expand Down Expand Up @@ -95,6 +97,9 @@ private void ingestUserAndLogResponse(UserExternal user) {

if (this.globalProperties.getBoolean(PROPERTY_IDENTITY_FEATURE_TOGGLE)) {
response = this.userIntegrationRestClient.importUserIdentity(user);
if (response.statusCode() == SC_CREATED) {
this.userMockRestClient.addUserProfileData(user.getExternalId());
}
} else {
response = this.userIntegrationRestClient.ingestUser(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ public class UserProfileData {
private static final String USER_PROFILE_POST_REQUEST_STRING =
"{ \"userId\": \"%s\", \"externalId\": \"%s\", \"userName\": \"%s\", \"name\": { \"formatted\": \"Mr. Account Statement Tester, Senior\", \"familyName\": \"Tester\", \"givenName\": \"Account\", \"middleName\": \"Statement\", \"honorificPrefix\": \"Mr.\", \"honorificSuffix\": \"Senior\" }, \"displayName\": \"AS Tester\", \"nickName\": \"AST\", \"profileUrl\": \"https://facebook.com/astester\", \"personalInformation\": { \"gender\": \"Male\", \"dateOfBirth\": \"01/01/1990\", \"countryOfBirth\": \"PL\", \"countryOfResidence\": \"PL\", \"nationalities\": [ \"PL, NL\" ], \"maritalStatus\": \"married\", \"educationLevel\": null, \"employer\": \"Backbase Poland\", \"employmentStatus\": \"Contractor\" }, \"identificationDetails\": [ { \"value\": \"9001010101011\", \"type\": \"PESEL\", \"issueDate\": null, \"expiryDate\": null, \"issueCountryCode\": \"PL\" } ], \"title\": \"QA Engineer\", \"userType\": \"Contractor\", \"preferredLanguage\": \"pl-PL\", \"locale\": \"pl-PL\", \"timezone\": \"America/Los_Angeles\", \"active\": true, \"emails\": [ { \"value\": \"mail@backbase.com\", \"display\": null, \"type\": \"work\", \"primary\": true } ], \"phoneNumbers\": [ { \"value\": \"604604604\", \"display\": null, \"type\": \"work\", \"primary\": true } ], \"ims\": [ { \"value\": \"slack/backbase\", \"display\": null, \"type\": \"aim\", \"primary\": true } ], \"photos\": [ { \"value\": \"http://imgagestock/12345\", \"display\": null, \"type\": \"photo\", \"primary\": null } ], \"addresses\": [ { \"formatted\": \"Pawia 100, 31111 Cracow, Poland\", \"streetAddress\": \"Pawia 100\", \"locality\": \"Cracow\", \"region\": \"Lesser Poland\", \"postalCode\": \"31111\", \"country\": \"Poland\", \"type\": \"work\", \"primary\": true } ], \"x509Certificates\": [ { \"value\": \"MIIDQzCCAqygAwIBAgICEAAwDQYJKoZIhvcNAQEFBQAwTjELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFDASBgNVBAoMC2V4YW1wbGUuY29tMRQwEgYDVQQDDAtleGFtcGxlLmNvbTAeFw0xMTEwMjIwNjI0MzFaFw0xMjEwMDQwNjI0MzFaMH8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQKDAtleGFtcGxlLmNvbTEhMB8GA1UEAwwYTXMuIEJhcmJhcmEgSiBKZW5zZW4gSUlJMSIwIAYJKoZIhvcNAQkBFhNiamVuc2VuQGV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7Kr\", \"display\": null, \"type\": null, \"primary\": null } ], \"extended\": { \"my-custom-reference-id\": \"Banky-McBankFace\" } }";

private static final String USER_PROFILE_PHONE_AND_ELECTRONIC_ADDRESSES_STRING =
"{ \"phone-addresses\": [ { \"key\": \"1\", \"type\": \"work\", \"primary\": true, \"number\": \"+441115556667\" }, { \"key\": \"2\", \"type\": \"home\", \"primary\": false, \"number\": \"022222222\" } ], \"electronic-addresses\": [ { \"key\": \"3\", \"type\": \"work\", \"primary\": true, \"address\": \"test@email.com\" }, { \"key\": \"4\", \"type\": \"home\", \"primary\": false, \"address\": \"test.test\" } ], \"postal-addresses\": [ ] }";


public static String getUserProfileData(String userId, String externalId) {
return String.format(USER_PROFILE_POST_REQUEST_STRING, userId, externalId, externalId);
}

public static String getPhoneAndElectronicAddressData() {
return USER_PROFILE_PHONE_AND_ELECTRONIC_ADDRESSES_STRING;
}
}
1 change: 1 addition & 0 deletions src/main/resources/application-k8s-beta-https.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bb-fuel:
legalentity: https://legalentity-${environment.name}.${environment.domain}
transactions: https://transactions-${environment.name}.${environment.domain}/integration-api
user: https://user-manager-${environment.name}.${environment.domain}/integration-api
usermock: https://usermock-${environment.name}.${environment.domain}/service-api
accountStatement: https://accountstatementsintegration-${environment.name}.${environment.domain}/service-api
pockets: https://edge.${environment.name}-${environment.domain}/api/pocket-tailor/client-api
pocketsArrangements: https://arrangementoutboundoriginationmock-${environment.name}.${environment.domain}/service-api
Expand Down

0 comments on commit cd62d2d

Please sign in to comment.