Skip to content

Commit f944af1

Browse files
author
eugenp
committed
minor test changes
1 parent 2fbe17c commit f944af1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

spring-security-login-and-registration/src/test/java/org/baeldung/test/RegistrationAPIChangePasswordTest.java renamed to spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordApiTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.junit.runner.RunWith;
1717
import org.springframework.beans.factory.annotation.Autowired;
1818
import org.springframework.security.crypto.password.PasswordEncoder;
19-
import org.springframework.test.context.ActiveProfiles;
2019
import org.springframework.test.context.ContextConfiguration;
2120
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
2221
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@@ -28,20 +27,18 @@
2827

2928
@RunWith(SpringJUnit4ClassRunner.class)
3029
@ContextConfiguration(classes = { ConfigTest.class, PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class)
31-
@ActiveProfiles("test")
32-
public class RegistrationAPIChangePasswordTest {
30+
public class ChangePasswordApiTest {
31+
32+
private final String URL_PREFIX = "http://localhost:8080/spring-security-login-and-registration";
33+
private final String URL = URL_PREFIX + "/user/updatePassword";
3334

3435
@Autowired
3536
private UserRepository userRepository;
3637

3738
@Autowired
3839
private PasswordEncoder passwordEncoder;
3940

40-
private final String URL_PREFIX = "http://localhost:8080/spring-security-login-and-registration";
41-
42-
private final String URL = URL_PREFIX + "/user/updatePassword";
43-
44-
FormAuthConfig formConfig = new FormAuthConfig(URL_PREFIX + "/j_spring_security_check", "j_username", "j_password");
41+
private final FormAuthConfig formConfig = new FormAuthConfig(URL_PREFIX + "/j_spring_security_check", "j_username", "j_password");
4542

4643
@Before
4744
public void init() {
@@ -60,6 +57,8 @@ public void init() {
6057
}
6158
}
6259

60+
// test
61+
6362
@Test
6463
public void givenLoggedInUser_whenChangingPassword_thenCorrect() {
6564
final RequestSpecification request = RestAssured.given().auth().form("[email protected]", "test", formConfig);
@@ -99,4 +98,5 @@ public void givenNotAuthenticatedUser_whenChangingPassword_thenRedirect() {
9998
assertEquals(302, response.statusCode());
10099
assertFalse(response.body().asString().contains("Password updated successfully"));
101100
}
101+
102102
}

0 commit comments

Comments
 (0)