Skip to content

Commit cdb3531

Browse files
authored
Merge pull request #96 from britive/checkin-correct-type
checkin correct version of the profile
2 parents 94af738 + 76aba99 commit cdb3531

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
#### Bug Fixes
1313
* Fixes an issue with interactive login when randomly generated tokens include `--` which the WAF sometimes sees as a SQL injection attack
14-
* Fix an issue with `ssh-add` and temporary keys filling up the `ssh-agent` due to the order of command flags
14+
* Fixes an issue with `ssh-add` and temporary keys filling up the `ssh-agent` due to the order of command flags
15+
* Fixes and issue with `checkin` checking in the wrong profile type (programmatic vs console)
1516

1617
#### Dependencies
1718
* None

src/pybritive/britive_cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def __get_cloud_credential_printer(self, app_type, console, mode, profile, silen
377377
cli=self
378378
)
379379

380-
def checkin(self, profile):
380+
def checkin(self, profile, console):
381381
self.login()
382382
self._set_available_profiles()
383383
parts = self._split_profile_into_parts(profile)
@@ -388,18 +388,21 @@ def checkin(self, profile):
388388
application_name=parts['app']
389389
)
390390

391+
access_type = 'CONSOLE' if console else 'PROGRAMMATIC'
392+
391393
transaction_id = None
392394
application_type = None
393395
for checked_out_profile in self.b.my_access.list_checked_out_profiles():
394396
same_env = checked_out_profile['environmentId'] == ids['environment_id']
395397
same_profile = checked_out_profile['papId'] == ids['profile_id']
396-
if all([same_env, same_profile]):
398+
same_access_type = checked_out_profile['accessType'] == access_type
399+
if all([same_env, same_profile, same_access_type]):
397400
transaction_id = checked_out_profile['transactionId']
398401

399402
for available_profile in self.available_profiles:
400403
same_env_2 = checked_out_profile['environmentId'] == available_profile['env_id']
401404
same_profile_2 = checked_out_profile['papId'] == available_profile['profile_id']
402-
if all([same_env_2, same_profile_2]):
405+
if all([same_env_2, same_profile_2, access_type == 'PROGRAMMATIC']):
403406
application_type = available_profile['app_type'].lower()
404407
break
405408
break

src/pybritive/commands/checkin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66

77
@click.command()
88
@build_britive
9-
@britive_options(names='tenant,token,silent,passphrase,federation_provider')
9+
@britive_options(names='console,tenant,token,silent,passphrase,federation_provider')
1010
@click_smart_profile_argument
11-
def checkin(ctx, tenant, token, silent, passphrase, federation_provider, profile):
11+
def checkin(ctx, console, tenant, token, silent, passphrase, federation_provider, profile):
1212
"""Checkin a profile.
1313
1414
This command takes 1 required argument `PROFILE`. This should be a string representation of the profile
1515
that should be checked in. Format is `application name/environment name/profile name`.
1616
"""
1717
ctx.obj.britive.checkin(
18-
profile=profile
18+
profile=profile,
19+
console=console
1920
)
2021

2122

src/pybritive/options/console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
default=False,
77
is_flag=True,
88
show_default=True,
9-
help='Checkout the console access for the profile instead of programmatic access.'
9+
help='Checkout/checkin the console access for the profile instead of programmatic access.'
1010
)
1111

0 commit comments

Comments
 (0)