Add full environment creation capabilities to XMLRPC API

RESOLVED FIXED

Status

Testopia
API
--
enhancement
RESOLVED FIXED
10 years ago
9 years ago

People

(Reporter: Robert Nelson, Assigned: Greg Hendricks)

Tracking

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.1; .NET CLR 3.0.04506.648)
Build Identifier: 

Needed a way to create test environments, with all their elements, properties, and values, through the XMLRPC API. Spoke with Gregory about adding capability via the mozilla.support.webtools Google group on June 9. He suggested that I share any solution I come up with. I am attaching a patch that provided me with the solution.

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
(Reporter)

Comment 1

10 years ago
Created attachment 327666 [details] [diff] [review]
changes to WebService/Testopia/Environment.pm and Testopia/Environment.pm
Attachment #327666 - Flags: review?(ghendricks)
(Assignee)

Comment 2

10 years ago
Comment on attachment 327666 [details] [diff] [review]
changes to WebService/Testopia/Environment.pm and Testopia/Environment.pm

A few questions:
Why restore get_elements_for_environment ? I don't see it used anywhere?

I am really trying to get rid of the store methods, is there any reason not to use the create method? 

Is there any reason for not moving this into the Main Environment module and then have the API do a simple call into it? I think it would be better to not expose these private methods this way.

I like the direction this is going though. What do you think?
(Reporter)

Comment 3

10 years ago
Created attachment 327807 [details] [diff] [review]
after refactoring code

Made all the changes you requested. Tested and still works. Also fixed a bug by putting a colon after the environment basename to avoid rcauto3: matching rcauto33:, etc.
Attachment #327807 - Flags: review?(ghendricks)
(Reporter)

Comment 4

10 years ago
Created attachment 327811 [details] [diff] [review]
fixed minor bug - otherwise, same as "after refactoring code"

found another minor bug that wasn't making sure yday was three characters wide, which would be a factor in sorting for days < 100.
Attachment #327807 - Attachment is obsolete: true
Attachment #327811 - Flags: review?(ghendricks)
Attachment #327807 - Flags: review?(ghendricks)
(Assignee)

Comment 5

10 years ago
Comment on attachment 327811 [details] [diff] [review]
fixed minor bug - otherwise, same as "after refactoring code"

This is working nicely. There were a couple of typos in the perldoc and I think we should compress them a bit (less whitespace) but I will fix those on checkin.

One very important thing for future reference: 

>+sub create_full {
>+	my $self = shift;
>+	my ($env_basename, $prod_id, $environment) = @_;
>+
>+	Bugzilla->login(LOGIN_REQUIRED);

There need to be a check that the user has rights to edit the product before creating environments. I will add this on checkin this time, but this could open security holes. The line I am adding looks like:

          ThrowUserError('testopia-read-only', {'object' => $product}) unless $product->canedit;

>+
>+        my $env_id = Bugzilla::Testopia::Environment->create_full($env_basename, $prod_id, $environment);
>+
>+	return $env_id;
>+}	
>+
Attachment #327811 - Flags: review?(ghendricks) → review+
(Assignee)

Comment 6

10 years ago
Good work!

cvs ci -m "Bug 443013 – Add full environment creation capabilities to XMLRPC API
Patch by rnelson@ciprico.com r=ghendricks" -l "/testopia/Bugzilla/WebService/Testopia/Environment.pm" "/testopia/testopia/contrib/drivers/perl/client.pl" "/testopia/Bugzilla/Testopia/Environment.pm"
    Checking in testopia/contrib/drivers/perl/client.pl;
    /cvsroot/mozilla/webtools/testopia/testopia/contrib/drivers/perl/client.pl,v  <--  client.pl
    new revision: 1.12; previous revision: 1.11
    done
    Checking in Bugzilla/WebService/Testopia/Environment.pm;
    /cvsroot/mozilla/webtools/testopia/Bugzilla/WebService/Testopia/Environment.pm,v  <--  Environment.pm
    new revision: 1.15; previous revision: 1.14
    done
    Checking in Bugzilla/Testopia/Environment.pm;
    /cvsroot/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm,v  <--  Environment.pm
    new revision: 1.30; previous revision: 1.29
    done
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → FIXED
(Assignee)

Updated

9 years ago
Attachment #327666 - Flags: review?(ghendricks) → review-
You need to log in before you can comment on or make changes to this bug.