Search in sources :

Example 1 with RenewTokenResult

use of org.haiku.haikudepotserver.api1.model.user.RenewTokenResult in project haikudepotserver by haiku.

the class UserApiIT method testRenewToken.

@Test
public void testRenewToken() {
    String token;
    ObjectId userOid;
    {
        ObjectContext context = serverRuntime.newContext();
        User user = integrationTestSupportService.createBasicUser(context, "testuser", "U7vqpsu6BB");
        userOid = user.getObjectId();
        token = userAuthenticationService.generateToken(user);
    }
    RenewTokenRequest renewTokenRequest = new RenewTokenRequest();
    renewTokenRequest.token = token;
    // ------------------------------------
    RenewTokenResult result = userApi.renewToken(renewTokenRequest);
    // ------------------------------------
    {
        Optional<ObjectId> afterUserObjectId = userAuthenticationService.authenticateByToken(result.token);
        Assertions.assertThat(userOid).isEqualTo(afterUserObjectId.get());
    }
}
Also used : User(org.haiku.haikudepotserver.dataobjects.User) Optional(java.util.Optional) ObjectId(org.apache.cayenne.ObjectId) RenewTokenRequest(org.haiku.haikudepotserver.api1.model.user.RenewTokenRequest) RenewTokenResult(org.haiku.haikudepotserver.api1.model.user.RenewTokenResult) ObjectContext(org.apache.cayenne.ObjectContext) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

Optional (java.util.Optional)1 ObjectContext (org.apache.cayenne.ObjectContext)1 ObjectId (org.apache.cayenne.ObjectId)1 AbstractIntegrationTest (org.haiku.haikudepotserver.AbstractIntegrationTest)1 RenewTokenRequest (org.haiku.haikudepotserver.api1.model.user.RenewTokenRequest)1 RenewTokenResult (org.haiku.haikudepotserver.api1.model.user.RenewTokenResult)1 User (org.haiku.haikudepotserver.dataobjects.User)1 Test (org.junit.jupiter.api.Test)1