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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations