Search in sources :

Example 1 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class DataTypesActionTest method testHandle.

@Test
public void testHandle() {
    AuthServiceProviderRegistry registry = mock(AuthServiceProviderRegistry.class);
    Set<String> dataTypes = new HashSet<>(Arrays.asList("CONTACTS", "PHOTOS"));
    when(registry.getTransferDataTypes()).thenReturn(dataTypes);
    DataTypesAction dataTypesAction = new DataTypesAction(registry, new Monitor() {
    });
    GetDataTypes request = mock(GetDataTypes.class);
    DataTypes actual = dataTypesAction.handle(request);
    Assert.assertEquals(actual.getDataTypes(), dataTypes);
}
Also used : Monitor(org.datatransferproject.api.launcher.Monitor) AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) GetDataTypes(org.datatransferproject.types.client.datatype.GetDataTypes) HashSet(java.util.HashSet) DataTypes(org.datatransferproject.types.client.datatype.DataTypes) GetDataTypes(org.datatransferproject.types.client.datatype.GetDataTypes) Test(org.junit.Test)

Example 2 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class PortabilityAuthServiceExtensionRegistryTest method testGetTransferDataTypes.

@Test
public void testGetTransferDataTypes() {
    List<String> supportedServiceTypes = ImmutableList.of("PHOTOS", "CONTACTS");
    AuthServiceExtension mockAuthProvider = getMockedAuthProvider(supportedServiceTypes, supportedServiceTypes, "mockAuthProvider");
    AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider", mockAuthProvider));
    Set<String> actual = registry.getTransferDataTypes();
    final String[] services = new String[] { "PHOTOS", "CONTACTS" };
    Set<String> expected = new HashSet<>(Arrays.asList(services));
    Assert.assertEquals(actual, expected);
}
Also used : AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) AuthServiceExtension(org.datatransferproject.spi.api.auth.extension.AuthServiceExtension) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class PortabilityAuthServiceExtensionRegistryTest method testGetImportServices1.

@Test
public void testGetImportServices1() {
    List<String> supportedServiceTypes1 = ImmutableList.of("PHOTOS", "CONTACTS");
    List<String> supportedServiceTypes2 = ImmutableList.of("CONTACTS");
    AuthServiceExtension mockAuthProvider1 = getMockedAuthProvider(supportedServiceTypes1, supportedServiceTypes1, "mockAuthProvider1");
    AuthServiceExtension mockAuthProvider2 = getMockedAuthProvider(supportedServiceTypes2, supportedServiceTypes2, "mockAuthProvider2");
    AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider1", mockAuthProvider1, "mockServiceProvider2", mockAuthProvider2));
    Set<String> actual = registry.getImportServices("CONTACTS");
    final String[] services = new String[] { "mockAuthProvider1", "mockAuthProvider2" };
    Set<String> expected = new HashSet<>(Arrays.asList(services));
    Assert.assertEquals(actual, expected);
}
Also used : AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) AuthServiceExtension(org.datatransferproject.spi.api.auth.extension.AuthServiceExtension) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class PortabilityAuthServiceExtensionRegistryTest method requireImportAndExportTest.

@Test
public void requireImportAndExportTest() {
    List<String> supportedImportTypes = ImmutableList.of("PHOTOS", "CONTACTS");
    List<String> supportedExportTypes = ImmutableList.of("CONTACTS");
    AuthServiceExtension mockAuthProvider = getMockedAuthProvider(supportedImportTypes, supportedExportTypes, "mockAuthProvider");
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("available for import but not export");
    AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider", mockAuthProvider));
}
Also used : AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) AuthServiceExtension(org.datatransferproject.spi.api.auth.extension.AuthServiceExtension) Test(org.junit.Test)

Example 5 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class PortabilityAuthServiceExtensionRegistryTest method testGetExportServices1.

@Test
public void testGetExportServices1() {
    List<String> supportedServiceTypes1 = ImmutableList.of("PHOTOS", "CONTACTS");
    List<String> supportedServiceTypes2 = ImmutableList.of("CONTACTS");
    AuthServiceExtension mockAuthProvider1 = getMockedAuthProvider(supportedServiceTypes1, supportedServiceTypes1, "mockAuthProvider1");
    AuthServiceExtension mockAuthProvider2 = getMockedAuthProvider(supportedServiceTypes2, supportedServiceTypes2, "mockAuthProvider2");
    AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider1", mockAuthProvider1, "mockServiceProvider2", mockAuthProvider2));
    Set<String> actual = registry.getExportServices("CONTACTS");
    final String[] services = new String[] { "mockAuthProvider1", "mockAuthProvider2" };
    Set<String> expected = new HashSet<>(Arrays.asList(services));
    Assert.assertEquals(actual, expected);
}
Also used : AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) AuthServiceExtension(org.datatransferproject.spi.api.auth.extension.AuthServiceExtension) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

AuthServiceProviderRegistry (org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry)9 Test (org.junit.Test)9 AuthServiceExtension (org.datatransferproject.spi.api.auth.extension.AuthServiceExtension)7 HashSet (java.util.HashSet)6 Monitor (org.datatransferproject.api.launcher.Monitor)2 GetDataTypes (org.datatransferproject.types.client.datatype.GetDataTypes)2 AuthDataGenerator (org.datatransferproject.spi.api.auth.AuthDataGenerator)1 DataTypes (org.datatransferproject.types.client.datatype.DataTypes)1