Esempio n. 1
0
    def test_get_finding(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        http_method = "httpMethod820747384"
        fuzzed_url = "fuzzedUrl-2120677666"
        body = "body3029410"
        description = "description-1724546052"
        reproduction_url = "reproductionUrl-244934180"
        frame_url = "frameUrl545464221"
        final_url = "finalUrl355601190"
        tracking_id = "trackingId1878901667"
        expected_response = {
            "name": name_2,
            "http_method": http_method,
            "fuzzed_url": fuzzed_url,
            "body": body,
            "description": description,
            "reproduction_url": reproduction_url,
            "frame_url": frame_url,
            "final_url": final_url,
            "tracking_id": tracking_id,
        }
        expected_response = finding_pb2.Finding(**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.finding_path("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]",
                                   "[FINDING]")

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

        assert len(channel.requests) == 1
        expected_request = web_security_scanner_pb2.GetFindingRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Esempio n. 2
0
    def test_get_finding(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        http_method = 'httpMethod820747384'
        fuzzed_url = 'fuzzedUrl-2120677666'
        body = 'body3029410'
        description = 'description-1724546052'
        reproduction_url = 'reproductionUrl-244934180'
        frame_url = 'frameUrl545464221'
        final_url = 'finalUrl355601190'
        tracking_id = 'trackingId1878901667'
        expected_response = {
            'name': name_2,
            'http_method': http_method,
            'fuzzed_url': fuzzed_url,
            'body': body,
            'description': description,
            'reproduction_url': reproduction_url,
            'frame_url': frame_url,
            'final_url': final_url,
            'tracking_id': tracking_id
        }
        expected_response = finding_pb2.Finding(**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.finding_path('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]',
                                   '[FINDING]')

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

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