Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
c3a93557
Commit
c3a93557
authored
May 13, 2011
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 656790 - Create a basic framework for testing custom search
r=mkanat, a=mkanat (module owner)
parent
e39f635e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
1 deletion
+131
-1
Search.pm
xt/lib/Bugzilla/Test/Search.pm
+7
-1
Constants.pm
xt/lib/Bugzilla/Test/Search/Constants.pm
+11
-0
CustomTest.pm
xt/lib/Bugzilla/Test/Search/CustomTest.pm
+113
-0
No files found.
xt/lib/Bugzilla/Test/Search.pm
View file @
c3a93557
...
...
@@ -58,6 +58,7 @@ use Bugzilla::FlagType;
use
Bugzilla::
Group
;
use
Bugzilla::
Install
();
use
Bugzilla::Test::Search::
Constants
;
use
Bugzilla::Test::Search::
CustomTest
;
use
Bugzilla::Test::Search::
FieldTestNormal
;
use
Bugzilla::Test::Search::
OperatorTest
;
use
Bugzilla::
User
();
...
...
@@ -111,7 +112,8 @@ sub num_tests {
# This @{ [] } thing is the only reasonable way to get a count out of a
# constant array.
my
$special_tests
=
scalar
(
@
{
[
SPECIAL_PARAM_TESTS
]
})
*
TESTS_PER_RUN
;
my
$special_tests
=
scalar
(
@
{
[
SPECIAL_PARAM_TESTS
,
CUSTOM_SEARCH_TESTS
]
})
*
TESTS_PER_RUN
;
return
$operator_field_tests
+
$sql_injection_tests
+
$special_tests
;
}
...
...
@@ -882,6 +884,10 @@ sub run {
# Even though _setup_bugs set us as an admin, we want to be sure at
# this point that we have an admin with refreshed group memberships.
Bugzilla
->
set_user
(
$self
->
admin
);
foreach
my
$test
(
CUSTOM_SEARCH_TESTS
)
{
my
$custom_test
=
new
Bugzilla::Test::Search::
CustomTest
(
$test
,
$self
);
$custom_test
->
run
();
}
foreach
my
$test
(
SPECIAL_PARAM_TESTS
)
{
my
$operator_test
=
new
Bugzilla::Test::Search::
OperatorTest
(
$test
->
{
operator
},
$self
);
...
...
xt/lib/Bugzilla/Test/Search/Constants.pm
View file @
c3a93557
...
...
@@ -36,6 +36,7 @@ our @EXPORT = qw(
COLUMN_TRANSLATION
COMMENT_FIELDS
CUSTOM_FIELDS
CUSTOM_SEARCH_TESTS
FIELD_SIZE
FIELD_SUBSTR_SIZE
FLAG_FIELDS
...
...
@@ -1021,4 +1022,14 @@ use constant SPECIAL_PARAM_TESTS => (
value
=>
'%group.<1-bug_group>%'
,
contains
=>
[
1
,
2
,
3
,
4
,
5
]
},
);
use
constant
CUSTOM_SEARCH_TESTS
=>
(
{
name
=>
'bug_id AND assigned_to'
,
contains
=>
[
1
],
columns
=>
[
'assigned_to'
],
params
=>
[
{
f
=>
'bug_id'
,
o
=>
'equals'
,
v
=>
'<1>'
},
{
f
=>
'assigned_to'
,
o
=>
'equals'
,
v
=>
'<1>'
},
]
},
);
1
;
xt/lib/Bugzilla/Test/Search/CustomTest.pm
0 → 100644
View file @
c3a93557
# -*- 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.
#
# The Initial Developer of the Original Code is Google, Inc.
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Max Kanat-Alexander <mkanat@bugzilla.org>
# This module represents a test with custom URL parameters.
# Tests like this are specified in CUSTOM_SEARCH_TESTS in
# Bugzilla::Test::Search::Constants.
package
Bugzilla::Test::Search::
CustomTest
;
use
base
qw(Bugzilla::Test::Search::FieldTest)
;
use
strict
;
use
warnings
;
use
Bugzilla::Test::Search::
FieldTest
;
use
Bugzilla::Test::Search::
OperatorTest
;
use
Storable
qw(dclone)
;
###############
# Constructor #
###############
sub
new
{
my
(
$class
,
$test
,
$search_test
)
=
@_
;
bless
{
raw_test
=>
dclone
(
$test
),
search_test
=>
$search_test
},
$class
;
}
#############
# Accessors #
#############
sub
search_test
{
return
$_
[
0
]
->
{
search_test
}
}
sub
name
{
return
'Custom: '
.
$_
[
0
]
->
test
->
{
name
}
}
sub
test
{
return
$_
[
0
]
->
{
raw_test
}
}
sub
operator_test
{
die
"unimplemented"
}
sub
field_object
{
die
"unimplemented"
}
sub
main_value
{
die
"unimplenmented"
}
sub
test_value
{
die
"unimplemented"
}
sub
debug_value
{
my
(
$self
)
=
@_
;
my
$string
=
''
;
my
$params
=
$self
->
search_params
;
foreach
my
$param
(
keys
%
$params
)
{
$string
.=
$param
.
"="
.
$params
->
{
$param
}
.
'&'
;
}
chop
(
$string
);
return
$string
;
}
# The tests we know are broken for this operator/field combination.
sub
_known_broken
{
return
{}
}
sub
contains_known_broken
{
return
undef
}
sub
search_known_broken
{
return
undef
}
sub
field_not_yet_implemented
{
return
undef
}
sub
invalid_field_operator_combination
{
return
undef
}
#########################################
# Accessors: Bugzilla::Search Arguments #
#########################################
# Converts the f, o, v rows into f0, o0, v0, etc. and translates
# the values appropriately.
sub
search_params
{
my
(
$self
)
=
@_
;
my
%
params
;
my
$counter
=
0
;
foreach
my
$row
(
@
{
$self
->
test
->
{
params
}
})
{
$row
->
{
v
}
=
$self
->
translate_value
(
$row
);
foreach
my
$key
(
keys
%
$row
)
{
$params
{
"${key}$counter"
}
=
$row
->
{
$key
};
}
$counter
++
;
}
return
\%
params
;
}
sub
translate_value
{
my
(
$self
,
$row
)
=
@_
;
my
$as_test
=
{
field
=>
$row
->
{
f
},
operator
=>
$row
->
{
o
},
value
=>
$row
->
{
v
}
};
my
$operator_test
=
new
Bugzilla::Test::Search::
OperatorTest
(
$row
->
{
o
},
$self
->
search_test
);
my
$field
=
Bugzilla::
Field
->
check
(
$row
->
{
f
});
my
$field_test
=
new
Bugzilla::Test::Search::
FieldTest
(
$operator_test
,
$field
,
$as_test
);
return
$field_test
->
translated_value
;
}
sub
search_columns
{
my
(
$self
)
=
@_
;
return
[
'bug_id'
,
@
{
$self
->
test
->
{
columns
}
}];
}
1
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment