Sync with 2431

git-svn-id: svn://10.0.0.236/trunk@216268 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ghendricks%novell.com
2006-12-01 18:06:58 +00:00
parent 175ea305f7
commit ab3a43f6a6
43 changed files with 827 additions and 228 deletions

View File

@@ -51,6 +51,37 @@ RELATIONSHIPS
);
#
# Fields to include when exporting a Test Case.
#
# All _id fields but case_id are converted to a string representation.
#
@Bugzilla::Testopia::Constants::TESTCASE_EXPORT = qw(
case_id
summary
set_up
break_down
action
expected_results
alias
arguments
author_id
blocks
case_status_id
category_id
components
creation_date
default_tester_id
depends_on
isautomated
plans
priority_id
requirement
script
tags
version
);
@Bugzilla::Constants::EXPORT_OK = qw(contenttypes);
# Test Case Status

View File

@@ -50,8 +50,9 @@ sub builds {
my $ref = $dbh->selectcol_arrayref(
"SELECT build_id
FROM test_builds
WHERE product_id = ?",
FROM test_builds
WHERE product_id = ?
ORDER BY name",
undef, $self->{'id'});
my @objs;
foreach my $id (@{$ref}){
@@ -68,7 +69,8 @@ sub categories {
my $ref = $dbh->selectcol_arrayref(
"SELECT category_id
FROM test_case_categories
WHERE product_id = ?",
WHERE product_id = ?
ORDER BY name",
undef, $self->{'id'});
my @objs;
foreach my $id (@{$ref}){

View File

@@ -366,7 +366,7 @@ sub get_product_ids {
if ($self->id == 0){
my @ids;
foreach my $plan (@{$self->plans}){
push @ids, $plan->product_id if Bugzilla->user->can_see_product($plan->product_name);
push @ids, $plan->product_id if Bugzilla->user->can_see_product($plan->product->name);
}
return \@ids;
}
@@ -1345,8 +1345,10 @@ sub candelete {
# Allow plan author to delete if this case is linked only to plans she owns.
my $own_all = 1;
foreach my $plan (@{$self->plans}){
$own_all = 0 if (Bugzilla->user->id != $plan->author->id);
last;
if (Bugzilla->user->id != $plan->author->id) {
$own_all = 0;
last;
}
}
return 1 if $own_all;
@@ -1551,7 +1553,10 @@ sub components {
my @comps;
foreach my $id (@$comps){
push @comps, Bugzilla::Component->new($id);
my $comp = Bugzilla::Component->new($id);
my $prod = Bugzilla::Product->new($comp->product_id);
$comp->{'product_name'} = $prod->name;
push @comps, $comp;
}
$self->{'components'} = \@comps;
return $self->{'components'};

View File

@@ -991,7 +991,7 @@ sub candelete {
=head2 obliterate
Removes this caserun, it's history, and all things that reference it.
Removes this caserun, its history, and all things that reference it.
=cut

View File

@@ -51,6 +51,7 @@ use Bugzilla::Testopia::TestCase;
use Bugzilla::Testopia::Category;
use Bugzilla::Testopia::Build;
use Bugzilla::Testopia::TestTag;
use Bugzilla::Testopia::Product;
use Bugzilla::Bug;
#TODO: Add this to checksetup
@@ -1002,34 +1003,6 @@ sub attachments {
}
=head2 builds
Returns a reference to a list of Testopia::Build objects associated
with this plan
=cut
sub builds {
my ($self) = @_;
my $dbh = Bugzilla->dbh;
return $self->{'builds'} if exists $self->{'builds'};
my $builds =
$dbh->selectcol_arrayref(
"SELECT build_id
FROM test_builds
WHERE product_id = ?",
undef, $self->{'product_id'});
my @builds;
foreach my $id (@{$builds}){
push @builds, Bugzilla::Testopia::Build->new($id);
}
$self->{'builds'} = \@builds;
return $self->{'builds'};
}
=head2 bugs
Returns a reference to a list of Bugzilla::Bug objects associated
@@ -1057,51 +1030,19 @@ sub bugs {
return $self->{'bugs'};
}
=head2 product_name
=head2 product
Returns the name of the product this plan is associated with
Returns the product this plan is associated with
=cut
sub product_name {
sub product {
my ($self) = @_;
my $dbh = Bugzilla->dbh;
return $self->{'product_name'} if exists $self->{'product_name'};
$self->{'product_name'} = undef;
$self->{'product_name'} = $dbh->selectrow_array(
"SELECT name FROM products
WHERE id = ?",
undef, $self->{'product_id'});
return $self->{'product_name'};
}
=head2 categories
Returns a reference to a list of Testopia::Category objects
associated with this plan
=cut
sub categories {
my ($self) = @_;
my $dbh = Bugzilla->dbh;
return $self->{'categories'} if exists $self->{'categories'};
my $categories =
$dbh->selectcol_arrayref(
"SELECT category_id
FROM test_case_categories
WHERE product_id = ?",
undef, $self->{'product_id'});
my @categories;
foreach my $c (@{$categories}){
push @categories, Bugzilla::Testopia::Category->new($c);
}
$self->{'categories'} = \@categories;
return $self->{'categories'};
return $self->{'product'} if exists $self->{'product'};
$self->{'product'} = Bugzilla::Testopia::Product->new($self->product_id);
return $self->{'product'};
}
=head2 test_cases

View File

@@ -88,19 +88,24 @@ sub add_tag()
push @{$self->tags}, $tag;
}
# Temporary copy of Bugzilla::Testopia::TestPlan->get_available_products(). Remove when bug 220134 is fixed.
sub TEMP_get_product_components {
my ($product_id) = @_;
=head2 get_available_products
Returns a list of products. This is the same code as Bugzilla::Testopia::TestPlan->get_available_products
without view restrictions.
=cut
sub get_available_products {
my $dbh = Bugzilla->dbh;
my $ref = $dbh->selectall_arrayref(
"SELECT DISTINCT id, name
FROM components
WHERE product_id IN($product_id)
ORDER BY name",
{'Slice'=>{}});
return $ref;
my $products = $dbh->selectall_arrayref(
"SELECT id, name
FROM products
ORDER BY name",
{"Slice"=>{}});
return $products;
}
sub add_component()
{
my ($self,$component,$component_product) = @_;
@@ -110,7 +115,7 @@ sub add_component()
return "Component $component needs to provide a product." if ( $component_product eq "" );
# Find the product identifier.
my $products_ref = Bugzilla::Testopia::TestPlan->get_available_products();
my $products_ref = get_available_products();
foreach my $product (@$products_ref)
{
if ( $component_product eq $product->{name} )
@@ -122,7 +127,7 @@ sub add_component()
return "Cannot find product $component_product for component $component." if ( $product_id eq "" );
# Find the component identifier for the product's componet
my $components_ref = TEMP_get_product_components($product_id);
my $components_ref = Bugzilla::Testopia::TestPlan->get_product_components($product_id,1);
foreach my $product_component ( @$components_ref )
{
if ( $component eq $product_component->{name} )
@@ -305,7 +310,7 @@ sub store()
{
my $categoryid = -1;
push my @categories, @{$testplan->categories};
push my @categories, @{$testplan->product->categories};
foreach my $category (@categories)
{
if ( $category->name eq $self->category )

View File

@@ -0,0 +1,98 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Dallas Harken <dharken@novell.com>
package Bugzilla::WebService;
use strict;
use Bugzilla::Config;
use Bugzilla::WebService::Constants;
sub fail_unimplemented
{
my $this = shift;
die SOAP::Fault
->faultcode(ERROR_UNIMPLEMENTED)
->faultstring('Service Unimplemented');
}
sub login
{
my $self = shift;
# Check for use of iChain first
if (Param('user_verify_class') ne 'iChain')
{
#
# Check for use of Basic Authorization
#
# WARNING - Your must modify your Apache server's configuration
# to allow the HTTP_AUTHORIZATION env parameter to be passed through!
# This requires using the rewrite module.
#
if (defined($ENV{'HTTP_AUTHORIZATION'}))
{
if ($ENV{'HTTP_AUTHORIZATION'} =~ /^Basic +(.*)$/os)
{
# HTTP Basic Authentication
my($login, $password) = split(/:/, MIME::Base64::decode_base64($1), 2);
my $cgi = Bugzilla->cgi;
$cgi->param("Bugzilla_login", $login);
$cgi->param("Bugzilla_password", $password);
}
}
}
Bugzilla->login;
}
sub logout
{
my $self = shift;
Bugzilla->logout;
}
package Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI;
use strict;
use Bugzilla::WebService::Constants;
eval 'use base qw(XMLRPC::Transport::HTTP::CGI)';
sub make_fault
{
my $self = shift;
# RPC Fault Code must be an integer
$self->SUPER::make_fault(ERROR_FAULT_SERVER, $_[1]);
}
sub make_response
{
my $self = shift;
$self->SUPER::make_response(@_);
# XMLRPC::Transport::HTTP::CGI doesn't know about Bugzilla carrying around
# its cookies in Bugzilla::CGI, so we need to copy them over.
foreach (@{Bugzilla->cgi->{'Bugzilla_cookie_list'}}) {
$self->response->headers->push_header('Set-Cookie', $_);
}
}
1;

View File

@@ -31,13 +31,13 @@ sub lookup_name_by_id
die "Invalid Build ID"
unless defined $build_id && length($build_id) > 0 && $build_id > 0;
Bugzilla->login;
$self->login;
my $build = new Bugzilla::Testopia::Build($build_id);
my $result = defined $build ? $build->name : '';
Bugzilla->logout;
$self->logout;
# Result is build name string or empty string if failed
return $result;
@@ -48,11 +48,11 @@ sub lookup_id_by_name
my $self = shift;
my ($name) = @_;
Bugzilla->login;
$self->login;
my $result = Bugzilla::Testopia::Build->check_build_by_name($name);
Bugzilla->logout;
$self->logout;
if (!defined $result)
{

View File

@@ -0,0 +1,83 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Dallas Harken <dharken@novell.com>
package Bugzilla::WebService::Testopia::Product;
use strict;
use base qw(Bugzilla::WebService);
use Bugzilla::Testopia::Product;
sub lookup_name_by_id
{
my $self = shift;
my ($product_id) = @_;
die "Invalid Product ID"
unless defined $product_id && length($product_id) > 0 && $product_id > 0;
$self->login;
my $product = new Bugzilla::Testopia::Product($product_id);
my $result = defined $product ? $product->name : '';
$self->logout;
# Result is product name string or empty string if failed
return $result;
}
sub lookup_id_by_name
{
my $self = shift;
my ($name) = @_;
$self->login;
my $result = Bugzilla::Testopia::Product->check_product_by_name($name);
$self->logout;
if (!defined $result)
{
$result = 0;
}
# Result is product id or 0 if failed
return $result;
}
#sub get_product
#{
# my $self = shift;
# my ($product_id) = @_;
#
# Bugzilla->login;
#
# # We can detaint immediately if what we get passed is fully numeric.
# # We leave bug alias checks to Bugzilla::Testopia::TestPlan::new.
#
# if ($product_id =~ /^[0-9]+$/) {
# detaint_natural($product_id);
# }
#
# return new Bugzilla::Product($product_id);
#}
1;

View File

@@ -21,64 +21,12 @@ use strict;
use base qw(Bugzilla::WebService);
use Bugzilla::Util qw(detaint_natural);
use Bugzilla::Product;
use Bugzilla::Constants;
use Bugzilla::User;
use Bugzilla::Testopia::TestPlan;
use Bugzilla::Testopia::Search;
use Bugzilla::Testopia::Table;
# Convert string field values to their respective integer id's
sub _convert_to_ids
{
my ($hash) = @_;
if (defined($$hash{"author"}))
{
$$hash{"author_id"} = login_to_id($$hash{"author"});
}
delete $$hash{"author"};
if (defined($$hash{"product"}))
{
my $product = Bugzilla::Product::check_product($$hash{"product"});
$$hash{"product_id"} = $product->id;
}
delete $$hash{"product"};
if (defined($$hash{"type"}))
{
$$hash{"type_id"} = Bugzilla::Testopia::TestPlan::lookup_type_by_name($$hash{"type"});
}
delete $$hash{"type"};
}
# Convert fields with integer id's to their respective string values
sub _convert_to_strings
{
my ($hash) = @_;
$$hash{"author"} = "";
if (defined($$hash{"author_id"}))
{
$$hash{"author"} = new Bugzilla::User($$hash{"author_id"})->login;
}
delete $$hash{"author_id"};
$$hash{"product"} = "";
if (defined($$hash{"product_id"}))
{
$$hash{"product"} = new Bugzilla::Product($$hash{"product_id"})->name;
}
delete $$hash{"product_id"};
$$hash{"type"} = "";
if (defined($$hash{"type_id"}))
{
$$hash{"type"} = Bugzilla::Testopia::TestPlan->lookup_type($$hash{"type_id"});
}
delete $$hash{"type_id"};
}
# Utility method called by the list method
sub _list
{
@@ -86,8 +34,6 @@ sub _list
my $cgi = Bugzilla->cgi;
$cgi->param("viewall", 1);
$cgi->param("current_tab", "plan");
foreach (keys(%$query))
@@ -111,42 +57,38 @@ sub get
my $self = shift;
my ($test_plan_id) = @_;
Bugzilla->login;
# We can detaint immediately if what we get passed is fully numeric.
# We leave bug alias checks to Bugzilla::Testopia::TestPlan::new.
if ($test_plan_id =~ /^[0-9]+$/) {
detaint_natural($test_plan_id);
}
$self->login;
#Result is a test plan hash map
my $testplan = new Bugzilla::Testopia::TestPlan($test_plan_id);
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
_convert_to_strings($testplan);
Bugzilla->logout;
return $testplan;
$self->logout;
return $test_plan;
}
sub list
{
Bugzilla->login;
my $self = shift;
my ($query) = @_;
_convert_to_ids($query);
$self->login;
my $list = _list($query);
foreach (@$list)
{
_convert_to_strings($_);
}
Bugzilla->logout;
$self->logout;
return $list;
}
@@ -156,16 +98,16 @@ sub create
my $self =shift;
my ($new_values) = @_;
Bugzilla->login;
$self->login;
_convert_to_ids($new_values);
my $test_plan = new Bugzilla::Testopia::TestPlan($new_values);
Bugzilla->logout;
my $result = $test_plan->store();
$self->logout;
# Result is new test plan id
return $test_plan->store();
return $result;
}
sub update
@@ -173,18 +115,154 @@ sub update
my $self =shift;
my ($test_plan_id, $new_values) = @_;
Bugzilla->login;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canedit)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->update($new_values);
$self->logout;
_convert_to_ids($new_values);
$test_plan->update($new_values);
Bugzilla->logout;
# Result is zero on success, otherwise an exception will be thrown
return 0;
return $test_plan;
}
sub get_test_cases
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->test_cases();
$self->logout;
# Result is list of test cases for the given test plan
return $result;
}
sub get_test_runs
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->test_runs();
$self->logout;
# Result is list of test runs for the given test plan
return $result;
}
sub get_categories
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->product->categories();
$self->logout;
# Result is list of test runs for the given test plan
return $result;
}
sub lookup_type_name_by_id
{
my $self =shift;
my ($id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan({});
my $result = $test_plan->lookup_type($id);
$self->logout;
# Result is test plan type name for the given test plan type id
return $result;
}
sub lookup_type_id_by_name
{
my $self =shift;
my ($name) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan({});
my $result = $test_plan->lookup_type_by_name($name);
$self->logout;
if (!defined $result)
{
$result = 0;
};
# Result is test plan type id for the given test plan type name
return $result;
}
1;

View File

@@ -0,0 +1,58 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Dallas Harken <dharken@novell.com>
package Bugzilla::WebService::User;
use strict;
use Bugzilla;
use base qw(Bugzilla::WebService);
sub lookup_login_by_id
{
my $self = shift;
my ($author_id) = @_;
$self->login;
my $user = new Bugzilla::User($author_id);
my $result = defined $user ? $user->login : '';
$self->logout;
# Result is user login string or empty string if failed
return $result;
}
sub lookup_id_by_login
{
my $self = shift;
my ($author) = @_;
$self->login;
my $result = Bugzilla::User::login_to_id($author);
$self->logout;
# Result is user id or 0 if failed
return $result;
}
1;