1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-18 04:01:42 +00:00

#268: endpoint to test TOTP code

This commit is contained in:
Benjamin Gamard
2019-02-01 14:47:18 +01:00
parent 0d50676586
commit c6eb1c813c
2 changed files with 51 additions and 1 deletions

View File

@@ -370,7 +370,16 @@ public class TestUserResource extends BaseJerseyTest {
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, totp1Token)
.get(JsonObject.class);
Assert.assertTrue(json.getBoolean("totp_enabled"));
// Generate a OTP
validationCode = googleAuthenticator.calculateCode(secret, new Date().getTime() / 30000);
// Test a validation code
target().path("/user/test_totp").request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, totp1Token)
.post(Entity.form(new Form()
.param("code", Integer.toString(validationCode))), JsonObject.class);
// Disable TOTP for totp1
target().path("/user/disable_totp").request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, totp1Token)