Ejemplo n.º 1
0
    def test_get_scan_config(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        display_name = "displayName1615086568"
        max_qps = 844445913
        expected_response = {
            "name": name_2,
            "display_name": display_name,
            "max_qps": max_qps,
        }
        expected_response = scan_config_pb2.ScanConfig(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = websecurityscanner_v1alpha.WebSecurityScannerClient()

        # Setup Request
        name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]")

        response = client.get_scan_config(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = web_security_scanner_pb2.GetScanConfigRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Ejemplo n.º 2
0
    def test_get_scan_config(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        display_name = 'displayName1615086568'
        max_qps = 844445913
        expected_response = {
            'name': name_2,
            'display_name': display_name,
            'max_qps': max_qps
        }
        expected_response = scan_config_pb2.ScanConfig(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        client = websecurityscanner_v1alpha.WebSecurityScannerClient(
            channel=channel)

        # Setup Request
        name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]')

        response = client.get_scan_config(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = web_security_scanner_pb2.GetScanConfigRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request