Skip to content

Commit 857b06a

Browse files
authored
Merge pull request #145 from scality/bugfix/OSIS-149-update-assumeRoleBackbeat-error
Bugfix: OSIS-149 | Update error expectation from Assume Role Backbeat API and bump OSIS to 2.2.4
2 parents 6eaf5d4 + 0e4fbb9 commit 857b06a

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
buildscript {
22
ext {
3-
osisVersion = '2.2.3'
3+
osisVersion = '2.2.4'
44
vaultclientVersion = '1.1.2'
55
springBootVersion = '2.7.6'
66
}

osis-core/src/main/java/com/scality/osis/service/impl/ScalityOsisServiceImpl.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,10 +1260,9 @@ public Credentials getCredentials(String accountID) {
12601260
} catch (VaultServiceException e) {
12611261

12621262
if (!StringUtils.isNullOrEmpty(e.getErrorCode()) &&
1263-
NO_SUCH_ENTITY_ERR.equals(e.getErrorCode()) &&
1264-
ROLE_DOES_NOT_EXIST_ERR.equals(e.getReason())) {
1265-
// If role does not exists, invoke setupAssumeRole
1266-
logger.error(ROLE_DOES_NOT_EXIST_ERR + ". Recreating the role");
1263+
ACCESS_DENIED.equals(e.getErrorCode())) {
1264+
// if access denied, invoke setupAssumeRole
1265+
logger.error(e.getReason() + ". Recreating the role");
12671266
// Call get Account with Account ID to retrieve account name
12681267
AccountData account = vaultAdmin.getAccount(ScalityModelConverter.toGetAccountRequestWithID(accountID));
12691268
asyncScalityOsisService.setupAssumeRole(accountID, account.getName());

osis-core/src/main/java/com/scality/osis/utils/ScalityConstants.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ private ScalityConstants() {
5656

5757
public static final String IAM_PREFIX = "/";
5858

59-
public static final String NO_SUCH_ENTITY_ERR = "NoSuchEntity";
60-
61-
public static final String ROLE_DOES_NOT_EXIST_ERR = "Role does not exist";
59+
public static final String ACCESS_DENIED = "AccessDenied";
6260

6361
public static final String NOT_AVAILABLE = "Not Available";
6462

osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceMiscTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ void testGetCredentialsWithNoRole() {
339339
// Setup
340340

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

0 commit comments

Comments
 (0)