use of com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanConfigsPagedResponse in project java-websecurityscanner by googleapis.
the class VPCServiceControlNegativeTest method testScanConfigList.
@Test
public void testScanConfigList() throws IOException {
// try to get the list of scan configs - it must fail
WebSecurityScannerSettings wssSetting = getWssSettingWithCredentials();
final String formattedParent = ProjectName.format(OUT_VPCSC_PROJECT);
try (WebSecurityScannerClient wssClient = WebSecurityScannerClient.create(wssSetting)) {
ListScanConfigsRequest lscRequest = ListScanConfigsRequest.newBuilder().setParent(formattedParent).build();
ListScanConfigsPagedResponse scanConfigsList = wssClient.listScanConfigs(lscRequest);
fail("Exception must occur for non-acceessible project scan-configs");
} catch (PermissionDeniedException expected) {
}
}
use of com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanConfigsPagedResponse in project java-websecurityscanner by googleapis.
the class WebSecurityScannerClientTest method listScanConfigsTest.
@Test
public void listScanConfigsTest() throws Exception {
ScanConfig responsesElement = ScanConfig.newBuilder().build();
ListScanConfigsResponse expectedResponse = ListScanConfigsResponse.newBuilder().setNextPageToken("").addAllScanConfigs(Arrays.asList(responsesElement)).build();
mockWebSecurityScanner.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListScanConfigsPagedResponse pagedListResponse = client.listScanConfigs(parent);
List<ScanConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getScanConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockWebSecurityScanner.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListScanConfigsRequest actualRequest = ((ListScanConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanConfigsPagedResponse in project java-websecurityscanner by googleapis.
the class WebSecurityScannerClientTest method listScanConfigsTest2.
@Test
public void listScanConfigsTest2() throws Exception {
ScanConfig responsesElement = ScanConfig.newBuilder().build();
ListScanConfigsResponse expectedResponse = ListScanConfigsResponse.newBuilder().setNextPageToken("").addAllScanConfigs(Arrays.asList(responsesElement)).build();
mockWebSecurityScanner.addResponse(expectedResponse);
String parent = "parent-995424086";
ListScanConfigsPagedResponse pagedListResponse = client.listScanConfigs(parent);
List<ScanConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getScanConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockWebSecurityScanner.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListScanConfigsRequest actualRequest = ((ListScanConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations