Search in sources :

Example 1 with SignUpCredentials

use of io.divide.client.auth.credentials.SignUpCredentials in project divide by HiddenStage.

the class AuthManagerTest method testGetRemoteUserFromToken.

@Test
public void testGetRemoteUserFromToken() throws Exception {
    SignUpResponse response = authManager.signUp(new SignUpCredentials("name", "email", ""));
    BackendUser user = response.get();
    assertEquals(user.getUsername(), "name");
    BackendUser credentials = authManager.getUserFromAuthToken(user.getAuthToken()).toBlockingObservable().first();
    assertEquals(credentials.getUsername(), "name");
}
Also used : SignUpCredentials(io.divide.client.auth.credentials.SignUpCredentials) BackendUser(io.divide.client.BackendUser) ClientTest(io.divide.client.ClientTest) Test(org.junit.Test)

Example 2 with SignUpCredentials

use of io.divide.client.auth.credentials.SignUpCredentials in project divide by HiddenStage.

the class AuthManagerTest method testSignUp.

@Test
public void testSignUp() throws Exception {
    SignUpResponse response = authManager.signUp(new SignUpCredentials("name", "email", ""));
    assertEquals(response.get().getUsername(), "name");
}
Also used : SignUpCredentials(io.divide.client.auth.credentials.SignUpCredentials) ClientTest(io.divide.client.ClientTest) Test(org.junit.Test)

Example 3 with SignUpCredentials

use of io.divide.client.auth.credentials.SignUpCredentials in project divide by HiddenStage.

the class AuthManagerTest method testLogin.

@Test
public void testLogin() throws Exception {
    SignUpCredentials signUpCredentials = new SignUpCredentials("name", "email", "");
    String unEncryptedPW = signUpCredentials.getPassword();
    BackendUser signInUser = authManager.signUp(signUpCredentials).get();
    BackendUser user = authManager.login(new LoginCredentials(signInUser.getEmailAddress(), unEncryptedPW)).get();
    assertNotNull(user);
    assertEquals(signInUser.getUsername(), user.getUsername());
}
Also used : LoginCredentials(io.divide.client.auth.credentials.LoginCredentials) SignUpCredentials(io.divide.client.auth.credentials.SignUpCredentials) BackendUser(io.divide.client.BackendUser) ClientTest(io.divide.client.ClientTest) Test(org.junit.Test)

Example 4 with SignUpCredentials

use of io.divide.client.auth.credentials.SignUpCredentials in project divide by HiddenStage.

the class DataManagerTest method testSend.

@Test
public void testSend() throws Exception {
    SignUpResponse response = authManager.signUp(new SignUpCredentials("name", "email", ""));
    assertEquals(response.get().getUsername(), "name");
    BackendServices.remote().save(new BackendObject()).toBlockingObservable();
}
Also used : SignUpResponse(io.divide.client.auth.SignUpResponse) SignUpCredentials(io.divide.client.auth.credentials.SignUpCredentials) BackendObject(io.divide.client.BackendObject) ClientTest(io.divide.client.ClientTest) Test(org.junit.Test)

Example 5 with SignUpCredentials

use of io.divide.client.auth.credentials.SignUpCredentials in project divide by HiddenStage.

the class BackendUser method signUp.

/**
     * Synchronously sign up using credentials provided via constructor or setters.
     * @return boolean indicating sign up success
     */
public boolean signUp() {
    SignUpCredentials creds = new SignUpCredentials(getUsername(), getEmailAddress(), getPassword());
    SignUpResponse response = getAM().signUp(creds);
    if (response.getStatus().isSuccess()) {
        this.initFrom(response.get());
        return true;
    } else
        return false;
}
Also used : SignUpResponse(io.divide.client.auth.SignUpResponse) SignUpCredentials(io.divide.client.auth.credentials.SignUpCredentials)

Aggregations

SignUpCredentials (io.divide.client.auth.credentials.SignUpCredentials)9 ClientTest (io.divide.client.ClientTest)8 Test (org.junit.Test)8 BackendUser (io.divide.client.BackendUser)6 LoginCredentials (io.divide.client.auth.credentials.LoginCredentials)3 SignUpResponse (io.divide.client.auth.SignUpResponse)2 BackendObject (io.divide.client.BackendObject)1