How can I authenticate using the Bugzilla Perl API in a script?

Working with the Bugzilla API , I wrote a quick Perl script to clone a Bugzilla product (recreate all the components in their new product). The Bugzilla Perl API is pretty easy to use from the command line. I could just work directly with the database, but I wanted to find a longer-term solution. Another option was a web service, but I thought that this time I would try using the API.

One problem that I am facing is authenticated as my Bz admin, so I can create new components. After looking at the Bugzilla Bugzilla.pm file, I see that they just run login() from the Bugzilla :: Auth object. I am not sure how to get the username and password. I suppose I could just add a script to the Bugzilla admin interface ...

Can any of you point me in the right direction?

+4
source share
3 answers

Oh, I’m rather ignorant today, I focused on “web services” and didn’t understand what you really wanted.

If you just use the API to communicate with the database (as opposed to directly managing the database), do you really need to authenticate as any user?

In the 3.2 source tree, for example, look at merge-users.pl , which uses Bugzilla::User objects. Could you do the same with Bugzilla::Component ?

You should also look at sanitycheck.pl , which uses Bugzilla->set_user .

+2
source

Have there been significant updates to the features of web services since 3.2, can you update?

In 3.6, at least check out contrib/bz_webservice_demo.pl how to use the User.login method.

http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/User.html

+2
source

This question may include the following code snippet. Here we also verify that the user has the correct "editcomponents" credentials.

 my $user = new Bugzilla::User({ name => $login }) || ThrowUserError('invalid_username', { name => $login }); # Authenticate using this user account. Bugzilla->set_user($user); $user->in_group('editcomponents') || ThrowUserError("auth_failure", {group => "editcomponents", action => "add", object => "products"}); 
+1
source

Source: https://habr.com/ru/post/1308829/


All Articles