@Test public void test_configureAWSRole_successfully() { String roleName = "role1"; String policies = "{\"default\"}"; String token = "7QPMPIGiyDFlJkrK3jFykUqa"; Response responsemock = getMockResponse(HttpStatus.NO_CONTENT, true, ""); when(reqProcessor.process(eq("/auth/aws/roles/update"),Mockito.any(),eq(token))).thenReturn(responsemock); Response response = awsAuthService.configureAWSRole(roleName, policies, token); assertEquals(HttpStatus.NO_CONTENT, response.getHttpstatus()); }
public Response configureAWSRole(String roleName,String policies,String token ){ ObjectMapper objMapper = new ObjectMapper(); Map<String,String>configureRoleMap = new HashMap<String,String>(); configureRoleMap.put("role", roleName); configureRoleMap.put("policies", policies); String awsConfigJson =""; try { awsConfigJson = objMapper.writeValueAsString(configureRoleMap); } catch (JsonProcessingException e) { logger.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "configureAWSRole"). put(LogMessage.MESSAGE, String.format ("Unable to create awsConfigJson [%s] with roleName [%s] policies [%s] ", e.getMessage(), roleName, policies)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); } return reqProcessor.process("/auth/aws/roles/update",awsConfigJson,token); }
AWSAuthService { public Response configureAWSRole(String roleName,String policies,String token ){ ObjectMapper objMapper = new ObjectMapper(); Map<String,String>configureRoleMap = new HashMap<String,String>(); configureRoleMap.put("role", roleName); configureRoleMap.put("policies", policies); String awsConfigJson =""; try { awsConfigJson = objMapper.writeValueAsString(configureRoleMap); } catch (JsonProcessingException e) { logger.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "configureAWSRole"). put(LogMessage.MESSAGE, String.format ("Unable to create awsConfigJson [%s] with roleName [%s] policies [%s] ", e.getMessage(), roleName, policies)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); } return reqProcessor.process("/auth/aws/roles/update",awsConfigJson,token); } }
AWSAuthService { public Response configureAWSRole(String roleName,String policies,String token ){ ObjectMapper objMapper = new ObjectMapper(); Map<String,String>configureRoleMap = new HashMap<String,String>(); configureRoleMap.put("role", roleName); configureRoleMap.put("policies", policies); String awsConfigJson =""; try { awsConfigJson = objMapper.writeValueAsString(configureRoleMap); } catch (JsonProcessingException e) { logger.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "configureAWSRole"). put(LogMessage.MESSAGE, String.format ("Unable to create awsConfigJson [%s] with roleName [%s] policies [%s] ", e.getMessage(), roleName, policies)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); } return reqProcessor.process("/auth/aws/roles/update",awsConfigJson,token); }  }
AWSAuthService { public Response configureAWSRole(String roleName,String policies,String token ){ ObjectMapper objMapper = new ObjectMapper(); Map<String,String>configureRoleMap = new HashMap<String,String>(); configureRoleMap.put("role", roleName); configureRoleMap.put("policies", policies); String awsConfigJson =""; try { awsConfigJson = objMapper.writeValueAsString(configureRoleMap); } catch (JsonProcessingException e) { logger.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "configureAWSRole"). put(LogMessage.MESSAGE, String.format ("Unable to create awsConfigJson [%s] with roleName [%s] policies [%s] ", e.getMessage(), roleName, policies)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); } return reqProcessor.process("/auth/aws/roles/update",awsConfigJson,token); }  ResponseEntity<String> authenticateEC2(AWSLogin login); ResponseEntity<String> createRole(String token, AWSLoginRole awsLoginRole, UserDetails userDetails); ResponseEntity<String> updateRole(String token, AWSLoginRole awsLoginRole); ResponseEntity<String> deleteRole(String token, String role, UserDetails userDetails); ResponseEntity<String> fetchRole(String token, String role); ResponseEntity<String> listRoles(String token); ResponseEntity<String> configureClient(AWSClientConfiguration awsClientConfiguration, String token); ResponseEntity<String> readClientConfiguration(String token); ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token); ResponseEntity<String> authenticateIAM(AWSIAMLogin awsiamLogin); ResponseEntity<String> authenticate(AWSAuthType authType, AWSAuthLogin awsAuthLogin); Response configureAWSRole(String roleName,String policies,String token ); }
AWSAuthService { public Response configureAWSRole(String roleName,String policies,String token ){ ObjectMapper objMapper = new ObjectMapper(); Map<String,String>configureRoleMap = new HashMap<String,String>(); configureRoleMap.put("role", roleName); configureRoleMap.put("policies", policies); String awsConfigJson =""; try { awsConfigJson = objMapper.writeValueAsString(configureRoleMap); } catch (JsonProcessingException e) { logger.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "configureAWSRole"). put(LogMessage.MESSAGE, String.format ("Unable to create awsConfigJson [%s] with roleName [%s] policies [%s] ", e.getMessage(), roleName, policies)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); } return reqProcessor.process("/auth/aws/roles/update",awsConfigJson,token); }  ResponseEntity<String> authenticateEC2(AWSLogin login); ResponseEntity<String> createRole(String token, AWSLoginRole awsLoginRole, UserDetails userDetails); ResponseEntity<String> updateRole(String token, AWSLoginRole awsLoginRole); ResponseEntity<String> deleteRole(String token, String role, UserDetails userDetails); ResponseEntity<String> fetchRole(String token, String role); ResponseEntity<String> listRoles(String token); ResponseEntity<String> configureClient(AWSClientConfiguration awsClientConfiguration, String token); ResponseEntity<String> readClientConfiguration(String token); ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token); ResponseEntity<String> authenticateIAM(AWSIAMLogin awsiamLogin); ResponseEntity<String> authenticate(AWSAuthType authType, AWSAuthLogin awsAuthLogin); Response configureAWSRole(String roleName,String policies,String token );  }