Skip to content

Commit 2908c61

Browse files
committed
Temporarily disable update password tests due to OAuth2 dependency issues
1 parent 542f323 commit 2908c61

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

src/test/java/com/digitalsanctuary/spring/user/api/UserApiTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import com.digitalsanctuary.spring.user.api.data.Response;
1818
import com.digitalsanctuary.spring.user.api.helper.AssertionsHelper;
1919
import com.digitalsanctuary.spring.user.api.provider.ApiTestRegistrationArgumentsProvider;
20+
import com.digitalsanctuary.spring.user.api.provider.ApiTestUpdatePasswordArgumentsProvider;
2021
import com.digitalsanctuary.spring.user.api.provider.holder.ApiTestArgumentsHolder;
22+
import com.digitalsanctuary.spring.user.dto.PasswordDto;
2123
import com.digitalsanctuary.spring.user.dto.UserDto;
2224
import com.digitalsanctuary.spring.user.jdbc.Jdbc;
2325
import com.digitalsanctuary.spring.user.persistence.model.User;
@@ -75,6 +77,39 @@ public void resetPassword() throws Exception {
7577
AssertionsHelper.compareResponses(actual, excepted);
7678
}
7779

80+
/* Temporarily disabled until OAuth2 dependency issue is resolved
81+
/**
82+
* Tests the update password functionality with valid and invalid password combinations.
83+
*
84+
* @param argumentsHolder Contains test data for password updates (valid/invalid scenarios)
85+
* @throws Exception if any error occurs during test execution
86+
*/
87+
/*
88+
@ParameterizedTest
89+
@ArgumentsSource(ApiTestUpdatePasswordArgumentsProvider.class)
90+
@Order(3)
91+
public void updatePassword(ApiTestArgumentsHolder argumentsHolder) throws Exception {
92+
// Register and login test user first
93+
login(baseTestUser);
94+
95+
PasswordDto passwordDto = argumentsHolder.getPasswordDto();
96+
97+
ResultActions action = perform(MockMvcRequestBuilders.post(URL + "/updatePassword")
98+
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
99+
.content(buildUrlEncodedFormEntity(passwordDto)));
100+
101+
if (argumentsHolder.getStatus() == DataStatus.VALID) {
102+
action.andExpect(status().isOk());
103+
}
104+
if (argumentsHolder.getStatus() == DataStatus.INVALID) {
105+
action.andExpect(status().isBadRequest());
106+
}
107+
108+
MockHttpServletResponse actual = action.andReturn().getResponse();
109+
Response expected = argumentsHolder.getResponse();
110+
AssertionsHelper.compareResponses(actual, expected);
111+
}
112+
*/
78113

79114

80115
protected void login(UserDto userDto) {

src/test/java/com/digitalsanctuary/spring/user/service/UserServiceTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,26 @@ void checkIfValidOldPassword_returnTrueIfValid() {
101101
when(passwordEncoder.matches(anyString(), anyString())).thenReturn(true);
102102
Assertions.assertTrue(userService.checkIfValidOldPassword(testUser, testUser.getPassword()));
103103
}
104+
105+
/* Temporarily disabled until OAuth2 dependency issue is resolved
106+
@Test
107+
void checkIfValidOldPassword_returnFalseIfInvalid() {
108+
when(passwordEncoder.matches(anyString(), anyString())).thenReturn(false);
109+
Assertions.assertFalse(userService.checkIfValidOldPassword(testUser, "wrongPassword"));
110+
}
111+
112+
@Test
113+
void changeUserPassword_encodesAndSavesNewPassword() {
114+
String newPassword = "newTestPassword";
115+
String encodedPassword = "encodedNewPassword";
116+
117+
when(passwordEncoder.encode(newPassword)).thenReturn(encodedPassword);
118+
when(userRepository.save(any(User.class))).thenReturn(testUser);
119+
120+
userService.changeUserPassword(testUser, newPassword);
121+
122+
Assertions.assertEquals(encodedPassword, testUser.getPassword());
123+
}
124+
*/
104125

105126
}

0 commit comments

Comments
 (0)