Skip to content

Commit

Permalink
Merge pull request #146 from scality/bugfix/OSIS-149-update-assumeRol…
Browse files Browse the repository at this point in the history
…eBackbeat-error-dev/2.1

[Cherry-pick] Bugfix: OSIS-149 | Update error expectation from Assume Role Backbeat API and bump OSIS to 2.1.5
  • Loading branch information
anurag4DSB committed Jun 4, 2024
2 parents 2ad4211 + 553833d commit 4c71fa1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
osisVersion = '2.1.4'
osisVersion = '2.1.5'
vaultclientVersion = '1.1.2'
springBootVersion = '2.7.6'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1249,10 +1249,9 @@ public Credentials getCredentials(String accountID) {
} catch (VaultServiceException e) {

if (!StringUtils.isNullOrEmpty(e.getErrorCode()) &&
NO_SUCH_ENTITY_ERR.equals(e.getErrorCode()) &&
ROLE_DOES_NOT_EXIST_ERR.equals(e.getReason())) {
// If role does not exists, invoke setupAssumeRole
logger.error(ROLE_DOES_NOT_EXIST_ERR + ". Recreating the role");
ACCESS_DENIED.equals(e.getErrorCode())) {
// if access denied, invoke setupAssumeRole
logger.error(e.getReason() + ". Recreating the role");
// Call get Account with Account ID to retrieve account name
AccountData account = vaultAdmin.getAccount(ScalityModelConverter.toGetAccountRequestWithID(accountID));
asyncScalityOsisService.setupAssumeRole(accountID, account.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ private ScalityConstants() {

public static final String IAM_PREFIX = "/";

public static final String NO_SUCH_ENTITY_ERR = "NoSuchEntity";

public static final String ROLE_DOES_NOT_EXIST_ERR = "Role does not exist";
public static final String ACCESS_DENIED = "AccessDenied";

public static final String NOT_AVAILABLE = "Not Available";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void testGetCredentialsWithNoRole() {
// Setup

when(vaultAdminMock.getTempAccountCredentials(any(AssumeRoleRequest.class)))
.thenThrow(new VaultServiceException(HttpStatus.NOT_FOUND, "NoSuchEntity", "Role does not exist"))
.thenThrow(new VaultServiceException(HttpStatus.FORBIDDEN, "AccessDenied", "User: backbeat is not allowed to assume role"))
.thenAnswer((Answer<Credentials>) invocation -> {
final Credentials credentials = new Credentials();
credentials.setAccessKeyId(TEST_ACCESS_KEY);
Expand Down

0 comments on commit 4c71fa1

Please sign in to comment.