Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: OSIS-149 | Update error expectation from Assume Role Backbeat API and bump OSIS to 2.2.4 #145

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2.3'
osisVersion = '2.2.4'
vaultclientVersion = '1.1.2'
springBootVersion = '2.7.6'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,10 +1260,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 @@ -339,7 +339,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
Loading