mirror of
https://github.com/sismics/docs.git
synced 2025-12-16 19:21:48 +00:00
#84: Generate TOTP secret key
This commit is contained in:
@@ -23,8 +23,6 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestAclResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the ACL resource.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testAclResource() {
|
||||
|
||||
@@ -21,8 +21,6 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestAppResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the API resource.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testAppResource() {
|
||||
@@ -63,8 +61,6 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
|
||||
/**
|
||||
* Test the log resource.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testLogResource() {
|
||||
|
||||
@@ -20,8 +20,6 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestAuditLogResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the audit log resource.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testAuditLogResource() {
|
||||
|
||||
@@ -21,11 +21,9 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestCommentResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the comment resource.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testCommentResource() throws Exception {
|
||||
public void testCommentResource() {
|
||||
// Login comment1
|
||||
clientUtil.createUser("comment1");
|
||||
String comment1Token = clientUtil.login("comment1");
|
||||
|
||||
@@ -359,9 +359,8 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
* @param query Search query
|
||||
* @param token Authentication token
|
||||
* @return Number of documents found
|
||||
* @throws Exception
|
||||
*/
|
||||
private int searchDocuments(String query, String token) throws Exception {
|
||||
private int searchDocuments(String query, String token) {
|
||||
JsonObject json = target().path("/document/list")
|
||||
.queryParam("search", query)
|
||||
.request()
|
||||
|
||||
@@ -198,6 +198,11 @@ public class TestFileResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(1, files.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test orphan files (without linked document).
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testOrphanFile() throws Exception {
|
||||
// Login file2
|
||||
@@ -283,6 +288,11 @@ public class TestFileResource extends BaseJerseyTest {
|
||||
Assert.assertEquals("ok", json.getString("status"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test user quota.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testQuota() throws Exception {
|
||||
// Login file_quota
|
||||
|
||||
@@ -22,8 +22,6 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestGroupResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the group resource.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testGroupResource() {
|
||||
|
||||
@@ -21,8 +21,6 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestSecurity extends BaseJerseyTest {
|
||||
/**
|
||||
* Test of the security layer.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testSecurity() {
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestShareResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the share resource.
|
||||
* @throws Exception
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
@@ -21,8 +21,6 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestTagResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the tag resource.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testTagResource() {
|
||||
|
||||
@@ -22,8 +22,6 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestUserResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the user resource.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testUserResource() {
|
||||
@@ -229,8 +227,6 @@ public class TestUserResource extends BaseJerseyTest {
|
||||
|
||||
/**
|
||||
* Test the user resource admin functions.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Test
|
||||
public void testUserResourceAdmin() {
|
||||
@@ -290,4 +286,18 @@ public class TestUserResource extends BaseJerseyTest {
|
||||
json = response.readEntity(JsonObject.class);
|
||||
Assert.assertEquals("UserNotFound", json.getString("type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTotp() {
|
||||
// Create totp1 user
|
||||
clientUtil.createUser("totp1");
|
||||
String totp1Token = clientUtil.login("totp1");
|
||||
|
||||
// Enable TOTP for totp1
|
||||
JsonObject json = target().path("/user/enable_totp").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, totp1Token)
|
||||
.post(Entity.form(new Form()), JsonObject.class);
|
||||
String secret = json.getString("secret");
|
||||
Assert.assertNotNull(secret);
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,9 @@ import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
public class TestVocabularyResource extends BaseJerseyTest {
|
||||
/**
|
||||
* Test the vocabulary resource.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testVocabularyResource() throws Exception {
|
||||
public void testVocabularyResource() {
|
||||
// Login vocabulary1
|
||||
clientUtil.createUser("vocabulary1");
|
||||
String vocabulary1Token = clientUtil.login("vocabulary1");
|
||||
|
||||
Reference in New Issue
Block a user