use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.
the class BigtableIOTest method testUsePipelineOptionsCredentialsIfNotSpecifiedInBigtableOptions.
/** Tests that credentials are used from PipelineOptions if not supplied by BigtableOptions. */
@Test
public void testUsePipelineOptionsCredentialsIfNotSpecifiedInBigtableOptions() throws Exception {
BigtableOptions options = BIGTABLE_OPTIONS.toBuilder().setCredentialOptions(CredentialOptions.defaultCredentials()).build();
GcpOptions pipelineOptions = PipelineOptionsFactory.as(GcpOptions.class);
pipelineOptions.setGcpCredential(new TestCredential());
BigtableService readService = BigtableIO.read().withBigtableOptions(options).withTableId("TEST-TABLE").getBigtableService(pipelineOptions);
BigtableService writeService = BigtableIO.write().withBigtableOptions(options).withTableId("TEST-TABLE").getBigtableService(pipelineOptions);
assertEquals(CredentialType.SuppliedCredentials, readService.getBigtableOptions().getCredentialOptions().getCredentialType());
assertEquals(CredentialType.SuppliedCredentials, writeService.getBigtableOptions().getCredentialOptions().getCredentialType());
}
use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.
the class BigtableIOTest method testDontUsePipelineOptionsCredentialsIfSpecifiedInBigtableOptions.
/** Tests that credentials are not used from PipelineOptions if supplied by BigtableOptions. */
@Test
public void testDontUsePipelineOptionsCredentialsIfSpecifiedInBigtableOptions() throws Exception {
BigtableOptions options = BIGTABLE_OPTIONS.toBuilder().setCredentialOptions(CredentialOptions.nullCredential()).build();
GcpOptions pipelineOptions = PipelineOptionsFactory.as(GcpOptions.class);
pipelineOptions.setGcpCredential(new TestCredential());
BigtableService readService = BigtableIO.read().withBigtableOptions(options).withTableId("TEST-TABLE").getBigtableService(pipelineOptions);
BigtableService writeService = BigtableIO.write().withBigtableOptions(options).withTableId("TEST-TABLE").getBigtableService(pipelineOptions);
assertEquals(CredentialType.None, readService.getBigtableOptions().getCredentialOptions().getCredentialType());
assertEquals(CredentialType.None, writeService.getBigtableOptions().getCredentialOptions().getCredentialType());
}
use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.
the class MonitoringUtilTest method testOverridesEndpointWithStagedDataflowEndpoint.
@Test
public void testOverridesEndpointWithStagedDataflowEndpoint() {
DataflowPipelineOptions options = PipelineOptionsFactory.create().as(DataflowPipelineOptions.class);
options.setProject(PROJECT_ID);
options.setGcpCredential(new TestCredential());
String stagingDataflowEndpoint = "v0neverExisted";
options.setDataflowEndpoint(stagingDataflowEndpoint);
String cancelCommand = MonitoringUtil.getGcloudCancelCommand(options, JOB_ID);
assertEquals("CLOUDSDK_API_ENDPOINT_OVERRIDES_DATAFLOW=https://dataflow.googleapis.com/v0neverExisted/ " + "gcloud beta dataflow jobs --project=someProject cancel 1234", cancelCommand);
}
use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.
the class GcsPathValidatorTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(mockGcsUtil.bucketAccessible(any(GcsPath.class))).thenReturn(true);
GcsOptions options = PipelineOptionsFactory.as(GcsOptions.class);
options.setGcpCredential(new TestCredential());
options.setGcsUtil(mockGcsUtil);
validator = GcsPathValidator.fromOptions(options);
}
use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.
the class GcsUtilTest method gcsOptionsWithTestCredential.
private static GcsOptions gcsOptionsWithTestCredential() {
GcsOptions pipelineOptions = PipelineOptionsFactory.as(GcsOptions.class);
pipelineOptions.setGcpCredential(new TestCredential());
return pipelineOptions;
}
Aggregations