mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +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
|
// Authenticate using the database
|
||||||
Assert.assertNotNull(new InternalAuthenticationHandler().authenticate("testJpa", "12345678"));
|
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.
|
* Test the API resource.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
private static boolean configInboxChanged = false;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppResource() {
|
public void testAppResource() {
|
||||||
// Login admin
|
// Login admin
|
||||||
@ -249,6 +252,8 @@ public class TestAppResource extends BaseJerseyTest {
|
|||||||
json = target().path("/app/config_inbox").request()
|
json = target().path("/app/config_inbox").request()
|
||||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, adminToken)
|
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, adminToken)
|
||||||
.get(JsonObject.class);
|
.get(JsonObject.class);
|
||||||
|
JsonObject lastSync = json.getJsonObject("last_sync");
|
||||||
|
if (!configInboxChanged) {
|
||||||
Assert.assertFalse(json.getBoolean("enabled"));
|
Assert.assertFalse(json.getBoolean("enabled"));
|
||||||
Assert.assertEquals("", json.getString("hostname"));
|
Assert.assertEquals("", json.getString("hostname"));
|
||||||
Assert.assertEquals(993, json.getJsonNumber("port").intValue());
|
Assert.assertEquals(993, json.getJsonNumber("port").intValue());
|
||||||
@ -256,10 +261,10 @@ public class TestAppResource extends BaseJerseyTest {
|
|||||||
Assert.assertEquals("", json.getString("password"));
|
Assert.assertEquals("", json.getString("password"));
|
||||||
Assert.assertEquals("INBOX", json.getString("folder"));
|
Assert.assertEquals("INBOX", json.getString("folder"));
|
||||||
Assert.assertEquals("", json.getString("tag"));
|
Assert.assertEquals("", json.getString("tag"));
|
||||||
JsonObject lastSync = json.getJsonObject("last_sync");
|
|
||||||
Assert.assertTrue(lastSync.isNull("date"));
|
Assert.assertTrue(lastSync.isNull("date"));
|
||||||
Assert.assertTrue(lastSync.isNull("error"));
|
Assert.assertTrue(lastSync.isNull("error"));
|
||||||
Assert.assertEquals(0, lastSync.getJsonNumber("count").intValue());
|
Assert.assertEquals(0, lastSync.getJsonNumber("count").intValue());
|
||||||
|
}
|
||||||
|
|
||||||
// Change inbox configuration
|
// Change inbox configuration
|
||||||
target().path("/app/config_inbox").request()
|
target().path("/app/config_inbox").request()
|
||||||
@ -276,6 +281,7 @@ public class TestAppResource extends BaseJerseyTest {
|
|||||||
.param("folder", "INBOX")
|
.param("folder", "INBOX")
|
||||||
.param("tag", tagInboxId)
|
.param("tag", tagInboxId)
|
||||||
), JsonObject.class);
|
), JsonObject.class);
|
||||||
|
configInboxChanged = true;
|
||||||
|
|
||||||
// Get inbox configuration
|
// Get inbox configuration
|
||||||
json = target().path("/app/config_inbox").request()
|
json = target().path("/app/config_inbox").request()
|
||||||
|
@ -411,6 +411,12 @@ public class TestUserResource extends BaseJerseyTest {
|
|||||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, totp1Token)
|
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, totp1Token)
|
||||||
.get(JsonObject.class);
|
.get(JsonObject.class);
|
||||||
Assert.assertFalse(json.getBoolean("totp_enabled"));
|
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
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user