@@ -37,7 +37,10 @@ public class TestAppResource extends BaseJerseyTest {
37
37
* Test the API resource.
38
38
*/
39
39
40
+ // Record if config has been changed by previous test runs
40
41
private static boolean configInboxChanged = false ;
42
+ private static boolean configSmtpChanged = false ;
43
+ private static boolean configLdapChanged = false ;
41
44
42
45
@ Test
43
46
public void testAppResource () {
@@ -191,6 +194,12 @@ public void testGuestLogin() {
191
194
target ().path ("/document/list" ).request ()
192
195
.cookie (TokenBasedSecurityFilter .COOKIE_NAME , guestToken )
193
196
.get (JsonObject .class );
197
+
198
+ // Disable guest login (clean up state)
199
+ target ().path ("/app/guest_login" ).request ()
200
+ .cookie (TokenBasedSecurityFilter .COOKIE_NAME , adminToken )
201
+ .post (Entity .form (new Form ()
202
+ .param ("enabled" , "false" )), JsonObject .class );
194
203
}
195
204
196
205
/**
@@ -205,11 +214,13 @@ public void testSmtpConfiguration() {
205
214
JsonObject json = target ().path ("/app/config_smtp" ).request ()
206
215
.cookie (TokenBasedSecurityFilter .COOKIE_NAME , adminToken )
207
216
.get (JsonObject .class );
208
- Assert .assertTrue (json .isNull ("hostname" ));
209
- Assert .assertTrue (json .isNull ("port" ));
210
- Assert .assertTrue (json .isNull ("username" ));
211
- Assert .assertTrue (json .isNull ("password" ));
212
- Assert .assertTrue (json .isNull ("from" ));
217
+ if (!configSmtpChanged ) {
218
+ Assert .assertTrue (json .isNull ("hostname" ));
219
+ Assert .assertTrue (json .isNull ("port" ));
220
+ Assert .assertTrue (json .isNull ("username" ));
221
+ Assert .assertTrue (json .isNull ("password" ));
222
+ Assert .assertTrue (json .isNull ("from" ));
223
+ }
213
224
214
225
// Change SMTP configuration
215
226
target ().path ("/app/config_smtp" ).request ()
@@ -220,6 +231,7 @@ public void testSmtpConfiguration() {
220
231
.param ("username" , "sismics" )
221
232
.
param (
"from" ,
"[email protected] " )
222
233
), JsonObject .class );
234
+ configSmtpChanged = true ;
223
235
224
236
// Get SMTP configuration
225
237
json = target ().path ("/app/config_smtp" ).request ()
@@ -389,7 +401,9 @@ public void testLdapAuthentication() throws Exception {
389
401
JsonObject json = target ().path ("/app/config_ldap" ).request ()
390
402
.cookie (TokenBasedSecurityFilter .COOKIE_NAME , adminToken )
391
403
.get (JsonObject .class );
392
- Assert .assertFalse (json .getBoolean ("enabled" ));
404
+ if (!configLdapChanged ) {
405
+ Assert .assertFalse (json .getBoolean ("enabled" ));
406
+ }
393
407
394
408
// Change LDAP configuration
395
409
target ().path ("/app/config_ldap" ).request ()
@@ -406,6 +420,7 @@ public void testLdapAuthentication() throws Exception {
406
420
.
param (
"default_email" ,
"[email protected] " )
407
421
.param ("default_storage" , "100000000" )
408
422
), JsonObject .class );
423
+ configLdapChanged = true ;
409
424
410
425
// Get the LDAP configuration
411
426
json = target ().path ("/app/config_ldap" ).request ()
0 commit comments