File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 88import boto3
99import botocore
1010
11+ from aws_gate import __version__
1112from aws_gate .constants import DEFAULT_GATE_BIN_PATH , PLUGIN_NAME
1213from aws_gate .exceptions import AWSConnectionError
1314
@@ -55,6 +56,10 @@ def _create_aws_session(region_name=None, profile_name=None):
5556
5657 session = boto3 .session .Session (** kwargs )
5758
59+ # Add aws-gate version to the client user-agent
60+ # pylint: disable=protected-access
61+ session ._session .user_agent_extra += " " + "aws-gate/{}" .format (__version__ )
62+
5863 return session
5964
6065
Original file line number Diff line number Diff line change 77from hypothesis import given
88from hypothesis .strategies import lists , text
99
10+ from aws_gate import __version__
1011from aws_gate .exceptions import AWSConnectionError
1112from aws_gate .utils import (
1213 is_existing_profile ,
@@ -50,6 +51,13 @@ def test_create_aws_session(mocker):
5051 assert session_mock .Session .call_args == mocker .call (region_name = "eu-west-1" )
5152
5253
54+ def test_create_aws_session_user_agent ():
55+ session = _create_aws_session (region_name = "eu-west-1" )
56+
57+ # pylint: disable=protected-access
58+ assert "aws-gate/{}" .format (__version__ ) in session ._session .user_agent ()
59+
60+
5361def test_create_aws_session_with_profile (mocker ):
5462 session_mock = mocker .patch (
5563 "aws_gate.utils.boto3.session" , return_value = mocker .MagicMock ()
You can’t perform that action at this time.
0 commit comments