Skip to content

Commit

Permalink
Clean dependencies (#54)
Browse files Browse the repository at this point in the history
Co-authored-by: Yaroslav Kudrin <Iaroslav_Kudrin@epam.com>
  • Loading branch information
kudrinyaroslav and Yaroslav Kudrin committed Aug 25, 2021
1 parent 820f774 commit b8c5bf8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
boto3>=1.9.0
requests>=2.19.0
configparser>=3.5.0
pyOpenSSL>=18.0.0
beautifulsoup4>=4.6.0
lxml>=4.3.0
tzlocal==2.1
beautifulsoup4>=4.6.0
7 changes: 3 additions & 4 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,11 @@ def test_collect_integer(mocker, value, expected):

def test_utc_to_local():
"""Check if passed utc datestamp becomes local one."""
import pytz
from tokendito import helpers
from tzlocal import get_localzone
from datetime import timezone

utc = datetime.now(pytz.utc)
local_time = utc.replace(tzinfo=pytz.utc).astimezone(tz=get_localzone())
utc = datetime.utcnow()
local_time = utc.replace(tzinfo=timezone.utc).astimezone(tz=None)
local_time = local_time.strftime("%Y-%m-%d %H:%M:%S %Z")

assert helpers.utc_to_local(utc) == local_time
Expand Down
2 changes: 1 addition & 1 deletion tokendito/__version__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vim: set filetype=python ts=4 sw=4
# -*- coding: utf-8 -*-
"""tokendito version."""
__version__ = "1.3.0"
__version__ = "2.0.0"
__title__ = "tokendito"
__description__ = "Get AWS STS tokens from Okta SSO"
__long_description_content_type__ = "text/x-rst"
Expand Down
7 changes: 3 additions & 4 deletions tokendito/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import argparse
import codecs
import configparser
from datetime import timezone
import getpass
import json
import logging
Expand All @@ -16,11 +17,9 @@
from botocore import __version__ as __botocore_version__
from bs4 import __version__ as __bs4_version__
from bs4 import BeautifulSoup
import pytz
import requests
from tokendito import settings
from tokendito.__version__ import __version__
from tzlocal import get_localzone


def setup(args):
Expand Down Expand Up @@ -113,7 +112,7 @@ def utc_to_local(utc_dt):
:param:utc_str:datetime
:return:local_time:string
"""
local_time = utc_dt.replace(tzinfo=pytz.utc).astimezone(tz=get_localzone())
local_time = utc_dt.replace(tzinfo=timezone.utc).astimezone(tz=None)
local_time = local_time.strftime("%Y-%m-%d %H:%M:%S %Z")

return local_time
Expand Down Expand Up @@ -369,7 +368,7 @@ def extract_arns(saml):
"""
logging.debug("Decode response string as a SAML decoded value.")

soup = BeautifulSoup(saml, "xml")
soup = BeautifulSoup(saml, "html.parser")
arns = soup.find_all(text=re.compile("arn:aws:iam::"))
if len(arns) == 0:
logging.error("No IAM roles found in SAML response.")
Expand Down

0 comments on commit b8c5bf8

Please sign in to comment.