amadib
amadib

Reputation: 878

Testing Artifactory Credentials

Is there a way to test artifactory credentials and if I can successfully access a repository? running from the command line I cannot see if the credentials are used and from a browser with the ?trace appended to the url denies the anonymous user access.

Upvotes: 6

Views: 10774

Answers (2)

Kuchara
Kuchara

Reputation: 705

if ! curl --fail-with-body --noproxy '*' --netrc --head 'https://<artifactory-url>:8080/artifactory/api/npm/auth' ; then
    # handle error here
fi

In my case:

  • using .netrc to keep information about credentials;
  • artifactory is behind nginx proxy;
  • accepted answer does not work, as it returns HTTP 404 when there are no builds[1].

Above curl command works like this:

  • For wrong credentials, HTTP 401 is returned.
  • For anonymous call, HTTP 400 is returned.
  • For correct credentials, HTTP 200 is returned.

[1]

{
  "errors" : [ {
    "status" : 404,
    "message" : "No builds were found"
  } ]
}

Upvotes: 0

Adil B
Adil B

Reputation: 16778

You could make use of the Artifactory REST API to test your credentials. Access it from the command line via the curl command:

curl -u myUser:myP455w0rd! -X GET "http://<artifactory-url>:8080/artifactory/api/build"

If your credentials are correct, this should show you all builds in Artifactory.

Upvotes: 5

Related Questions