Search in sources :

Example 1 with AuthenticateRequest

use of io.realm.internal.network.AuthenticateRequest in project realm-java by realm.

the class AuthenticateRequestTests method realmLogin.

// Tests based on the schemas described here: https://github.com/realm/realm-sync-services/blob/master/doc/index.apib
@Test
public void realmLogin() throws URISyntaxException, JSONException {
    Token t = SyncTestUtils.createTestUser().getSyncUser().getUserToken();
    AuthenticateRequest request = AuthenticateRequest.realmLogin(t, new URI("realm://objectserver/" + t.identity() + "/default"));
    JSONObject obj = new JSONObject(request.toJson());
    assertEquals("/" + t.identity() + "/default", obj.get("path"));
    assertEquals(t.value(), obj.get("data"));
    assertEquals("realm", obj.get("provider"));
}
Also used : AuthenticateRequest(io.realm.internal.network.AuthenticateRequest) JSONObject(org.json.JSONObject) Token(io.realm.internal.objectserver.Token) URI(java.net.URI) Test(org.junit.Test)

Example 2 with AuthenticateRequest

use of io.realm.internal.network.AuthenticateRequest in project realm-java by realm.

the class AuthenticateRequestTests method userRefresh.

@Test
public void userRefresh() throws URISyntaxException, JSONException {
    Token t = SyncTestUtils.createTestUser().getSyncUser().getUserToken();
    AuthenticateRequest request = AuthenticateRequest.userRefresh(t, new URI("realm://objectserver/" + t.identity() + "/default"));
    JSONObject obj = new JSONObject(request.toJson());
    assertTrue(obj.has("path"));
    assertEquals(t.value(), obj.get("data"));
    assertEquals("realm", obj.get("provider"));
}
Also used : AuthenticateRequest(io.realm.internal.network.AuthenticateRequest) JSONObject(org.json.JSONObject) Token(io.realm.internal.objectserver.Token) URI(java.net.URI) Test(org.junit.Test)

Example 3 with AuthenticateRequest

use of io.realm.internal.network.AuthenticateRequest in project realm-java by realm.

the class AuthenticateRequestTests method userLogin.

@Test
public void userLogin() throws URISyntaxException, JSONException {
    AuthenticateRequest request = AuthenticateRequest.userLogin(SyncCredentials.facebook("foo"));
    JSONObject obj = new JSONObject(request.toJson());
    assertFalse(obj.has("path"));
    assertEquals("foo", obj.get("data"));
    assertEquals("facebook", obj.get("provider"));
}
Also used : AuthenticateRequest(io.realm.internal.network.AuthenticateRequest) JSONObject(org.json.JSONObject) Test(org.junit.Test)

Aggregations

AuthenticateRequest (io.realm.internal.network.AuthenticateRequest)3 JSONObject (org.json.JSONObject)3 Test (org.junit.Test)3 Token (io.realm.internal.objectserver.Token)2 URI (java.net.URI)2