Skip to content

Commit dd51a9c

Browse files
authored
Merge pull request #31 from britive/develop
v0.5.2
2 parents 9326f56 + 52715c8 commit dd51a9c

File tree

6 files changed

+28
-22
lines changed

6 files changed

+28
-22
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
All changes to the package starting with v0.3.1 will be logged here.
44

5+
## v0.5.2 [2022-10-24]
6+
#### What's New
7+
* None
8+
9+
#### Enhancements
10+
* None
11+
12+
#### Bug Fixes
13+
* Allow local machine DNS to resolve (e.g. /etc/hosts) for tenant url
14+
15+
#### Dependencies
16+
* `britive~=2.11.1` from `britive~=2.11.0`
17+
18+
#### Other
19+
* None
20+
521
## v0.5.1 [2022-10-21]
622
#### What's New
723
* None

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
britive~=2.11.0
1+
britive~=2.11.1
22
certifi==2022.6.15
33
charset-normalizer==2.1.0
44
click==8.1.3

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pybritive
3-
version = 0.5.1
3+
version = 0.5.2
44
author = Britive Inc.
55
author_email = support@britive.com
66
description = A pure Python CLI for Britive
@@ -25,7 +25,7 @@ install_requires =
2525
tabulate
2626
toml
2727
cryptography
28-
britive
28+
britive>=2.11.1
2929

3030
[options.packages.find]
3131
where = src

src/pybritive/britive_cli.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,6 @@ def __init__(self, tenant_name: str = None, token: str = None, silent: bool = Fa
3535
def set_output_format(self, output_format: str):
3636
self.output_format = self.config.get_output_format(output_format)
3737

38-
# it is preferable to do this in the sdk as a static method
39-
# as this will eliminate the duplicate code
40-
def parse_tenant(self):
41-
domain = self.tenant_name.replace('https://', '').replace('http://', '') # remove scheme
42-
domain = domain.split('/')[0] # remove any paths as they will not be needed
43-
try:
44-
domain_without_port = domain.split(':')[0]
45-
socket.gethostbyname_ex(domain_without_port) # if success then a full domain was provided
46-
return domain
47-
except socket.gaierror: # assume just the tenant name was provided (originally the only supported method)
48-
domain = f'{self.tenant_name}.britive-app.com'
49-
try:
50-
socket.gethostbyname_ex(domain) # validate the hostname is real
51-
return domain
52-
except socket.gaierror:
53-
raise Exception(f'Invalid tenant provided: {self.tenant_name}')
54-
5538
def set_credential_manager(self):
5639
if self.credential_manager:
5740
return
@@ -113,7 +96,7 @@ def logout(self):
11396
if self.token:
11497
raise click.ClickException('Logout not available when using an API token.')
11598
self.login()
116-
self.b.delete(f'https://{self.parse_tenant()}/api/auth')
99+
self.b.delete(f'https://{Britive.parse_tenant(self.tenant_name)}/api/auth')
117100
self._cleanup_credentials()
118101

119102
# will take a list of dicts and print to the screen based on the format specified in the config file

src/pybritive/helpers/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import toml
77
from ..choices.output_format import output_format_choices
88
from ..choices.backend import backend_choices
9+
from britive.britive import Britive
910

1011

1112
def extract_tenant(tenant_key):
@@ -259,6 +260,11 @@ def validate_tenant(self, section, fields):
259260
for field, value in fields.items():
260261
if field not in tenant_fields:
261262
self.validation_error_messages.append(f'Invalid {section} field {field} provided.')
263+
if field == 'name':
264+
try:
265+
Britive.parse_tenant(value)
266+
except Exception as e:
267+
raise click.ClickException(f'Error validating tenant name: {str(e)}')
262268
if field == 'output_format' and value not in output_format_choices.choices:
263269
error = f'Invalid {section} field {field} value {value} provided. Invalid value choice.'
264270
self.validation_error_messages.append(error)

src/pybritive/helpers/credentials.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import json
1111
import os
1212
from .encryption import StringEncryption, InvalidPassphraseException
13+
from britive.britive import Britive
1314

1415

1516
interactive_login_fields_to_pop = [
@@ -45,7 +46,7 @@ def __init__(self, tenant_name: str, tenant_alias: str, cli):
4546
self.cli = cli
4647
self.tenant = tenant_name
4748
self.alias = tenant_alias
48-
self.base_url = f'https://{cli.parse_tenant()}'
49+
self.base_url = f'https://{Britive.parse_tenant(tenant_name)}'
4950

5051
# not sure if we really need 32 random bytes or if any random string would work
5152
# but the current britive-cli in node.js does it this way so it will be done the same

0 commit comments

Comments
 (0)