Skip to content

Commit e238ba3

Browse files
author
eugenp
committed
work on a Spring Security authentication provider
1 parent 2736895 commit e238ba3

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

‎api/src/main/java/org/rest/sec/client/template/auth/AuthenticationRestTemplate.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public AuthenticationRestTemplate() {
3333
// API
3434

3535
public final ResponseEntity<User> authenticate(final String username, final String password) {
36-
return restTemplate.exchange(getUri(), HttpMethod.POST, new HttpEntity<User>(createHeaders(username, password)), User.class);
36+
return restTemplate.exchange(getUri(), HttpMethod.GET, new HttpEntity<User>(createHeaders(username, password)), User.class);
3737
}
3838

3939
// util

‎sec/src/test/java/org/rest/sec/client/template/test/AuthenticationClientRestLiveTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ public class AuthenticationClientRestLiveTest {
3131
// GET
3232

3333
@Test
34-
public final void whenAuthenticating_then201IsReceived() {
34+
public final void whenAuthenticating_then200IsReceived() {
3535
// When
3636
final ResponseEntity<User> response = authenticationRestTemplate.authenticate(SecurityConstants.ADMIN_EMAIL, SecurityConstants.ADMIN_PASS);
3737

3838
// Then
39-
assertThat(response.getStatusCode().value(), is(201));
39+
assertThat(response.getStatusCode().value(), is(200));
4040
}
4141

4242
}

‎sec/src/test/java/org/rest/sec/security/AuthenticationRestLiveTest.java‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,23 @@ public class AuthenticationRestLiveTest {
3131

3232
@Autowired
3333
private SecBusinessPaths paths;
34+
3435
@Autowired
3536
private ITestAuthenticator auth;
3637

3738
// tests
3839

3940
@Test
40-
public final void whenAuthenticationIsCreated_then201IsReceived() {
41+
public final void whenAuthenticationIsPerformed_then200IsReceived() {
4142
// When
42-
final Response response = givenAuthenticated().contentType(APPLICATION_JSON.toString()).post(paths.getAuthenticationUri());
43+
final Response response = givenAuthenticated().contentType(APPLICATION_JSON.toString()).get(paths.getAuthenticationUri());
4344

4445
// Then
45-
assertThat(response.getStatusCode(), is(201));
46+
assertThat(response.getStatusCode(), is(200));
4647
}
4748

4849
@Test
49-
public final void whenAuthenticationIsCreated_thenResponseHasContent() {
50+
public final void whenAuthenticationIsPerformed_thenResponseHasContent() {
5051
// When
5152
final Response response = givenAuthenticated().contentType(APPLICATION_JSON.toString()).post(paths.getAuthenticationUri());
5253

@@ -55,18 +56,18 @@ public final void whenAuthenticationIsCreated_thenResponseHasContent() {
5556
}
5657

5758
@Test
58-
public final void whenAuthenticationIsCreated_thenResponseIsPrincipal() {
59+
public final void whenAuthenticationIsPerformed_thenResponseIsPrincipal() {
5960
// When
60-
final Response response = givenAuthenticated().contentType(APPLICATION_JSON.toString()).post(paths.getAuthenticationUri());
61+
final Response response = givenAuthenticated().contentType(APPLICATION_JSON.toString()).get(paths.getAuthenticationUri());
6162

6263
// Then
6364
response.as(User.class);
6465
}
6566

6667
@Test
67-
public final void whenAuthenticationIsCreated_thenPrincipalResponseIsCorrect() {
68+
public final void whenAuthenticationIsPerformed_thenPrincipalResponseIsCorrect() {
6869
// When
69-
final Response response = givenAuthenticated().contentType(APPLICATION_JSON.toString()).post(paths.getAuthenticationUri());
70+
final Response response = givenAuthenticated().contentType(APPLICATION_JSON.toString()).get(paths.getAuthenticationUri());
7071

7172
// Then
7273
assertEquals(new User(SecurityConstants.EMAIL, SecurityConstants.PASS, null), response.as(User.class));

0 commit comments

Comments
 (0)