CloudStore { AssumeRoleRequest getAssumeRoleRequest(String account, String roleName, String principal, Integer durationSeconds, String externalId) { final String arn = "arn:aws:iam::" + account + ":role/" + roleName; AssumeRoleRequest req = new AssumeRoleRequest(); req.setRoleArn(arn); req.setRoleSessionName(AWS_ROLE_SESSION_NAME); if (durationSeconds != null && durationSeconds > 0) { req.setDurationSeconds(durationSeconds); } if (externalId != null && !externalId.isEmpty()) { req.setExternalId(externalId); } return req; } CloudStore(); void close(); void setHttpClient(HttpClient client); boolean isAwsEnabled(); AmazonS3 getS3Client(); AWSTemporaryCredentials assumeAWSRole(String account, String roleName, String principal,
                                                 Integer durationSeconds, String externalId); String getCloudAccount(String domainName);  }
@Test public void testGetAssumeRoleRequest() { CloudStore store = new CloudStore(); AssumeRoleRequest req = store.getAssumeRoleRequest("1234", "admin", "sys.auth.zts", null, null); assertEquals("arn:aws:iam::1234:role/admin", req.getRoleArn()); assertEquals("athenz-zts-service", req.getRoleSessionName()); assertNull(req.getDurationSeconds()); assertNull(req.getExternalId()); req = store.getAssumeRoleRequest("12345", "adminuser", "athenz.zts", 101, "external"); assertEquals("arn:aws:iam::12345:role/adminuser", req.getRoleArn()); assertEquals("athenz-zts-service", req.getRoleSessionName()); assertEquals(Integer.valueOf(101), req.getDurationSeconds()); assertEquals("external", req.getExternalId()); store.close(); }