Skip to content

Commit

Permalink
Merge pull request #93 from TrueSparrowSystems/user-code-fix
Browse files Browse the repository at this point in the history
Update App Tester User Login to use Token from Environment
  • Loading branch information
mohitcharkha authored Sep 18, 2023
2 parents 3640a0c + 2918425 commit 2f6fb1b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.salessparrow</groupId>
<artifactId>salessparrow-api</artifactId>
<version>0.2.0</version>
<version>0.2.2</version>
<name>api</name>
<description>Salessparrow apis</description>

Expand Down
16 changes: 16 additions & 0 deletions repo-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# SalesSparrow APIs

## 0.2.2

### Enhancements:

- Update Default Test User Login to use token from Environment [#92](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/92)

## 0.2.1

### New Features and Enhancements:

- Default Test User Login in Connect Flow [#90](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/90)

### Bug Fixes:

- Use Environment based Naming as Suffix in Cache Names [#91](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/91)

## 0.2.0

### New Features and Enhancements:
Expand Down
5 changes: 3 additions & 2 deletions sample.secrets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ERROR_MAIL_TO": "",
"COOKIE_DOMAIN": "",
"OPENAI_API_KEY": "",
"DEFAULT_TEST_USER":"",
"DEFAULT_TEST_USER_PASSWORD":""
"APP_STORE_TESTER_LOGIN_USER":"",
"APP_STORE_TESTER_LOGIN_PASSWORD":"",
"APP_STORE_TESTER_LOGIN_TOKEN": ""
}
12 changes: 6 additions & 6 deletions src/main/java/com/salessparrow/api/config/CoreConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public static String localKmsEndpoint() {
return SecretConstants.localKmsEndpoint();
}

public static String defaultTestUser() {
return SecretConstants.defaultTestUser();
public static String appStoreTesterLoginUser() {
return SecretConstants.appStoreTesterLoginUser();
}

public static String defaultTestUserPassword() {
return SecretConstants.defaultTestUserPassword();
public static String appStoreTesterLoginPassword() {
return SecretConstants.appStoreTesterLoginPassword();
}

public static String defaultTestUserCode() {
return "test_12341234";
public static String appStoreTesterLoginToken() {
return SecretConstants.appStoreTesterLoginToken();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AccountController {
@GetMapping("")
public ResponseEntity<GetAccountListResponseDto> getAccounts(HttpServletRequest request,
@Valid @ModelAttribute GetAccountsDto getAccountsDto) {
logger.info("Request received");
logger.info("Get Accounts Request received");

GetAccountListResponseDto getAccountsResponse = getAccountListService.getAccounts(request, getAccountsDto);

Expand All @@ -45,7 +45,7 @@ public ResponseEntity<GetAccountListResponseDto> getAccounts(HttpServletRequest
@GetMapping("/feed")
public ResponseEntity<GetAccountsFeedResponseDto> getFeed(HttpServletRequest request,
@Valid @ModelAttribute GetAccountsFeedDto getAccountsFeedDto) {
logger.info("Request received");
logger.info("Get Account Feed Request received");

GetAccountsFeedResponseDto getAccountsFeedResponse = getAccountsFeedService.getAccountsFeed(request,
getAccountsFeedDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ public static String localKmsEndpoint() {
return getSecret("LOCAL_KMS_ENDPOINT");
}

public static String defaultTestUser() {
return getSecret("DEFAULT_TEST_USER");
public static String appStoreTesterLoginUser() {
return getSecret("APP_STORE_TESTER_LOGIN_USER");
}

public static String defaultTestUserPassword() {
return getSecret("DEFAULT_TEST_USER_PASSWORD");
public static String appStoreTesterLoginPassword() {
return getSecret("APP_STORE_TESTER_LOGIN_PASSWORD");
}

public static String appStoreTesterLoginToken() {
return getSecret("APP_STORE_TESTER_LOGIN_TOKEN");
}

/* Secrets end */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public HttpResponse getTokens(String code, String redirectUri, Boolean isTestUse
requestBody = String.format(
"grant_type=%s&client_id=%s&client_secret=%s&username=%s&password=%s&redirect_uri=%s",
salesforceConstants.passwordGrantType(), CoreConstants.salesforceClientId(),
CoreConstants.salesforceClientSecret(), CoreConstants.defaultTestUser(),
CoreConstants.defaultTestUserPassword(), redirectUri);
CoreConstants.salesforceClientSecret(), CoreConstants.appStoreTesterLoginUser(),
CoreConstants.appStoreTesterLoginPassword(), redirectUri);
}

Map<String, String> headers = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public AuthServiceDto connectToSalesforce(SalesforceConnectDto params, HttpServl
this.isNewUser = true; // setting default value true to this variable, this will
// be updated based on conditions in further processing

String testUserCode = CoreConstants.defaultTestUserCode();
String appStoreTesterLoginToken = CoreConstants.appStoreTesterLoginToken();
Boolean isTestUser = false;

code = params.getCode();
if (code.equals(testUserCode)) {
if (code.equals(appStoreTesterLoginToken)) {
isTestUser = true;
}

Expand Down

0 comments on commit 2f6fb1b

Please sign in to comment.