Skip to content

MM-27 added team creation and user assignment functionality in deline… - #2472

Closed
mkanadi-ks wants to merge 1 commit into
feature/mm-5-phase-onefrom
feature/mm-27-enhance-team-creation-in-delinea-import
Closed

mkanadi-ks wants to merge 1 commit into
feature/mm-5-phase-onefrom
feature/mm-27-enhance-team-creation-in-delinea-import

Conversation

@mkanadi-ks

@mkanadi-ks mkanadi-ks commented Oct 29, 2026 •

Copy link
Copy Markdown

Summary
Adds a feature of team creation and user assignment in delinea import

Changes
Added "--add-teams" flag to enable team creation during import.
Implemented comprehensive test cases for the new team creation logic.

Comment thread unit-tests/test_thycotic_add_users.py Resolved
Comment thread unit-tests/test_thycotic_add_teams.py Resolved
f'/v1/secrets/lookup?filter.folderId={folder_id}'
f'&filter.includeSubFolders=true&filter.includeRestricted={restricted}'
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

self._create_enterprise_users(params, thycotic_users)

def _prepare_thycotic_groups(self, auth): # type: (ThycoticAuth) -> List[dict]
"""Fetch enabled Delinea groups and their direct user members.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a broader system level, we should also separate this team management part into a separate module or mixin, this should not be tightly coupled to thycotic

Comment on lines +725 to +733
ec_private_key, ec_public_key = crypto.generate_ec_key()
request['ecc_private_key'] = utils.base64_url_encode(
crypto.encrypt_aes_v2(crypto.unload_ec_private_key(ec_private_key), team_key))
request['ecc_public_key'] = utils.base64_url_encode(crypto.unload_ec_public_key(ec_public_key))
if not getattr(params, 'forbid_rsa', False):
rsa_private_key, rsa_public_key = crypto.generate_rsa_key()
request['private_key'] = utils.base64_url_encode(
crypto.encrypt_aes_v1(crypto.unload_rsa_private_key(rsa_private_key), team_key))
request['public_key'] = utils.base64_url_encode(crypto.unload_rsa_public_key(rsa_public_key))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better to separate the crypto things from here
we should not tightly couple it

also the json assembly

these should be common abstractions, not tied to any single lifecycle

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created seperated helper function for this

Comment on lines +836 to +842
return {
'added': added,
'queued': queued,
'already': already_count,
'missing': len(missing),
'failed': failed,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would a dataclass work better here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with a dataclass

user_ids = []
if (group.get('memberCount') or 0) > 0:
try:
member_rs = auth.thycotic_search(f'/v1/groups/{group_id}/users')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this fails, we should stop, else we create empty teams on keeper

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated logic so that Empty teams wont be created if user fetch fails

logging.warning('\'%s\' team is not created: %s', name, message or 'no response')
if created:
try:
api.query_enterprise(params)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you already call this in load existing users?
can we avoid duplicate calls? or is it needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is removed now.

Comment on lines +887 to +891
try:
request, team_key = self._build_team_add_request(params, name, node_id)
except Exception as e:
logging.warning('Could not prepare Keeper team "%s": %s', name, e)
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that is an error
but if it's encryption key missing error
we will continue to process and fail while looping
it's better to fail faster

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled this with MissingTeamEncryptionKey

@ajaiswal-ks
ajaiswal-ks force-pushed the feature/mm-5-phase-one branch from f058402 to 299e133 Compare October 30, 2026 06:05
@ajaiswal-ks
ajaiswal-ks force-pushed the feature/mm-27-enhance-team-creation-in-delinea-import branch from bb7cdc2 to da2cbb7 Compare October 30, 2026 06:20
@ajaiswal-ks
ajaiswal-ks force-pushed the feature/mm-27-enhance-team-creation-in-delinea-import branch from da2cbb7 to 299e133 Compare October 30, 2026 06:22
Added `"add-teams"` flag to support creating keeper teams in delinea import
Added test cases for add teams feature
@mkanadi-ks mkanadi-ks reopened this Oct 30, 2026
@mkanadi-ks mkanadi-ks closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants