Skip to content

Commit 683a78b

Browse files
committed
work
1 parent 716e4b3 commit 683a78b

File tree

9 files changed

+197
-75
lines changed

9 files changed

+197
-75
lines changed

src/main/java/org/woehlke/java/simpleworklist/config/WebSecurityConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter implements W
4040

4141
private final AuthenticationManagerBuilder authenticationManagerBuilder;
4242
//private final AuthenticationSuccessHandler loginSuccessHandler;
43-
private final ApplicationUserDetailsService applicationUserDetailsService;
43+
private final UserDetailsService applicationUserDetailsService;
4444
private final SimpleworklistProperties simpleworklistProperties;
4545

46+
47+
4648
@Autowired
4749
public WebSecurityConfig(
4850
AuthenticationManagerBuilder auth,
49-
//LoginSuccessHandler loginSuccessHandler,
5051
ApplicationUserDetailsService applicationUserDetailsService,
5152
SimpleworklistProperties simpleworklistProperties) {
5253
this.authenticationManagerBuilder = auth;
53-
//this.loginSuccessHandler = loginSuccessHandler;
5454
this.applicationUserDetailsService = applicationUserDetailsService;
5555
this.simpleworklistProperties = simpleworklistProperties;
5656
}

src/main/java/org/woehlke/java/simpleworklist/domain/security/access/ApplicationUserDetailsServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.woehlke.java.simpleworklist.domain.db.user.account.UserAccountRepository;
1212

