devopshq/artifactory

Unable to manage group's users on Artifactory SaaS

Opened this issue · 0 comments

I am using Artifactory SaaS and I am trying to create a group with users as specified in the documentation:

from artifactory import ArtifactorySaaSPath
from dohq_artifactory import Group

artifactory_ = ArtifactorySaaSPath(
                'https://mycompany.jfrog.io/artifactory',
                apikey='myApiKey123'
            )

group = artifactory_.find_group("groupname")

if group is None:
    group = Group(artifactory_, "groupname")
    group.create()

group.read()

group.users = ["admin", "anonymous"]
group.create()

The group is created but it has no user as members. I have found this working alternative though:

from artifactory import ArtifactorySaaSPath
from dohq_artifactory import Group

artifactory_ = ArtifactorySaaSPath(
                'https://mycompany.jfrog.io/artifactory',
                apikey='myApiKey123'
            )

group = artifactory_.find_group("groupname")

if group is None:
    group = Group(artifactory_, "groupname")
    group.create()

group.read()

for user in ["admin", "anonymous"]:
  user = artifactory_.find_user(user)
  user.add_to_group(group)
  user.update()

But then I have the same problem again if I want to delete all group members:

from artifactory import ArtifactorySaaSPath
from dohq_artifactory import Group

artifactory_ = ArtifactorySaaSPath(
                'https://mycompany.jfrog.io/artifactory',
                apikey='myApiKey123'
            )

group = artifactory_.find_group("groupname")

if group is None:
    group = Group(artifactory_, "groupname")
    group.create()

group.read()

group.users = []
group.update() # group.create() has the same effect

The previously added users are not removed. I set every time group.users as a list, as required by the source code, but that does not seem to work.

Has somebody else had the same issue? I am currently using dohq-artifactory 0.9.0. Thanks in advance