Search in sources :

Example 11 with Builder

use of com.google.api.ads.common.lib.auth.OfflineCredentials.Builder in project googleads-java-lib by googleads.

the class OfflineCredentialsTest method testReadPropertiesFromConfiguration_missingClientSecret.

/**
 * Tests that the builder correctly fails on a bad configuration.
 */
@Test
public void testReadPropertiesFromConfiguration_missingClientSecret() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.admanager.clientId", "clientId");
    config.setProperty("api.admanager.refreshToken", "refreshToken");
    thrown.expect(ValidationException.class);
    new OfflineCredentials.Builder().forApi(OfflineCredentials.Api.AD_MANAGER).from(config).build();
}
Also used : Builder(com.google.api.ads.common.lib.auth.OfflineCredentials.Builder) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Test(org.junit.Test)

Example 12 with Builder

use of com.google.api.ads.common.lib.auth.OfflineCredentials.Builder in project googleads-java-lib by googleads.

the class OfflineCredentialsTest method testReadPropertiesFromConfiguration_onlyKeyFilePath.

/**
 * Tests that the builder does not fail when missing everything but a service account key.
 */
@Test
public void testReadPropertiesFromConfiguration_onlyKeyFilePath() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.admanager.jsonKeyFilePath", "jsonKeyFilePath");
    new OfflineCredentials.Builder().forApi(OfflineCredentials.Api.AD_MANAGER).from(config).build();
}
Also used : Builder(com.google.api.ads.common.lib.auth.OfflineCredentials.Builder) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Test(org.junit.Test)

Example 13 with Builder

use of com.google.api.ads.common.lib.auth.OfflineCredentials.Builder in project googleads-java-lib by googleads.

the class OfflineCredentialsTest method testReadPropertiesFromConfiguration_serviceAccountUserNoKeyFile.

/**
 * Tests that the builder correctly fails on a bad configuration that has serviceAccountUser
 * specified but does not have the jsonKeyFilePath.
 */
@Test
public void testReadPropertiesFromConfiguration_serviceAccountUserNoKeyFile() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.admanager.clientId", "clientId");
    config.setProperty("api.admanager.clientSecret", "clientSecret");
    config.setProperty("api.admanager.refreshToken", "refreshToken");
    config.setProperty("api.admanager.serviceAccountUser", "someUser@example.com");
    thrown.expect(ValidationException.class);
    new OfflineCredentials.Builder().forApi(OfflineCredentials.Api.AD_MANAGER).from(config).build();
}
Also used : Builder(com.google.api.ads.common.lib.auth.OfflineCredentials.Builder) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Test(org.junit.Test)

Example 14 with Builder

use of com.google.api.ads.common.lib.auth.OfflineCredentials.Builder in project googleads-java-lib by googleads.

the class OfflineCredentialsTest method testReadPropertiesFromConfiguration_missingClientId.

/**
 * Tests that the builder correctly fails on a bad configuration.
 */
@Test
public void testReadPropertiesFromConfiguration_missingClientId() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.admanager.clientSecret", "clientSecret");
    config.setProperty("api.admanager.refreshToken", "refreshToken");
    thrown.expect(ValidationException.class);
    new OfflineCredentials.Builder().forApi(OfflineCredentials.Api.AD_MANAGER).from(config).build();
}
Also used : Builder(com.google.api.ads.common.lib.auth.OfflineCredentials.Builder) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Test(org.junit.Test)

Example 15 with Builder

use of com.google.api.ads.common.lib.auth.OfflineCredentials.Builder in project googleads-java-lib by googleads.

the class OfflineCredentialsTest method testReadPropertiesFromConfiguration_multipleOAuthTypes.

/**
 * Tests that the builder correctly fails on a bad configuration.
 */
@Test
public void testReadPropertiesFromConfiguration_multipleOAuthTypes() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.admanager.clientSecret", "clientSecret");
    config.setProperty("api.admanager.jsonKeyFilePath", "jsonKeyFilePath");
    thrown.expect(ValidationException.class);
    new OfflineCredentials.Builder().forApi(OfflineCredentials.Api.AD_MANAGER).from(config).build();
}
Also used : Builder(com.google.api.ads.common.lib.auth.OfflineCredentials.Builder) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Test(org.junit.Test)

Aggregations

Builder (com.google.api.ads.common.lib.auth.OfflineCredentials.Builder)15 Test (org.junit.Test)15 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)13 ForApiBuilder (com.google.api.ads.common.lib.auth.OfflineCredentials.ForApiBuilder)1 HttpTransport (com.google.api.client.http.HttpTransport)1 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)1