@Before public void setUp() throws Exception { ((RestTemplate) restOperations) .setRequestFactory(new IntegrationTestUtils.StatelessRequestFactory()); ClientCredentialsResourceDetails clientCredentials = getClientCredentialsResource( new String[] {"scim.write"}, testAccounts.getAdminClientId(), testAccounts.getAdminClientSecret()); client = IntegrationTestUtils.getClientCredentialsTempate(clientCredentials); user = createUser( new RandomValueStringGenerator().generate(), "openiduser", "openidlast", "test@openid,com", true); }
@Test public void testUserLoginViaPasswordGrant() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); headers.add("Authorization", ((UaaTestAccounts) testAccounts).getAuthorizationHeader("cf", "")); LinkedMultiValueMap<String, String> postBody = new LinkedMultiValueMap<>(); postBody.add("grant_type", "password"); postBody.add("username", testAccounts.getUserName()); postBody.add("password", testAccounts.getPassword()); ResponseEntity<Void> responseEntity = restOperations.exchange( baseUrl + "/oauth/token", HttpMethod.POST, new HttpEntity<>(postBody, headers), Void.class); Assert.assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); }