mirror of
https://github.com/sismics/docs.git
synced 2024-12-14 16:13:48 +01:00
fixed non-idempotent tests (#757)
This commit is contained in:
parent
afa78857f9
commit
11ae0ea7d3
@ -29,5 +29,9 @@ public class TestJpa extends BaseTransactionalTest {
|
||||
|
||||
// Authenticate using the database
|
||||
Assert.assertNotNull(new InternalAuthenticationHandler().authenticate("testJpa", "12345678"));
|
||||
|
||||
// Delete the created user
|
||||
userDao.delete("testJpa", user.getId());
|
||||
TransactionUtil.commit();
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the API resource.
|
||||
*/
|
||||
|
||||
private static boolean configInboxChanged = false;
|
||||
|
||||
@Test
|
||||
public void testAppResource() {
|
||||
// Login admin
|
||||
@ -249,17 +252,19 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
json = target().path("/app/config_inbox").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, adminToken)
|
||||
.get(JsonObject.class);
|
||||
Assert.assertFalse(json.getBoolean("enabled"));
|
||||
Assert.assertEquals("", json.getString("hostname"));
|
||||
Assert.assertEquals(993, json.getJsonNumber("port").intValue());
|
||||
Assert.assertEquals("", json.getString("username"));
|
||||
Assert.assertEquals("", json.getString("password"));
|
||||
Assert.assertEquals("INBOX", json.getString("folder"));
|
||||
Assert.assertEquals("", json.getString("tag"));
|
||||
JsonObject lastSync = json.getJsonObject("last_sync");
|
||||
Assert.assertTrue(lastSync.isNull("date"));
|
||||
Assert.assertTrue(lastSync.isNull("error"));
|
||||
Assert.assertEquals(0, lastSync.getJsonNumber("count").intValue());
|
||||
if (!configInboxChanged) {
|
||||
Assert.assertFalse(json.getBoolean("enabled"));
|
||||
Assert.assertEquals("", json.getString("hostname"));
|
||||
Assert.assertEquals(993, json.getJsonNumber("port").intValue());
|
||||
Assert.assertEquals("", json.getString("username"));
|
||||
Assert.assertEquals("", json.getString("password"));
|
||||
Assert.assertEquals("INBOX", json.getString("folder"));
|
||||
Assert.assertEquals("", json.getString("tag"));
|
||||
Assert.assertTrue(lastSync.isNull("date"));
|
||||
Assert.assertTrue(lastSync.isNull("error"));
|
||||
Assert.assertEquals(0, lastSync.getJsonNumber("count").intValue());
|
||||
}
|
||||
|
||||
// Change inbox configuration
|
||||
target().path("/app/config_inbox").request()
|
||||
@ -276,6 +281,7 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
.param("folder", "INBOX")
|
||||
.param("tag", tagInboxId)
|
||||
), JsonObject.class);
|
||||
configInboxChanged = true;
|
||||
|
||||
// Get inbox configuration
|
||||
json = target().path("/app/config_inbox").request()
|
||||
|
@ -411,6 +411,12 @@ public class TestUserResource extends BaseJerseyTest {
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, totp1Token)
|
||||
.get(JsonObject.class);
|
||||
Assert.assertFalse(json.getBoolean("totp_enabled"));
|
||||
|
||||
// Delete totp1
|
||||
response = target().path("/user/totp1").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, adminToken)
|
||||
.delete();
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user