Search in sources :

Example 1 with WebSecurityScannerSettings

use of com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings 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) {
    }
}
Also used : ListScanConfigsRequest(com.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest) WebSecurityScannerSettings(com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings) WebSecurityScannerClient(com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient) ListScanConfigsPagedResponse(com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanConfigsPagedResponse) PermissionDeniedException(com.google.api.gax.rpc.PermissionDeniedException) Test(org.junit.Test)

Example 2 with WebSecurityScannerSettings

use of com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings in project java-websecurityscanner by googleapis.

the class VPCServiceControlNegativeTest method testScanConfigCreation.

@Test
public void testScanConfigCreation() throws IOException {
    WebSecurityScannerSettings wssSetting = getWssSettingWithCredentials();
    final String formattedParent = ProjectName.format(OUT_VPCSC_PROJECT);
    try (WebSecurityScannerClient wssClient = WebSecurityScannerClient.create(wssSetting)) {
        ScanConfig scanConfig = ScanConfig.newBuilder().addAllStartingUrls(Lists.newArrayList(OUT_VPCSC_HOSTNAME)).setDisplayName(testScanConfigCreationDisplayName).build();
        CreateScanConfigRequest request = CreateScanConfigRequest.newBuilder().setParent(formattedParent).setScanConfig(scanConfig).build();
        ScanConfig responseScanConfig = wssClient.createScanConfig(request);
        fail("Exception must occur for non-accessible project");
    } catch (PermissionDeniedException expected) {
    }
}
Also used : WebSecurityScannerSettings(com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings) WebSecurityScannerClient(com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient) ScanConfig(com.google.cloud.websecurityscanner.v1beta.ScanConfig) CreateScanConfigRequest(com.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest) PermissionDeniedException(com.google.api.gax.rpc.PermissionDeniedException) Test(org.junit.Test)

Aggregations

PermissionDeniedException (com.google.api.gax.rpc.PermissionDeniedException)2 WebSecurityScannerClient (com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient)2 WebSecurityScannerSettings (com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings)2 Test (org.junit.Test)2 CreateScanConfigRequest (com.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest)1 ListScanConfigsRequest (com.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest)1 ScanConfig (com.google.cloud.websecurityscanner.v1beta.ScanConfig)1 ListScanConfigsPagedResponse (com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanConfigsPagedResponse)1