Script

ARTIFACTORY/ACCESS: Loading huge list of users into Artifactory instance for test scenarios

AuthorFullName__c
Sunil Varghese
articleNumber
000005696
ft:sourceType
Salesforce
FirstPublishedDate
2023-04-27T15:29:40Z
lastModifiedDate
2023-04-30
VersionNumber
1
  • Copy the below to a .py extension file. Go to the location of the file in a command or terminal window and use the following command “python3 file.py”. 
  • Before running please change the bearer token(inputvalueforbearertoken) based on the access token you are generating in your Artifactory instance and all the values marked as username, userpass, useremail needs to be set based on the naming conventions you follow. 

(Note :: { } entries get set with a new number while running the loop. “artinstanceurl” needs to be replaced with your Artifactory URL, Also the limit of 2000 can be increased or decreased based on your requirements)
import requests
headers = {'Content-type': 'application/json', 'Authorization': 'Bearer inputvalueforbearertoken'}
for x in range(2000):
   printstat = '{{"username": "username{}", "password": "userpass{}", "email": "useremail{}@gma.com","groups": ["readers"],"admin": false,"profile_updatable": true,"internal_password_disabled": false,"disable_ui_access": false}}"'.format(
       x, x, x)
   #API used below
   url = "https://artifactoryurl/access/api/v2/users"
   y = requests.post(url, printstat, headers=headers)
   print(y.text)