Skip to content

Commit 7a8cd49

Browse files
authored
Update CI configuration, fix spelling errors, session duration, and add Okta URL support (#98)
* Update CI configuration * Fix spelling errors (including #96) * Session duration bug (#80) * Add Okta full URL support (#65 and #82) * Fix line length, remove old setup step * Move pip upgrade to inside the venv * Version bump * Update readme * Fix link in readme
1 parent 9e30f86 commit 7a8cd49

File tree

11 files changed

+59
-31
lines changed

11 files changed

+59
-31
lines changed

.circleci/config.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies: &dependencies
88
command: |
99
python -m venv venv || virtualenv venv
1010
. venv/bin/activate
11+
pip install -U pip
1112
pip install -r requirements.txt
1213
pip install -r test_requirements.txt
1314
@@ -35,6 +36,7 @@ workflows:
3536
version: 2
3637
test:
3738
jobs:
39+
- test-3.9
3840
- test-3.8
3941
- test-3.7
4042
- test-3.6
@@ -44,7 +46,7 @@ workflows:
4446
jobs:
4547
test-2.7:
4648
docker:
47-
- image: circleci/python:2.7
49+
- image: cimg/python:2.7
4850
steps:
4951
- checkout
5052
- run: *dbus
@@ -61,19 +63,24 @@ jobs:
6163
- run: *pycodestyle
6264
- run: *pyflakes
6365
docker:
64-
- image: circleci/python:3.5
66+
- image: cimg/python:3.5
6567

6668
test-3.6:
6769
<<: *3x-template
6870
docker:
69-
- image: circleci/python:3.6
71+
- image: cimg/python:3.6
7072

7173
test-3.7:
7274
<<: *3x-template
7375
docker:
74-
- image: circleci/python:3.7
76+
- image: cimg/python:3.7
7577

7678
test-3.8:
7779
<<: *3x-template
7880
docker:
79-
- image: circleci/python:3.8
81+
- image: cimg/python:3.8
82+
83+
test-3.9:
84+
<<: *3x-template
85+
docker:
86+
- image: cimg/python:3.9

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ __pycache__
1414
.eggs/
1515
.tox/
1616
.python-version
17+
.DS_Store

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Apache](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/nathan-v/aws_okta_keyman/blob/master/LICENSE.txt) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman?ref=badge_shield) [![Python versions](https://img.shields.io/pypi/pyversions/aws-okta-keyman.svg)](https://pypi.python.org/pypi/aws-okta-keyman/) ![PyPI - Implementation](https://img.shields.io/pypi/implementation/aws-okta-keyman) [![Downloads](http://pepy.tech/badge/aws-okta-keyman)](http://pepy.tech/count/aws-okta-keyman)
1+
[![Apache](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/nathan-v/aws_okta_keyman/blob/master/LICENSE.txt) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnathan-v%2Faws_okta_keyman?ref=badge_shield) [![Python versions](https://img.shields.io/pypi/pyversions/aws-okta-keyman.svg)](https://pypi.python.org/pypi/aws-okta-keyman/) ![PyPI - Implementation](https://img.shields.io/pypi/implementation/aws-okta-keyman) [![Downloads](http://pepy.tech/badge/aws-okta-keyman)](https://pepy.tech/project/aws_okta_keyman)
22

33
[![Requirements Status](https://pyup.io/repos/github/nathan-v/aws_okta_keyman/shield.svg?t=1580777582434)](https://pyup.io/repos/github/nathan-v/aws_okta_keyman/) ![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/nathan-v/aws_okta_keyman) ![Code Climate issues](https://img.shields.io/codeclimate/issues/nathan-v/aws_okta_keyman) ![Code Climate technical debt](https://img.shields.io/codeclimate/tech-debt/nathan-v/aws_okta_keyman) ![Codecov](https://img.shields.io/codecov/c/gh/nathan-v/aws_okta_keyman) ![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/nathan-v/aws_okta_keyman)
44

@@ -37,10 +37,10 @@ Benefits vs other similar tools:
3737
* No API keys required; just your Okta username and password
3838
* No analytics or metrics collection; this tool does _not_ call home in any way
3939
* Open source distributed as source; you can see what you're running
40-
* Wide Python version support; works on Python 2.7.4+ and 3.5.0+.
40+
* Wide Python version support; works on Python 2.7.4+ and 3.5.0+. (v 0.8.x)
4141

4242
### Optional MFA Authentication
43-
If you organization or integration requires MFA we will automatically detect that
43+
If your organization or integration requires MFA we will automatically detect that
4444
requirement during authentication and prompt the user to complete the
4545
Multi Factor Authentication.
4646

aws_okta_keyman/aws.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __init__(self,
118118
profile='default',
119119
region='us-east-1',
120120
role=None,
121-
session_duration=3600):
121+
session_duration=None):
122122
cred_dir = os.path.expanduser(credential_path)
123123
cred_file = os.path.join(cred_dir, 'credentials')
124124

@@ -145,7 +145,10 @@ def __init__(self,
145145
'Expiration': None}
146146
self.session_token = None
147147
self.role = role
148-
self.duration = session_duration
148+
if session_duration:
149+
self.duration = session_duration
150+
else:
151+
self.duration = 3600
149152
self.available_roles()
150153

151154
@property
@@ -318,7 +321,7 @@ def account_ids_to_names(self, roles):
318321
try:
319322
accounts = self.get_account_name_map()
320323
except Exception:
321-
msg = ('Error retreiving AWS account name/ID map. '
324+
msg = ('Error retrieving AWS account name/ID map. '
322325
'Falling back to just account IDs')
323326
LOG.warning(msg)
324327
return roles

aws_okta_keyman/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ def main_args(arg_group, required=False):
187187
help=(
188188
'Okta Organization Name - ie, if your '
189189
'login URL is https://foobar.okta.com, '
190-
'enter in foobar here'
190+
'enter in foobar here or you may use'
191+
'the complete URL.'
191192
),
192193
required=required)
193194

@@ -282,11 +283,11 @@ def optional_args(optional_args):
282283
'by AWS the default of 3600s (one '
283284
'hour) will be used.'
284285
),
285-
default=3600)
286+
default=None)
286287
optional_args.add_argument('-co', '--console',
287288
action='store_true', help=(
288289
'Output AWS Console URLs to log in '
289-
'and use the web conle with the '
290+
'and use the web console with the '
290291
'selected role..'
291292
),
292293
default=False)
@@ -353,7 +354,7 @@ def write_config(self):
353354

354355
file_folder = os.path.dirname(os.path.abspath(file_path))
355356
if not os.path.exists(file_folder):
356-
LOG.debug("Creating missin config file folder : {}".format(
357+
LOG.debug("Creating missing config file folder : {}".format(
357358
file_folder))
358359
os.makedirs(file_folder)
359360

aws_okta_keyman/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# Copyright 2018 Nathan V
1515
"""Package metadata."""
1616

17-
__version__ = '0.8.5'
17+
__version__ = '0.8.6'
1818
__desc__ = 'AWS Okta Keyman'

aws_okta_keyman/okta.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,14 @@ class Okta(object):
9292

9393
def __init__(self, organization, username, password, duo_factor=None,
9494
oktapreview=False):
95-
if oktapreview:
96-
self.base_url = PREVIEW_BASE_URL.format(organization=organization)
95+
if organization and "https://" not in organization:
96+
if oktapreview:
97+
url = PREVIEW_BASE_URL.format(organization=organization)
98+
self.base_url = url
99+
else:
100+
self.base_url = BASE_URL.format(organization=organization)
97101
else:
98-
self.base_url = BASE_URL.format(organization=organization)
102+
self.base_url = organization
99103

100104
LOG.debug('Base URL Set to: {url}'.format(url=self.base_url))
101105

@@ -144,7 +148,7 @@ def _request(self, path, data=None):
144148
def set_token(self, ret):
145149
"""Parse an authentication response, get a long-lived token, store it
146150
Parses a SUCCESSFUL authentication response from Okta to get the
147-
one time use token, requests a long-lived sessoin token from Okta, and
151+
one time use token, requests a long-lived session token from Okta, and
148152
stores the new token.
149153
Args:
150154
ret: The response from Okta that we know is successful and contains

aws_okta_keyman/test/aws_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ def test_init_folder_exists(self, exists_mock, _makedirs_mock,
152152

153153
exists_mock.assert_has_calls([mock.call('/home/fakeuser')])
154154

155+
@mock.patch('os.path.expanduser')
156+
@mock.patch('os.makedirs')
157+
@mock.patch('os.path.exists')
158+
def test_init_with_duration(self, exists_mock, _makedirs_mock,
159+
expuser_mock):
160+
exists_mock.return_value = True
161+
expuser_mock.return_value = '/home/fakeuser'
162+
163+
aws.Session('BogusAssertion', session_duration=6000)
164+
165+
exists_mock.assert_has_calls([mock.call('/home/fakeuser')])
166+
155167
def test_is_valid_false(self):
156168
session = aws.Session('BogusAssertion')
157169

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
beautifulsoup4>=4.4.0
1+
beautifulsoup4~=4.9.0
22
colorlog>=4.0.0
33
requests>=2.10.0
44
boto3>=1.4.0
55
future>=0.16.0
66
configparser>=3.5.0
7-
PyYAML>=5.0
8-
keyring>=18.0.0; python_version == '3.*'
7+
PyYAML~=5.3.0
8+
keyring>=20.0.0; python_version == '3.*'
99
keyring~=18.0.0; python_version == '2.7' # pyup: ignore
1010
SecretStorage>=2.3.1; python_version == '2.7'
1111
dbus-python>=1.2.12; python_version == '2.7' and sys_platform == 'linux2'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def run_tests(self):
116116
packages=find_packages(),
117117
test_suite='pytest',
118118
tests_require=open("{}/test_requirements.txt".format(DIR)).readlines(),
119-
setup_requires=['pytest-runner'],
120119
install_requires=open("{}/requirements.txt".format(DIR)).readlines(),
121120
entry_points={
122121
'console_scripts': [
@@ -135,6 +134,7 @@ def run_tests(self):
135134
'Programming Language :: Python :: 3.6',
136135
'Programming Language :: Python :: 3.7',
137136
'Programming Language :: Python :: 3.8',
137+
'Programming Language :: Python :: 3.9',
138138
'Operating System :: MacOS :: MacOS X',
139139
'Operating System :: Microsoft :: Windows',
140140
'Operating System :: POSIX',

test_requirements.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
pytest>=4.6.0
2-
pytest-cov>=2.8.0
3-
coverage==5.2
4-
mock>=3.0.0
5-
pycodestyle>=2.5.0
6-
pyflakes>=2.1.0
7-
codecov>=2.0.0
1+
pytest~=4.6.0
2+
pytest-cov~=2.12.0
3+
coverage~=5.5.0
4+
mock~=3.0.0
5+
pycodestyle~=2.8.0
6+
pyflakes~=2.4.0
7+
codecov~=2.1.0

0 commit comments

Comments
 (0)