/** * Tests that the builder correctly identifies the file path. */ @Test public void testReadPropertiesFromFile_clientSecretTokenBadWithFilePath() throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.admanager.clientId", "clientId"); config.setProperty("api.admanager.refreshToken", "refreshToken"); when(configurationHelper.fromFile("/home/user/path")).thenReturn(config); GoogleClientSecretsForApiBuilder builder = new GoogleClientSecretsForApiBuilder( configurationHelper, GoogleClientSecretsBuilder.Api.AD_MANAGER); thrown.expect(ValidationException.class); thrown.expectMessage( "Client secret must be set as api.admanager.clientSecret in /home/user/path." + "\nIf you do not have a client ID or secret, please create one in the API " + "console: https://console.developers.google.com"); builder.fromFile("/home/user/path").build(); }
/** * Tests that the builder correctly identifies the file path. */ @Test public void testReadPropertiesFromFile_clientIdTokenBadWithFilePath() throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.admanager.clientSecret", "clientSecret"); config.setProperty("api.admanager.refreshToken", "refreshToken"); when(configurationHelper.fromFile("/home/user/path")).thenReturn(config); GoogleClientSecretsForApiBuilder builder = new GoogleClientSecretsForApiBuilder( configurationHelper, GoogleClientSecretsBuilder.Api.AD_MANAGER); thrown.expect(ValidationException.class); thrown.expectMessage( "Client ID must be set as api.admanager.clientId in /home/user/path." + "\nIf you do not have a client ID or secret, please create one in the API " + "console: https://console.developers.google.com"); builder.fromFile("/home/user/path").build(); }
/** * Tests that the builder correctly reads from a file. */ @Test public void testGoogleSecretsReadPropertiesFromFile() throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.admanager.clientId", "clientId"); config.setProperty("api.admanager.clientSecret", "clientSecret"); when(configurationHelper.fromFile("path")).thenReturn(config); GoogleClientSecretsForApiBuilder builder = new GoogleClientSecretsForApiBuilder( configurationHelper, GoogleClientSecretsBuilder.Api.AD_MANAGER); GoogleClientSecrets googleClientSecrets = builder.fromFile("path").build(); assertEquals("clientId", googleClientSecrets.getInstalled().getClientId()); assertEquals("clientSecret", googleClientSecrets.getInstalled().getClientSecret()); }
@Override public GoogleClientSecretsForApiBuilder fromFile() throws ConfigurationLoadException { return fromFile(com.google.api.ads.common.lib.utils.Builder.DEFAULT_CONFIGURATION_FILENAME); }
@Override public GoogleClientSecretsForApiBuilder fromFile() throws ConfigurationLoadException { return fromFile(com.google.api.ads.common.lib.utils.Builder.DEFAULT_CONFIGURATION_FILENAME); }