Skip to content

Commit

Permalink
removed trailing whitespace
Browse files Browse the repository at this point in the history
Signed-off-by: Chinmay Gadgil <[email protected]>
  • Loading branch information
cgchinmay committed Oct 11, 2023
1 parent abd217a commit c1d6505
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions osbenchmark/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ def __init__(self, cfg):
client_options["basic_auth_user"] = user
client_options["basic_auth_password"] = password

# add options for aws user login:
# add options for aws user login:
# pass in aws access key id, aws secret access key, aws session token, service and region on command
if metrics_amazon_aws_log_in is not None:
client_options["amazon_aws_log_in"] = 'client_option'
client_options["aws_access_key_id"] = metrics_aws_access_key_id
client_options["aws_secret_access_key"] = metrics_aws_secret_access_key
client_options["service"] = metrics_aws_service
client_options["region"] = metrics_aws_region

if metrics_aws_session_token:
client_options["aws_session_token"] = metrics_aws_session_token

Expand Down
20 changes: 10 additions & 10 deletions tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,24 @@ def test_create_https_connection_with_aws_creds(self, mocked_load_cert_chain):
"region": "us-east-1",
"verify_certs": True
}

role_based_client_options = dict(user_based_client_options)
role_based_client_options["aws_session_token"] = "dummy_token"

client_options_list = [
user_based_client_options,
role_based_client_options
]

logger = logging.getLogger("osbenchmark.client")

for client_options in client_options_list:
# make a copy so we can verify later that the factory did not modify it
original_client_options = dict(client_options)

with mock.patch.object(logger, "info") as mocked_info_logger:
f = client.OsClientFactory(hosts, client_options)

mocked_info_logger.assert_has_calls([
mock.call("SSL support: on"),
mock.call("SSL certificate verification: on"),
Expand All @@ -297,13 +297,13 @@ def test_create_https_connection_with_aws_creds(self, mocked_load_cert_chain):
self.assertIn("amazon_aws_log_in", f.client_options)
self.assertIn("service", f.client_options)
self.assertIn("region", f.client_options)

if "aws_session_token" in original_client_options:
self.assertIn("aws_session_token", f.client_options)

self.assertDictEqual(original_client_options, client_options)


@mock.patch.object(ssl.SSLContext, "load_cert_chain")
def test_create_https_connection_unverified_certificate_present_client_certificates(self, mocked_load_cert_chain):
hosts = [{"host": "localhost", "port": 9200}]
Expand Down
20 changes: 10 additions & 10 deletions tests/metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ def test_config_opts_parsing_aws_creds_with_env(self, client_OsClientfactory):
}
self.config_opts_parsing_aws_creds("environment", override_datastore=override_config)



# validate client_options when session_token is passed
enable_role_access = [False, True]
for role_based in enable_role_access:
# verify config parsing is successful when all required parameters are present
config_opts = self.config_opts_parsing_aws_creds("environment", role_based=role_based)

expected_client_options = {
"use_ssl": True,
"timeout": 120,
Expand All @@ -257,15 +257,15 @@ def test_config_opts_parsing_aws_creds_with_env(self, client_OsClientfactory):
"region": config_opts["_datastore_aws_region"],
"verify_certs": config_opts["_datastore_verify_certs"]
}

if role_based:
expected_client_options["aws_session_token"] = config_opts["_datastore_aws_session_token"]

client_OsClientfactory.assert_called_with(
hosts=[{"host": config_opts["_datastore_host"], "port": config_opts["_datastore_port"]}],
client_options=expected_client_options
)


def config_opts_parsing(self, password_configuration):
cfg = config.Config()
Expand Down Expand Up @@ -327,7 +327,7 @@ def config_opts_parsing_aws_creds(self, configuration_source, override_datastore
_datastore_aws_secret_access_key = "".join([random.choice(string.ascii_letters + string.digits) for _ in range(40)])
_datastore_aws_service = random.choice(['es', 'aoss'])
_datastore_aws_region = random.choice(['us-east-1', 'eu-west-1'])

# optional
_datastore_aws_session_token = "".join([random.choice(string.ascii_letters + string.digits) for _ in range(752)])

Expand Down Expand Up @@ -391,7 +391,7 @@ def config_opts_parsing_aws_creds(self, configuration_source, override_datastore
"'environment' or 'config'"
assert e.message == missing_aws_credentials_message
return

response = {
"_datastore_user": _datastore_user,
"_datastore_host": _datastore_host,
Expand All @@ -403,10 +403,10 @@ def config_opts_parsing_aws_creds(self, configuration_source, override_datastore
"_datastore_aws_service": _datastore_aws_service,
"_datastore_aws_region": _datastore_aws_region
}

if role_based:
response["_datastore_aws_session_token"] = _datastore_aws_session_token

return response

def test_raises_sytem_setup_error_on_connection_problems(self):
Expand Down

0 comments on commit c1d6505

Please sign in to comment.