devopshq / artifactory

dohq-artifactory: a Python client for Artifactory
https://devopshq.github.io/artifactory/
MIT License
270 stars 137 forks source link

Password generator broken + create api key issue #397

Closed Sajitus closed 1 year ago

Sajitus commented 1 year ago

Hello! First of all great job on this module, it's amazing!

First issue - Password generator: Lately Jfrog changed their password policy and you need lower letter + upper letter + digits + punctuation mark for the password, your module only provides lower and upper letter, I've modified it as follows:

def _new_function_with_secret_module(pw_len=16):
    import secrets
    characters = string.ascii_letters + string.digits + string.punctuation
    return "".join(secrets.choice(characters) for i in range(pw_len))

generate_password = _new_function_with_secret_module

Second issue - Create api key: So I'm trying to create an API key as per your documentation and I'm getting the following error: dohq_artifactory_local.exception.ArtifactoryException: Please, set [self.password] before querying

Looking at the functions I can't understand where/how do I send the password to the function... Please assist if you can, this is how I send the request:

#Create User Token
user_key = User(path, username)
user_key.api_key.create()
# get Token key
user_key.api_key.get()
my_key = str(user_key.api_key)
print(my_key)
Sajitus commented 1 year ago

Found the issue with api_key, needed to do as follows:

user_key = User(path, username, password=user_password)
user_key.api_key.create()
# get Token key
user_key.api_key.get()
my_key = str(user_key.api_key)
return (my_key)
allburov commented 1 year ago

@Sajitus hi man, thank for the kind words! Could you separate issues please? It's better to work and discuss one thing at a time.

  1. If you can create pull request with the changes - it'd be great!