Skip to content

Suppress InsecureRequestWarning if SSL verification is disabled #499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd
- Changed datatype of "amount" from String to numeric for "Transaction" vertices in Fraud Graph sample notebook ([Link to PR](https://github.com/aws/graph-notebook/pull/489))
- Replaced usages of deprecated DataFrame.append method in ML samples ([Link to PR](https://github.com/aws/graph-notebook/pull/495))
- Set Gremlin as default language for PropertyGraph samples in `%seed` ([Link to PR](https://github.com/aws/graph-notebook/pull/497))
- Suppress InsecureRequestWarning if SSL verification is disabled ([Link to PR](https://github.com/aws/graph-notebook/pull/499))

## Release 3.8.1 (April 17, 2023)
- Reinstate Python 3.7 support for compatibility with legacy AL1 Neptune Notebooks ([Link to PR](https://github.com/aws/graph-notebook/pull/479))
Expand Down
3 changes: 3 additions & 0 deletions src/graph_notebook/neptune/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import re

import requests
import urllib3
from urllib.parse import urlparse, urlunparse
from SPARQLWrapper import SPARQLWrapper
from boto3 import Session
Expand Down Expand Up @@ -146,6 +147,8 @@ def __init__(self, host: str, port: int = DEFAULT_PORT, ssl: bool = True, ssl_ve
self.target_port = port
self.ssl = ssl
self.ssl_verify = ssl_verify
if not self.ssl_verify:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
self.sparql_path = sparql_path
self.gremlin_traversal_source = gremlin_traversal_source
self.gremlin_username = gremlin_username
Expand Down
19 changes: 19 additions & 0 deletions test/unit/configuration/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ def test_generate_configuration_override_defaults_neptune_reg(self):
config_from_file = get_config(self.test_file_path)
self.assertEqual(config.to_dict(), config_from_file.to_dict())

def test_generate_configuration_override_defaults_neptune_no_verify(self):
auth_mode = AuthModeEnum.IAM
ssl = True
ssl_verify = False
loader_arn = 'foo'
aws_region = 'us-iso-east-1'
config = Configuration(self.neptune_host_reg, self.port, auth_mode=auth_mode,
load_from_s3_arn=loader_arn,
ssl=ssl, ssl_verify=ssl_verify,
aws_region=aws_region)

c = generate_config(config.host, config.port, auth_mode=config.auth_mode,
load_from_s3_arn=config.load_from_s3_arn,
ssl=config.ssl, ssl_verify=config.ssl_verify,
aws_region=config.aws_region)
c.write_to_file(self.test_file_path)
config_from_file = get_config(self.test_file_path)
self.assertEqual(config.to_dict(), config_from_file.to_dict())

def test_generate_configuration_override_defaults_neptune_cn(self):
auth_mode = AuthModeEnum.IAM
ssl = False
Expand Down
16 changes: 13 additions & 3 deletions test/unit/configuration/test_configuration_from_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def test_generate_configuration_main_override_defaults_neptune_reg(self):
load_from_s3_arn='loader_arn', ssl=False)
self.generate_config_from_main_and_test(expected_config, host_type='neptune')

def test_generate_configuration_main_override_defaults_neptune_no_verify(self):
expected_config = Configuration(self.neptune_host_reg, self.port, auth_mode=AuthModeEnum.IAM,
load_from_s3_arn='loader_arn', ssl=True, ssl_verify=False)
self.generate_config_from_main_and_test(expected_config, host_type='neptune')

def test_generate_configuration_main_override_defaults_neptune_cn(self):
expected_config = Configuration(self.neptune_host_cn, self.port, auth_mode=AuthModeEnum.IAM,
load_from_s3_arn='loader_arn', ssl=False)
Expand Down Expand Up @@ -95,8 +100,11 @@ def generate_config_from_main_and_test(self, source_config: Configuration, host_
# Configuration object we get from the resulting file is what we expect.
if host_type == 'neptune':
result = os.system(f'{self.python_cmd} -m graph_notebook.configuration.generate_config '
f'--host "{source_config.host}" --port "{source_config.port}" '
f'--auth_mode "{source_config.auth_mode.value}" --ssl "{source_config.ssl}" '
f'--host "{source_config.host}" '
f'--port "{source_config.port}" '
f'--auth_mode "{source_config.auth_mode.value}" '
f'--ssl "{source_config.ssl}" '
f'--ssl-verify "{source_config.ssl_verify}" '
f'--load_from_s3_arn "{source_config.load_from_s3_arn}" '
f'--proxy_host "{source_config.proxy_host}" '
f'--proxy_port "{source_config.proxy_port}" '
Expand All @@ -106,7 +114,9 @@ def generate_config_from_main_and_test(self, source_config: Configuration, host_
f'--host "{source_config.host}" --port "{source_config.port}" '
f'--proxy_host "{source_config.proxy_host}" '
f'--proxy_port "{source_config.proxy_port}" '
f'--ssl "{source_config.ssl}" --config_destination="{self.test_file_path}" ')
f'--ssl "{source_config.ssl}" '
f'--ssl-verify "{source_config.ssl_verify}" '
f'--config_destination="{self.test_file_path}" ')
self.assertEqual(result, 0)
config = get_config(self.test_file_path)
self.assertEqual(source_config.to_dict(), config.to_dict())