1313
@Slf4j
14-
@Service
14+
@Service//("userDetailsService")
1515
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
1616
public class ApplicationUserDetailsServiceImpl implements ApplicationUserDetailsService {
1717

src/test/java/org/woehlke/java/simpleworklist/SmokeTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
1212
import org.springframework.context.annotation.Import;
1313
import org.springframework.security.core.context.SecurityContextHolder;
14+
import org.springframework.security.core.userdetails.UserDetailsService;
1415
import org.springframework.security.core.userdetails.UsernameNotFoundException;
1516
import org.springframework.security.test.context.support.WithMockUser;
1617
import org.springframework.test.web.servlet.MockMvc;
@@ -20,6 +21,7 @@
2021
import org.woehlke.java.simpleworklist.config.UserAccountTestDataService;
2122
import org.woehlke.java.simpleworklist.config.WebMvcConfig;
2223
import org.woehlke.java.simpleworklist.config.WebSecurityConfig;
24+
import org.woehlke.java.simpleworklist.domain.security.access.ApplicationUserDetailsService;
2325

2426
import java.net.URL;
2527

src/test/java/org/woehlke/java/simpleworklist/domain/UserLoginControllerIT.java

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class UserLoginControllerIT {
6060
private final String eyecatcherH3 = "******************************************************************";
6161

6262
@BeforeEach
63-
public void setUp() throws Exception {
63+
public void setUp() {
6464
log.info(eyecatcherH1);
6565
log.info(" @BeforeEach setUp()");
6666
log.info(eyecatcherH2);
@@ -70,42 +70,64 @@ public void setUp() throws Exception {
7070
}
7171

7272
@BeforeAll
73-
public void runBeforeTestClass() throws Exception {
73+
public void runBeforeTestClass() {
7474
log.info(eyecatcherH1);
7575
log.info(" @BeforeTestClass runBeforeTestClass");
7676
log.info(eyecatcherH2);
77+
try {
7778
URL base = new URL("http://localhost:" + port + "/");
7879
log.info(" Server URL: " + base.toString());
7980
log.info(eyecatcherH2);
8081
userAccountTestDataService.setUp();
8182
log.info(eyecatcherH2);
8283
log.info(" @BeforeTestClass runBeforeTestClass");
8384
log.info(eyecatcherH1);
85+
} catch (Exception ex) {
86+
log.warn("Exception: " + ex.getLocalizedMessage());
87+
for (StackTraceElement e : ex.getStackTrace()) {
88+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
89+
}
90+
}
8491
}
8592

8693
@AfterAll
87-
public void runAfterTestClass() throws Exception {
94+
public void runAfterTestClass() {
8895
log.info(eyecatcherH1);
8996
log.info(" @AfterTestClass clearContext");
9097
log.info(eyecatcherH2);
91-
URL base = new URL("http://localhost:" + port + "/");
98+
URL base;
99+
try {
100+
base = new URL("http://localhost:" + port + "/");
92101
log.info(" Server URL: " + base.toString());
93102
log.info(eyecatcherH2);
94103
SecurityContextHolder.clearContext();
95104
log.info(eyecatcherH1);
105+
} catch (Exception ex) {
106+
log.warn("Exception: " + ex.getLocalizedMessage());
107+
for (StackTraceElement e : ex.getStackTrace()) {
108+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
109+
}
110+
}
96111
}
97112

98113

99114
@Test
100-
public void testLoginFormular() throws Exception {
101-
this.mockMvc.perform(
115+
public void testLoginFormular() {
116+
try {
117+
this.mockMvc.perform(
102118
get("/user/login")).andDo(print())
103119
.andExpect(view().name(containsString("user/login/loginForm")));
120+
} catch (Exception ex) {
121+
log.warn("Exception: " + ex.getLocalizedMessage());
122+
for (StackTraceElement e : ex.getStackTrace()) {
123+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
124+
}
125+
}
104126
}
105127

106128
@Test
107129
public void testFinish() {
108-
deleteAll();
130+
//deleteAll();
109131
}
110132

111133

src/test/java/org/woehlke/java/simpleworklist/domain/UserPasswordRecoveryControllerIT.java

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class UserPasswordRecoveryControllerIT {
8888
}
8989

9090
@BeforeEach
91-
public void setUp() throws Exception {
91+
public void setUp() {
9292
log.info(eyecatcherH1);
9393
log.info(" @BeforeEach setUp()");
9494
log.info(eyecatcherH2);
@@ -98,57 +98,87 @@ public void setUp() throws Exception {
9898
}
9999

100100
@BeforeAll
101-
public void runBeforeTestClass() throws Exception {
101+
public void runBeforeTestClass() {
102102
log.info(eyecatcherH1);
103103
log.info(" @BeforeTestClass runBeforeTestClass");
104104
log.info(eyecatcherH2);
105-
URL base = new URL("http://localhost:" + port + "/");
106-
log.info(" Server URL: " + base.toString());
107-
log.info(eyecatcherH2);
108-
userAccountTestDataService.setUp();
109-
log.info(eyecatcherH2);
110-
log.info(" @BeforeTestClass runBeforeTestClass");
105+
try {
106+
URL base = new URL("http://localhost:" + port + "/");
107+
log.info(" Server URL: " + base.toString());
108+
log.info(eyecatcherH2);
109+
userAccountTestDataService.setUp();
110+
log.info(eyecatcherH2);
111+
log.info(" @BeforeTestClass runBeforeTestClass");
111112
log.info(eyecatcherH1);
113+
} catch (Exception ex) {
114+
log.warn("Exception: " + ex.getLocalizedMessage());
115+
for (StackTraceElement e : ex.getStackTrace()) {
116+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
117+
}
118+
}
112119
}
113120

114121
@AfterAll
115-
public void runAfterTestClass() throws Exception {
122+
public void runAfterTestClass() {
116123
log.info(eyecatcherH1);
117124
log.info(" @AfterTestClass clearContext");
118125
log.info(eyecatcherH2);
119-
URL base = new URL("http://localhost:" + port + "/");
120-
log.info(" Server URL: " + base.toString());
121-
log.info(eyecatcherH2);
122-
SecurityContextHolder.clearContext();
123-
log.info(eyecatcherH1);
126+
try {
127+
URL base = new URL("http://localhost:" + port + "/");
128+
log.info(" Server URL: " + base.toString());
129+
log.info(eyecatcherH2);
130+
SecurityContextHolder.clearContext();
131+
log.info(eyecatcherH1);
132+
} catch (Exception ex) {
133+
log.warn("Exception: " + ex.getLocalizedMessage());
134+
for (StackTraceElement e : ex.getStackTrace()) {
135+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
136+
}
137+
}
124138
}
125139

126140

127141
@Autowired
128142
private UserAccountPasswordRecoveryService userAccountPasswordRecoveryService;
129143

130144
@Test
131-
public void testResetPassword() throws Exception {
132-
this.mockMvc.perform(
133-
get("/user/resetPassword")).andDo(print())
134-
.andExpect(view().name(containsString("user/resetPassword/resetPasswordForm")));
145+
public void testResetPassword() {
146+
try {
147+
this.mockMvc.perform(
148+
get("/user/resetPassword")).andDo(print())
149+
.andExpect(view().name(containsString("user/resetPassword/resetPasswordForm")));
150+
} catch (Exception ex) {
151+
log.warn("Exception: " + ex.getLocalizedMessage());
152+
for (StackTraceElement e : ex.getStackTrace()) {
153+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
154+
}
155+
}
135156
}
136157

137158
@Test
138-
public void testEnterNewPasswordFormular() throws Exception {
139-
this.mockMvc.perform(
140-
get("/user/resetPassword/confirm/ASDF")).andDo(print())
141-
.andExpect(view().name(containsString("user/resetPassword/resetPasswordNotConfirmed")));
159+
public void testEnterNewPasswordFormular() {
160+
try {
161+
this.mockMvc.perform(
162+
get("/user/resetPassword/confirm/ASDF")).andDo(print())
163+
.andExpect(view().name(containsString("user/resetPassword/resetPasswordNotConfirmed")));
164+
} catch (Exception ex) {
165+
log.warn("Exception: " + ex.getLocalizedMessage());
166+
for (StackTraceElement e : ex.getStackTrace()) {
167+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
168+
}
169+
}
142170
}
143171

172+
144173
@Test
145-
public void testEnterNewPasswordFormularWithToken() throws Exception {
174+
public void testEnterNewPasswordFormularWithToken() {
146175
userAccountPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]);
147176
try {
148177
Thread.sleep(2000);
149178
} catch (InterruptedException e) {
150179
e.printStackTrace();
151180
}
181+
try {
152182
UserAccountPasswordRecovery o = testHelperService.findPasswordRecoveryByEmail(emails[0]);
153183
assertNotNull(o);
154184
boolean result = o.getDoubleOptInStatus()== UserAccountPasswordRecoveryStatus.PASSWORD_RECOVERY_SAVED_EMAIL
@@ -159,7 +189,13 @@ public void testEnterNewPasswordFormularWithToken() throws Exception {
159189
get(url)).andDo(print())
160190
.andExpect(view().name(containsString("user/resetPassword/resetPasswordConfirmed")))
161191
.andExpect(model().attributeExists("userAccountFormBean"));
162-
userAccountPasswordRecoveryService.passwordRecoveryDone(o);
192+
userAccountPasswordRecoveryService.passwordRecoveryDone(o);
193+
} catch (Exception ex) {
194+
log.warn("Exception: " + ex.getLocalizedMessage());
195+
for (StackTraceElement e : ex.getStackTrace()) {
196+
log.warn(e.getClassName() + "." + e.getMethodName() + "in: " + e.getFileName() + " line: " + e.getLineNumber());
197+
}
198+
}
163199
}
164200

165201
@Test
@@ -168,9 +204,11 @@ public void finish(){
168204
}
169205

170206
protected void deleteAll(){
207+
/*
171208
testHelperService.deleteAllRegistrations();
172209
testHelperService.deleteAllTasks();
173210
testHelperService.deleteAllProjects();
174211
testHelperService.deleteUserAccount();
212+
*/
175213
}
176214
}

0 commit comments

Comments
 (0)