| 1 | package JIRA::REST::Class; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | our $VERSION = '0.12'; | |||||||||||||||||||||||||||
| 7 | 4 | our $SOURCE = 'CPAN'; | |||||||||||||||||||||||||||
| 8 | ## $SOURCE = 'GitHub'; # COMMENT | ||||||||||||||||||||||||||||
| 9 | # the line above will be commented out by Dist::Zilla | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # ABSTRACT: An OO Class module built atop L<JIRA::REST|JIRA::REST> for dealing with JIRA issues and their data as objects. | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Clone::Any qw( clone ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Readonly 2.04; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use JIRA::REST; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use JIRA::REST::Class::Factory; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use parent qw(JIRA::REST::Class::Mixins); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 22 | # Constants | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 4 | Readonly my $DEFAULT_MAXRESULTS => 50; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 44 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 44 | my ( $class, @arglist ) = @_; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 44 | my $args = $class->_get_known_args( | |||||||||||||||||||||||||||
| 32 | \@arglist, | ||||||||||||||||||||||||||||
| 33 | qw/ url username password rest_client_config | ||||||||||||||||||||||||||||
| 34 | proxy ssl_verify_none anonymous / | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 44 | return bless { | |||||||||||||||||||||||||||
| 38 | jira_rest => $class->JIRA_REST( clone( $args ) ), | ||||||||||||||||||||||||||||
| 39 | factory => $class->factory( clone( $args ) ), | ||||||||||||||||||||||||||||
| 40 | args => clone( $args ), | ||||||||||||||||||||||||||||
| 41 | userobj => undef, | ||||||||||||||||||||||||||||
| 42 | }, $class; | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 46 | # | ||||||||||||||||||||||||||||
| 47 | # using Inline::Test to generate testing files from tests | ||||||||||||||||||||||||||||
| 48 | # declared next to the code that it's testing | ||||||||||||||||||||||||||||
| 49 | # | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | #pod =begin test setup 1 | ||||||||||||||||||||||||||||
| 52 | #pod | ||||||||||||||||||||||||||||
| 53 | #pod use File::Basename; | ||||||||||||||||||||||||||||
| 54 | #pod use lib dirname($0).'/..'; | ||||||||||||||||||||||||||||
| 55 | #pod use MyTest; | ||||||||||||||||||||||||||||
| 56 | #pod use 5.010; | ||||||||||||||||||||||||||||
| 57 | #pod | ||||||||||||||||||||||||||||
| 58 | #pod TestServer_setup(); | ||||||||||||||||||||||||||||
| 59 | #pod | ||||||||||||||||||||||||||||
| 60 | #pod END { | ||||||||||||||||||||||||||||
| 61 | #pod TestServer_stop(); | ||||||||||||||||||||||||||||
| 62 | #pod } | ||||||||||||||||||||||||||||
| 63 | #pod | ||||||||||||||||||||||||||||
| 64 | #pod use_ok('JIRA::REST::Class'); | ||||||||||||||||||||||||||||
| 65 | #pod | ||||||||||||||||||||||||||||
| 66 | #pod sub get_test_client { | ||||||||||||||||||||||||||||
| 67 | #pod state $test = | ||||||||||||||||||||||||||||
| 68 | #pod JIRA::REST::Class->new(TestServer_url(), 'username', 'password'); | ||||||||||||||||||||||||||||
| 69 | #pod $test->REST_CLIENT->setTimeout(5); | ||||||||||||||||||||||||||||
| 70 | #pod return $test; | ||||||||||||||||||||||||||||
| 71 | #pod }; | ||||||||||||||||||||||||||||
| 72 | #pod | ||||||||||||||||||||||||||||
| 73 | #pod =end test | ||||||||||||||||||||||||||||
| 74 | #pod | ||||||||||||||||||||||||||||
| 75 | #pod =cut | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | #pod =begin testing new 5 | ||||||||||||||||||||||||||||
| 80 | #pod | ||||||||||||||||||||||||||||
| 81 | #pod my $jira; | ||||||||||||||||||||||||||||
| 82 | #pod try { | ||||||||||||||||||||||||||||
| 83 | #pod $jira = JIRA::REST::Class->new({ | ||||||||||||||||||||||||||||
| 84 | #pod url => TestServer_url(), | ||||||||||||||||||||||||||||
| 85 | #pod username => 'user', | ||||||||||||||||||||||||||||
| 86 | #pod password => 'pass', | ||||||||||||||||||||||||||||
| 87 | #pod proxy => '', | ||||||||||||||||||||||||||||
| 88 | #pod anonymous => 0, | ||||||||||||||||||||||||||||
| 89 | #pod ssl_verify_none => 1, | ||||||||||||||||||||||||||||
| 90 | #pod rest_client_config => {}, | ||||||||||||||||||||||||||||
| 91 | #pod }); | ||||||||||||||||||||||||||||
| 92 | #pod } | ||||||||||||||||||||||||||||
| 93 | #pod catch { | ||||||||||||||||||||||||||||
| 94 | #pod $jira = $_; # as good a place as any to stash the error, because | ||||||||||||||||||||||||||||
| 95 | #pod # isa_ok() will complain that it's not an object. | ||||||||||||||||||||||||||||
| 96 | #pod }; | ||||||||||||||||||||||||||||
| 97 | #pod | ||||||||||||||||||||||||||||
| 98 | #pod isa_ok($jira, 'JIRA::REST::Class', 'JIRA::REST::Class->new'); | ||||||||||||||||||||||||||||
| 99 | #pod | ||||||||||||||||||||||||||||
| 100 | #pod my $needs_url_regexp = qr/'?url'? argument must be defined/i; | ||||||||||||||||||||||||||||
| 101 | #pod | ||||||||||||||||||||||||||||
| 102 | #pod throws_ok( | ||||||||||||||||||||||||||||
| 103 | #pod sub { | ||||||||||||||||||||||||||||
| 104 | #pod JIRA::REST::Class->new(); | ||||||||||||||||||||||||||||
| 105 | #pod }, | ||||||||||||||||||||||||||||
| 106 | #pod $needs_url_regexp, | ||||||||||||||||||||||||||||
| 107 | #pod 'JIRA::REST::Class->new with no parameters throws an exception', | ||||||||||||||||||||||||||||
| 108 | #pod ); | ||||||||||||||||||||||||||||
| 109 | #pod | ||||||||||||||||||||||||||||
| 110 | #pod throws_ok( | ||||||||||||||||||||||||||||
| 111 | #pod sub { | ||||||||||||||||||||||||||||
| 112 | #pod JIRA::REST::Class->new({ | ||||||||||||||||||||||||||||
| 113 | #pod username => 'user', | ||||||||||||||||||||||||||||
| 114 | #pod password => 'pass', | ||||||||||||||||||||||||||||
| 115 | #pod }); | ||||||||||||||||||||||||||||
| 116 | #pod }, | ||||||||||||||||||||||||||||
| 117 | #pod $needs_url_regexp, | ||||||||||||||||||||||||||||
| 118 | #pod 'JIRA::REST::Class->new with no url throws an exception', | ||||||||||||||||||||||||||||
| 119 | #pod ); | ||||||||||||||||||||||||||||
| 120 | #pod | ||||||||||||||||||||||||||||
| 121 | #pod throws_ok( | ||||||||||||||||||||||||||||
| 122 | #pod sub { | ||||||||||||||||||||||||||||
| 123 | #pod JIRA::REST::Class->new('http://not.a.good.server.com'); | ||||||||||||||||||||||||||||
| 124 | #pod }, | ||||||||||||||||||||||||||||
| 125 | #pod qr/No credentials found/, | ||||||||||||||||||||||||||||
| 126 | #pod q{JIRA::REST::Class->new with just url tries to find credentials}, | ||||||||||||||||||||||||||||
| 127 | #pod ); | ||||||||||||||||||||||||||||
| 128 | #pod | ||||||||||||||||||||||||||||
| 129 | #pod lives_ok( | ||||||||||||||||||||||||||||
| 130 | #pod sub { | ||||||||||||||||||||||||||||
| 131 | #pod JIRA::REST::Class->new(TestServer_url(), 'user', 'pass'); | ||||||||||||||||||||||||||||
| 132 | #pod }, | ||||||||||||||||||||||||||||
| 133 | #pod q{JIRA::REST::Class->new with url, username, and password does't croak!}, | ||||||||||||||||||||||||||||
| 134 | #pod ); | ||||||||||||||||||||||||||||
| 135 | #pod | ||||||||||||||||||||||||||||
| 136 | #pod =end testing | ||||||||||||||||||||||||||||
| 137 | #pod | ||||||||||||||||||||||||||||
| 138 | #pod =cut | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | #pod =method B<issues> QUERY | ||||||||||||||||||||||||||||
| 143 | #pod | ||||||||||||||||||||||||||||
| 144 | #pod =method B<issues> KEY [, KEY...] | ||||||||||||||||||||||||||||
| 145 | #pod | ||||||||||||||||||||||||||||
| 146 | #pod The C<issues> method can be called two ways: either by providing a list of | ||||||||||||||||||||||||||||
| 147 | #pod issue keys, or by proving a single hash reference which describes a JIRA | ||||||||||||||||||||||||||||
| 148 | #pod query in the same format used by L<JIRA::REST|JIRA::REST> (essentially, | ||||||||||||||||||||||||||||
| 149 | #pod C<< jql => "JQL query string" >>). | ||||||||||||||||||||||||||||
| 150 | #pod | ||||||||||||||||||||||||||||
| 151 | #pod The return value is an array of L<JIRA::REST::Class::Issue|JIRA::REST::Class::Issue> objects. | ||||||||||||||||||||||||||||
| 152 | #pod | ||||||||||||||||||||||||||||
| 153 | #pod =cut | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 0 | ▶ | sub issues { | ||||||||||||||||||||||||||
|
Subroutine
issues: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 156 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ( @args == 1 && ref $args[0] eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@args == 1 and ref $args[0] eq "HASH"
MC/DC0%0/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1
ref $args[0] eq "HASH"
Truth table0%0/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 158 | 0 | return $self->query( $args[0] )->issues; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | else { | ||||||||||||||||||||||||||||
| 161 | 0 | my $jql = sprintf 'key in (%s)', join q{,} => @args; | |||||||||||||||||||||||||||
| 162 | 0 | return $self->query( { jql => $jql } )->issues; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 167 | # | ||||||||||||||||||||||||||||
| 168 | # =begin testing issues | ||||||||||||||||||||||||||||
| 169 | # =end testing | ||||||||||||||||||||||||||||
| 170 | # | ||||||||||||||||||||||||||||
| 171 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | #pod =method B<query> QUERY | ||||||||||||||||||||||||||||
| 174 | #pod | ||||||||||||||||||||||||||||
| 175 | #pod The C<query> method takes a single parameter: a hash reference which | ||||||||||||||||||||||||||||
| 176 | #pod describes a JIRA query in the same format used by L<JIRA::REST|JIRA::REST> | ||||||||||||||||||||||||||||
| 177 | #pod (essentially, C<< jql => "JQL query string" >>). | ||||||||||||||||||||||||||||
| 178 | #pod | ||||||||||||||||||||||||||||
| 179 | #pod The return value is a single L<JIRA::REST::Class::Query|JIRA::REST::Class::Query> object. | ||||||||||||||||||||||||||||
| 180 | #pod | ||||||||||||||||||||||||||||
| 181 | #pod =cut | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | sub query { | ||||||||||||||||||||||||||
|
Subroutine
query: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 184 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 185 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | my $query = $self->post( '/search', $args ); | |||||||||||||||||||||||||||
| 188 | 0 | return $self->make_object( 'query', { data => $query } ); | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 192 | # | ||||||||||||||||||||||||||||
| 193 | # =begin testing query | ||||||||||||||||||||||||||||
| 194 | # =end testing | ||||||||||||||||||||||||||||
| 195 | # | ||||||||||||||||||||||||||||
| 196 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | #pod =method B<iterator> QUERY | ||||||||||||||||||||||||||||
| 199 | #pod | ||||||||||||||||||||||||||||
| 200 | #pod The C<query> method takes a single parameter: a hash reference which | ||||||||||||||||||||||||||||
| 201 | #pod describes a JIRA query in the same format used by L<JIRA::REST|JIRA::REST> | ||||||||||||||||||||||||||||
| 202 | #pod (essentially, C<< jql => "JQL query string" >>). It accepts an additional | ||||||||||||||||||||||||||||
| 203 | #pod field, however: C<restart_if_lt_total>. If this field is set to a true value, | ||||||||||||||||||||||||||||
| 204 | #pod the iterator will keep track of the number of results fetched and, if when | ||||||||||||||||||||||||||||
| 205 | #pod the results run out this number doesn't match the number of results | ||||||||||||||||||||||||||||
| 206 | #pod predicted by the query, it will restart the query. This is particularly | ||||||||||||||||||||||||||||
| 207 | #pod useful if you are transforming a number of issues through an iterator, and | ||||||||||||||||||||||||||||
| 208 | #pod the transformation causes the issues to no longer match the query. | ||||||||||||||||||||||||||||
| 209 | #pod | ||||||||||||||||||||||||||||
| 210 | #pod The return value is a single | ||||||||||||||||||||||||||||
| 211 | #pod L<JIRA::REST::Class::Iterator|JIRA::REST::Class::Iterator> object. The | ||||||||||||||||||||||||||||
| 212 | #pod issues returned by the query can be obtained in serial by repeatedly calling | ||||||||||||||||||||||||||||
| 213 | #pod L<next|JIRA::REST::Class::Iterator/next> on this object, which returns a | ||||||||||||||||||||||||||||
| 214 | #pod series of L<JIRA::REST::Class::Issue|JIRA::REST::Class::Issue> objects. | ||||||||||||||||||||||||||||
| 215 | #pod | ||||||||||||||||||||||||||||
| 216 | #pod =cut | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub iterator { | ||||||||||||||||||||||||||
|
Subroutine
iterator: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 219 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 220 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 221 | 0 | return $self->make_object( 'iterator', { iterator_args => $args } ); | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 225 | # | ||||||||||||||||||||||||||||
| 226 | # =begin testing iterator | ||||||||||||||||||||||||||||
| 227 | # =end testing | ||||||||||||||||||||||||||||
| 228 | # | ||||||||||||||||||||||||||||
| 229 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | #pod =internal_method B<get> | ||||||||||||||||||||||||||||
| 232 | #pod | ||||||||||||||||||||||||||||
| 233 | #pod A wrapper for C<JIRA::REST>'s L<GET|JIRA::REST/"GET RESOURCE [, QUERY]"> method. | ||||||||||||||||||||||||||||
| 234 | #pod | ||||||||||||||||||||||||||||
| 235 | #pod =cut | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 6 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 238 | 6 | my ( $self, $url, @args ) = @_; | |||||||||||||||||||||||||||
| 239 | 6 | return $self->JIRA_REST->GET( $url, undef, @args ); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | #pod =begin testing get | ||||||||||||||||||||||||||||
| 245 | #pod | ||||||||||||||||||||||||||||
| 246 | #pod validate_wrapper_method( sub { get_test_client()->get('/test'); }, | ||||||||||||||||||||||||||||
| 247 | #pod { GET => 'SUCCESS' }, 'get() method works' ); | ||||||||||||||||||||||||||||
| 248 | #pod | ||||||||||||||||||||||||||||
| 249 | #pod =end testing | ||||||||||||||||||||||||||||
| 250 | #pod | ||||||||||||||||||||||||||||
| 251 | #pod =cut | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | #pod =internal_method B<post> | ||||||||||||||||||||||||||||
| 256 | #pod | ||||||||||||||||||||||||||||
| 257 | #pod Wrapper around C<JIRA::REST>'s L<POST|JIRA::REST/"POST RESOURCE, QUERY, VALUE [, HEADERS]"> method. | ||||||||||||||||||||||||||||
| 258 | #pod | ||||||||||||||||||||||||||||
| 259 | #pod =cut | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 1 | ▶ | sub post { | ||||||||||||||||||||||||||
|
Subroutine
post: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 262 | 1 | my ( $self, $url, @args ) = @_; | |||||||||||||||||||||||||||
| 263 | 1 | return $self->JIRA_REST->POST( $url, undef, @args ); | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | #pod =begin testing post | ||||||||||||||||||||||||||||
| 269 | #pod | ||||||||||||||||||||||||||||
| 270 | #pod validate_wrapper_method( sub { get_test_client()->post('/test', "key=value"); }, | ||||||||||||||||||||||||||||
| 271 | #pod { POST => 'SUCCESS' }, 'post() method works' ); | ||||||||||||||||||||||||||||
| 272 | #pod | ||||||||||||||||||||||||||||
| 273 | #pod =end testing | ||||||||||||||||||||||||||||
| 274 | #pod | ||||||||||||||||||||||||||||
| 275 | #pod =cut | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | #pod =internal_method B<put> | ||||||||||||||||||||||||||||
| 280 | #pod | ||||||||||||||||||||||||||||
| 281 | #pod Wrapper around C<JIRA::REST>'s L<PUT|JIRA::REST/"PUT RESOURCE, QUERY, VALUE [, HEADERS]"> method. | ||||||||||||||||||||||||||||
| 282 | #pod | ||||||||||||||||||||||||||||
| 283 | #pod =cut | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 1 | ▶ | sub put { | ||||||||||||||||||||||||||
|
Subroutine
put: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 286 | 1 | my ( $self, $url, @args ) = @_; | |||||||||||||||||||||||||||
| 287 | 1 | return $self->JIRA_REST->PUT( $url, undef, @args ); | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | #pod =begin testing put | ||||||||||||||||||||||||||||
| 293 | #pod | ||||||||||||||||||||||||||||
| 294 | #pod validate_wrapper_method( sub { get_test_client()->put('/test', "key=value"); }, | ||||||||||||||||||||||||||||
| 295 | #pod { PUT => 'SUCCESS' }, 'put() method works' ); | ||||||||||||||||||||||||||||
| 296 | #pod | ||||||||||||||||||||||||||||
| 297 | #pod =end testing | ||||||||||||||||||||||||||||
| 298 | #pod | ||||||||||||||||||||||||||||
| 299 | #pod =cut | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | #pod =internal_method B<delete> | ||||||||||||||||||||||||||||
| 304 | #pod | ||||||||||||||||||||||||||||
| 305 | #pod Wrapper around C<JIRA::REST>'s L<DELETE|JIRA::REST/"DELETE RESOURCE [, QUERY]"> method. | ||||||||||||||||||||||||||||
| 306 | #pod | ||||||||||||||||||||||||||||
| 307 | #pod =cut | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 1 | ▶ | sub delete { ## no critic (ProhibitBuiltinHomonyms) | ||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 310 | 1 | my ( $self, $url, @args ) = @_; | |||||||||||||||||||||||||||
| 311 | 1 | return $self->JIRA_REST->DELETE( $url, @args ); | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | #pod =begin testing delete | ||||||||||||||||||||||||||||
| 317 | #pod | ||||||||||||||||||||||||||||
| 318 | #pod validate_wrapper_method( sub { get_test_client()->delete('/test'); }, | ||||||||||||||||||||||||||||
| 319 | #pod { DELETE => 'SUCCESS' }, 'delete() method works' ); | ||||||||||||||||||||||||||||
| 320 | #pod | ||||||||||||||||||||||||||||
| 321 | #pod =end testing | ||||||||||||||||||||||||||||
| 322 | #pod | ||||||||||||||||||||||||||||
| 323 | #pod =cut | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | #pod =internal_method B<data_upload> | ||||||||||||||||||||||||||||
| 328 | #pod | ||||||||||||||||||||||||||||
| 329 | #pod Similar to | ||||||||||||||||||||||||||||
| 330 | #pod L<< JIRA::REST->attach_files|JIRA::REST/"attach_files ISSUE FILE..." >>, | ||||||||||||||||||||||||||||
| 331 | #pod but entirely from memory and only attaches one file at a time. Returns the | ||||||||||||||||||||||||||||
| 332 | #pod L<HTTP::Response|HTTP::Response> object from the post request. Takes the | ||||||||||||||||||||||||||||
| 333 | #pod following named parameters: | ||||||||||||||||||||||||||||
| 334 | #pod | ||||||||||||||||||||||||||||
| 335 | #pod =over 4 | ||||||||||||||||||||||||||||
| 336 | #pod | ||||||||||||||||||||||||||||
| 337 | #pod =item + B<url> | ||||||||||||||||||||||||||||
| 338 | #pod | ||||||||||||||||||||||||||||
| 339 | #pod The relative URL to POST to. This will have the hostname and REST version | ||||||||||||||||||||||||||||
| 340 | #pod information prepended to it, so all you need to provide is something like | ||||||||||||||||||||||||||||
| 341 | #pod C</issue/>I<issueIdOrKey>C</attachments>. I'm allowing the URL to be | ||||||||||||||||||||||||||||
| 342 | #pod specified in case I later discover something this can be used for besides | ||||||||||||||||||||||||||||
| 343 | #pod attaching files to issues. | ||||||||||||||||||||||||||||
| 344 | #pod | ||||||||||||||||||||||||||||
| 345 | #pod =item + B<name> | ||||||||||||||||||||||||||||
| 346 | #pod | ||||||||||||||||||||||||||||
| 347 | #pod The name that is specified for this file attachment. | ||||||||||||||||||||||||||||
| 348 | #pod | ||||||||||||||||||||||||||||
| 349 | #pod =item + B<data> | ||||||||||||||||||||||||||||
| 350 | #pod | ||||||||||||||||||||||||||||
| 351 | #pod The actual data to be uploaded. If a reference is provided, it will be | ||||||||||||||||||||||||||||
| 352 | #pod dereferenced before posting the data. | ||||||||||||||||||||||||||||
| 353 | #pod | ||||||||||||||||||||||||||||
| 354 | #pod =back | ||||||||||||||||||||||||||||
| 355 | #pod | ||||||||||||||||||||||||||||
| 356 | #pod I guess that makes it only a I<little> like | ||||||||||||||||||||||||||||
| 357 | #pod C<< JIRA::REST->attach_files >>... | ||||||||||||||||||||||||||||
| 358 | #pod | ||||||||||||||||||||||||||||
| 359 | #pod =cut | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 1 | ▶ | sub data_upload { | ||||||||||||||||||||||||||
|
Subroutine
data_upload: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 362 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 363 | 1 | my $args = $self->_get_known_args( \@args, qw/ url name data / ); | |||||||||||||||||||||||||||
| 364 | 1 | $self->_check_required_args( | |||||||||||||||||||||||||||
| 365 | $args, | ||||||||||||||||||||||||||||
| 366 | url => 'you must specify a URL to upload to', | ||||||||||||||||||||||||||||
| 367 | name => 'you must specify a name for the file data', | ||||||||||||||||||||||||||||
| 368 | data => 'you must specify the file data', | ||||||||||||||||||||||||||||
| 369 | ); | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 1 | my $name = $args->{name}; | |||||||||||||||||||||||||||
| 372 | 0 | ▶ | my $data = ref $args->{data} ? ${ $args->{data} } : $args->{data}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | # code cribbed from JIRA::REST | ||||||||||||||||||||||||||||
| 375 | # | ||||||||||||||||||||||||||||
| 376 | 1 | my $url = $self->rest_api_url_base . $args->{url}; | |||||||||||||||||||||||||||
| 377 | 1 | my $rest = $self->REST_CLIENT; | |||||||||||||||||||||||||||
| 378 | my $response = $rest->getUseragent()->post( | ||||||||||||||||||||||||||||
| 379 | $url, | ||||||||||||||||||||||||||||
| 380 | 1 | %{ $rest->{_headers} }, | |||||||||||||||||||||||||||
| 381 | 'X-Atlassian-Token' => 'nocheck', | ||||||||||||||||||||||||||||
| 382 | 'Content-Type' => 'form-data', | ||||||||||||||||||||||||||||
| 383 | 'Content' => [ | ||||||||||||||||||||||||||||
| 384 | file => [ undef, $name, Content => $data ], | ||||||||||||||||||||||||||||
| 385 | ], | ||||||||||||||||||||||||||||
| 386 | ); | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | #<<< perltidy should ignore these lines | ||||||||||||||||||||||||||||
| 389 | 1 | ▶ | $response->is_success | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | or croak $self->JIRA_REST->_error( ## no critic (ProtectPrivateSubs) | ||||||||||||||||||||||||||||
| 391 | $self->_croakmsg( $response->status_line, $name ) | ||||||||||||||||||||||||||||
| 392 | ); | ||||||||||||||||||||||||||||
| 393 | #>>> | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 1 | return $response; | |||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | #pod =begin testing data_upload | ||||||||||||||||||||||||||||
| 401 | #pod | ||||||||||||||||||||||||||||
| 402 | #pod my $expected = { | ||||||||||||||||||||||||||||
| 403 | #pod "Content-Disposition" => "form-data; name=\"file\"; filename=\"file.txt\"", | ||||||||||||||||||||||||||||
| 404 | #pod POST => "SUCCESS", | ||||||||||||||||||||||||||||
| 405 | #pod data => "An OO Class module built atop L<JIRA::REST|JIRA::REST> for dealing with " | ||||||||||||||||||||||||||||
| 406 | #pod . "JIRA issues and their data as objects.", | ||||||||||||||||||||||||||||
| 407 | #pod name => "file.txt" | ||||||||||||||||||||||||||||
| 408 | #pod }; | ||||||||||||||||||||||||||||
| 409 | #pod | ||||||||||||||||||||||||||||
| 410 | #pod my $test1_name = 'return value from data_upload()'; | ||||||||||||||||||||||||||||
| 411 | #pod my $test2_name = 'data_upload() method succeeded'; | ||||||||||||||||||||||||||||
| 412 | #pod my $test3_name = 'data_upload() method returned expected data'; | ||||||||||||||||||||||||||||
| 413 | #pod | ||||||||||||||||||||||||||||
| 414 | #pod my $test = get_test_client(); | ||||||||||||||||||||||||||||
| 415 | #pod my $results; | ||||||||||||||||||||||||||||
| 416 | #pod my $got; | ||||||||||||||||||||||||||||
| 417 | #pod | ||||||||||||||||||||||||||||
| 418 | #pod try { | ||||||||||||||||||||||||||||
| 419 | #pod $results = $test->data_upload({ | ||||||||||||||||||||||||||||
| 420 | #pod url => "/data_upload", | ||||||||||||||||||||||||||||
| 421 | #pod name => $expected->{name}, | ||||||||||||||||||||||||||||
| 422 | #pod data => $expected->{data}, | ||||||||||||||||||||||||||||
| 423 | #pod }); | ||||||||||||||||||||||||||||
| 424 | #pod $got = $test->JSON->decode($results->decoded_content); | ||||||||||||||||||||||||||||
| 425 | #pod } | ||||||||||||||||||||||||||||
| 426 | #pod catch { | ||||||||||||||||||||||||||||
| 427 | #pod $results = $_; | ||||||||||||||||||||||||||||
| 428 | #pod diag($test->REST_CLIENT->getHost); | ||||||||||||||||||||||||||||
| 429 | #pod }; | ||||||||||||||||||||||||||||
| 430 | #pod | ||||||||||||||||||||||||||||
| 431 | #pod my $test1_ok = isa_ok( $results, 'HTTP::Response', $test1_name ); | ||||||||||||||||||||||||||||
| 432 | #pod my $test2_ok = ok($test1_ok && $results->is_success, $test2_name ); | ||||||||||||||||||||||||||||
| 433 | #pod $test2_ok ? is_deeply( $got, $expected, $test3_name ) : fail( $test3_name ); | ||||||||||||||||||||||||||||
| 434 | #pod | ||||||||||||||||||||||||||||
| 435 | #pod =end testing | ||||||||||||||||||||||||||||
| 436 | #pod | ||||||||||||||||||||||||||||
| 437 | #pod =cut | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | #pod =method B<maxResults> | ||||||||||||||||||||||||||||
| 442 | #pod | ||||||||||||||||||||||||||||
| 443 | #pod A getter/setter method that allows setting a global default for the L<maxResults pagination parameter for JIRA's REST API |https://docs.atlassian.com/jira/REST/latest/#pagination>. This determines the I<maximum> number of results returned by the L<issues|/"issues QUERY"> and L<query|/"query QUERY"> methods; and the initial number of results fetched by the L<iterator|/"iterator QUERY"> (when L<next|JIRA::REST::Class::Iterator/next> exhausts that initial cache of results it will automatically make subsequent calls to the REST API to fetch more results). | ||||||||||||||||||||||||||||
| 444 | #pod | ||||||||||||||||||||||||||||
| 445 | #pod Defaults to 50. | ||||||||||||||||||||||||||||
| 446 | #pod | ||||||||||||||||||||||||||||
| 447 | #pod say $jira->maxResults; # returns 50 | ||||||||||||||||||||||||||||
| 448 | #pod | ||||||||||||||||||||||||||||
| 449 | #pod $jira->maxResults(10); # only return 10 results at a time | ||||||||||||||||||||||||||||
| 450 | #pod | ||||||||||||||||||||||||||||
| 451 | #pod =cut | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 3 | ▶ | sub maxResults { | ||||||||||||||||||||||||||
|
Subroutine
maxResults: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 454 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 455 | 3 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 456 | 1 | $self->{maxResults} = shift; | |||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | 3 | ▶ | unless ( exists $self->{maxResults} && defined $self->{maxResults} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{"maxResults"} and defined $self->{"maxResults"}
MC/DC50%1/2
exists $self->{"maxResults"} and defined $self->{"maxResults"}
exists $self->{"maxResults"}
defined $self->{"maxResults"}
Truth table66%2/3
A and B
A= exists $self->{"maxResults"}B= defined $self->{"maxResults"}
| |||||||||||||||||||||||||||||
| 459 | 1 | $self->{maxResults} = $DEFAULT_MAXRESULTS; | |||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||
| 461 | 3 | return $self->{maxResults}; | |||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | #pod =method B<issue_types> | ||||||||||||||||||||||||||||
| 465 | #pod | ||||||||||||||||||||||||||||
| 466 | #pod Returns a list of defined issue types (as | ||||||||||||||||||||||||||||
| 467 | #pod L<JIRA::REST::Class::Issue::Type|JIRA::REST::Class::Issue::Type> objects) | ||||||||||||||||||||||||||||
| 468 | #pod for this server. | ||||||||||||||||||||||||||||
| 469 | #pod | ||||||||||||||||||||||||||||
| 470 | #pod =cut | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | 3 | ▶ | sub issue_types { | ||||||||||||||||||||||||||
|
Subroutine
issue_types: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 473 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 3 | ▶ | unless ( $self->{issue_types} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 476 | 1 | my $types = $self->get( '/issuetype' ); | |||||||||||||||||||||||||||
| 477 | $self->{issue_types} = [ # stop perltidy from pulling | ||||||||||||||||||||||||||||
| 478 | map { # these lines together | ||||||||||||||||||||||||||||
| 479 | 1 | $self->make_object( 'issuetype', { data => $_ } ); | |||||||||||||||||||||||||||
| 480 | } @$types | ||||||||||||||||||||||||||||
| 481 | ]; | ||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 3 | ▶ | return @{ $self->{issue_types} } if wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 485 | 1 | return $self->{issue_types}; | |||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | #pod =begin testing issue_types 16 | ||||||||||||||||||||||||||||
| 491 | #pod | ||||||||||||||||||||||||||||
| 492 | #pod try { | ||||||||||||||||||||||||||||
| 493 | #pod my $test = get_test_client(); | ||||||||||||||||||||||||||||
| 494 | #pod | ||||||||||||||||||||||||||||
| 495 | #pod validate_contextual_accessor($test, { | ||||||||||||||||||||||||||||
| 496 | #pod method => 'issue_types', | ||||||||||||||||||||||||||||
| 497 | #pod class => 'issuetype', | ||||||||||||||||||||||||||||
| 498 | #pod data => [ sort qw/ Bug Epic Improvement Sub-task Story Task /, | ||||||||||||||||||||||||||||
| 499 | #pod 'New Feature' ], | ||||||||||||||||||||||||||||
| 500 | #pod }); | ||||||||||||||||||||||||||||
| 501 | #pod | ||||||||||||||||||||||||||||
| 502 | #pod print "#\n# Checking the 'Bug' issue type\n#\n"; | ||||||||||||||||||||||||||||
| 503 | #pod | ||||||||||||||||||||||||||||
| 504 | #pod my ($bug) = sort $test->issue_types; | ||||||||||||||||||||||||||||
| 505 | #pod | ||||||||||||||||||||||||||||
| 506 | #pod can_ok_abstract( $bug, qw/ description iconUrl id name self subtask / ); | ||||||||||||||||||||||||||||
| 507 | #pod | ||||||||||||||||||||||||||||
| 508 | #pod my $host = TestServer_url(); | ||||||||||||||||||||||||||||
| 509 | #pod | ||||||||||||||||||||||||||||
| 510 | #pod validate_expected_fields( $bug, { | ||||||||||||||||||||||||||||
| 511 | #pod description => "jira.translation.issuetype.bug.name.desc", | ||||||||||||||||||||||||||||
| 512 | #pod iconUrl => "$host/secure/viewavatar?size=xsmall&avatarId=10303" | ||||||||||||||||||||||||||||
| 513 | #pod . "&avatarType=issuetype", | ||||||||||||||||||||||||||||
| 514 | #pod id => 10004, | ||||||||||||||||||||||||||||
| 515 | #pod name => "Bug", | ||||||||||||||||||||||||||||
| 516 | #pod self => "$host/rest/api/latest/issuetype/10004", | ||||||||||||||||||||||||||||
| 517 | #pod subtask => JSON::PP::false, | ||||||||||||||||||||||||||||
| 518 | #pod }); | ||||||||||||||||||||||||||||
| 519 | #pod }; | ||||||||||||||||||||||||||||
| 520 | #pod | ||||||||||||||||||||||||||||
| 521 | #pod =end testing | ||||||||||||||||||||||||||||
| 522 | #pod | ||||||||||||||||||||||||||||
| 523 | #pod =cut | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | #pod =method B<projects> | ||||||||||||||||||||||||||||
| 528 | #pod | ||||||||||||||||||||||||||||
| 529 | #pod Returns a list of projects (as | ||||||||||||||||||||||||||||
| 530 | #pod L<JIRA::REST::Class::Project|JIRA::REST::Class::Project> objects) for this | ||||||||||||||||||||||||||||
| 531 | #pod server. | ||||||||||||||||||||||||||||
| 532 | #pod | ||||||||||||||||||||||||||||
| 533 | #pod =cut | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | 3 | ▶ | sub projects { | ||||||||||||||||||||||||||
|
Subroutine
projects: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 536 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | 3 | ▶ | unless ( $self->{project_list} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | # get the project list from JIRA | ||||||||||||||||||||||||||||
| 541 | 1 | my $projects = $self->get( '/project' ); | |||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | # build a list, and make a hash so we can | ||||||||||||||||||||||||||||
| 544 | # grab projects later by id, key, or name. | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | 1 | my $list = $self->{project_list} = []; | |||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | 5 | ▶ | my $make_project_hash_entry = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 549 | 5 | my $prj = shift; | |||||||||||||||||||||||||||
| 550 | 5 | my $obj = $self->make_object( 'project', { data => $prj } ); | |||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | 5 | push @$list, $obj; | |||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | 5 | return $obj->id => $obj, $obj->key => $obj, $obj->name => $obj; | |||||||||||||||||||||||||||
| 555 | 1 | }; | |||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | $self->{project_hash} = { ## | ||||||||||||||||||||||||||||
| 558 | 1 | map { $make_project_hash_entry->( $_ ) } @$projects | |||||||||||||||||||||||||||
| 559 | }; | ||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | 3 | ▶ | return @{ $self->{project_list} } if wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 563 | 2 | return $self->{project_list}; | |||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | #pod =begin testing projects 5 | ||||||||||||||||||||||||||||
| 569 | #pod | ||||||||||||||||||||||||||||
| 570 | #pod my $test = get_test_client(); | ||||||||||||||||||||||||||||
| 571 | #pod | ||||||||||||||||||||||||||||
| 572 | #pod try { | ||||||||||||||||||||||||||||
| 573 | #pod validate_contextual_accessor($test, { | ||||||||||||||||||||||||||||
| 574 | #pod method => 'projects', | ||||||||||||||||||||||||||||
| 575 | #pod class => 'project', | ||||||||||||||||||||||||||||
| 576 | #pod data => [ qw/ JRC KANBAN PACKAY PM SCRUM / ], | ||||||||||||||||||||||||||||
| 577 | #pod }); | ||||||||||||||||||||||||||||
| 578 | #pod }; | ||||||||||||||||||||||||||||
| 579 | #pod | ||||||||||||||||||||||||||||
| 580 | #pod =end testing | ||||||||||||||||||||||||||||
| 581 | #pod | ||||||||||||||||||||||||||||
| 582 | #pod =cut | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | #pod =method B<project> PROJECT_ID || PROJECT_KEY || PROJECT_NAME | ||||||||||||||||||||||||||||
| 587 | #pod | ||||||||||||||||||||||||||||
| 588 | #pod Returns a L<JIRA::REST::Class::Project|JIRA::REST::Class::Project> object | ||||||||||||||||||||||||||||
| 589 | #pod for the project specified. Returns undef if the project doesn't exist. | ||||||||||||||||||||||||||||
| 590 | #pod | ||||||||||||||||||||||||||||
| 591 | #pod =cut | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | 1 | ▶ | sub project { | ||||||||||||||||||||||||||
|
Subroutine
project: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 594 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 595 | 1 | ▶ | my $proj = shift || return; # if nothing was passed, we return nothing | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | # if we were passed a project object, just return it | ||||||||||||||||||||||||||||
| 598 | 1 | ▶ | return $proj if $self->obj_isa( $proj, 'project' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | 1 | $self->projects; # load the project hash if it hasn't been loaded | |||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | 1 | ▶ | return unless exists $self->{project_hash}->{$proj}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 603 | 1 | return $self->{project_hash}->{$proj}; | |||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | #pod =begin testing project 17 | ||||||||||||||||||||||||||||
| 609 | #pod | ||||||||||||||||||||||||||||
| 610 | #pod try { | ||||||||||||||||||||||||||||
| 611 | #pod print "#\n# Checking the SCRUM project\n#\n"; | ||||||||||||||||||||||||||||
| 612 | #pod | ||||||||||||||||||||||||||||
| 613 | #pod my $test = get_test_client(); | ||||||||||||||||||||||||||||
| 614 | #pod | ||||||||||||||||||||||||||||
| 615 | #pod my $proj = $test->project('SCRUM'); | ||||||||||||||||||||||||||||
| 616 | #pod | ||||||||||||||||||||||||||||
| 617 | #pod can_ok_abstract( $proj, qw/ avatarUrls expand id key name self | ||||||||||||||||||||||||||||
| 618 | #pod category assigneeType components | ||||||||||||||||||||||||||||
| 619 | #pod description issueTypes lead roles versions | ||||||||||||||||||||||||||||
| 620 | #pod allowed_components allowed_versions | ||||||||||||||||||||||||||||
| 621 | #pod allowed_fix_versions allowed_issue_types | ||||||||||||||||||||||||||||
| 622 | #pod allowed_priorities allowed_field_values | ||||||||||||||||||||||||||||
| 623 | #pod field_metadata_exists field_metadata | ||||||||||||||||||||||||||||
| 624 | #pod field_name | ||||||||||||||||||||||||||||
| 625 | #pod / ); | ||||||||||||||||||||||||||||
| 626 | #pod | ||||||||||||||||||||||||||||
| 627 | #pod validate_expected_fields( $proj, { | ||||||||||||||||||||||||||||
| 628 | #pod expand => "description,lead,url,projectKeys", | ||||||||||||||||||||||||||||
| 629 | #pod id => 10002, | ||||||||||||||||||||||||||||
| 630 | #pod key => 'SCRUM', | ||||||||||||||||||||||||||||
| 631 | #pod name => "Scrum Software Development Sample Project", | ||||||||||||||||||||||||||||
| 632 | #pod projectTypeKey => "software", | ||||||||||||||||||||||||||||
| 633 | #pod lead => { | ||||||||||||||||||||||||||||
| 634 | #pod class => 'user', | ||||||||||||||||||||||||||||
| 635 | #pod expected => { | ||||||||||||||||||||||||||||
| 636 | #pod key => 'packy' | ||||||||||||||||||||||||||||
| 637 | #pod }, | ||||||||||||||||||||||||||||
| 638 | #pod }, | ||||||||||||||||||||||||||||
| 639 | #pod }); | ||||||||||||||||||||||||||||
| 640 | #pod | ||||||||||||||||||||||||||||
| 641 | #pod validate_contextual_accessor($proj, { | ||||||||||||||||||||||||||||
| 642 | #pod method => 'versions', | ||||||||||||||||||||||||||||
| 643 | #pod class => 'projectvers', | ||||||||||||||||||||||||||||
| 644 | #pod name => "SCRUM project's", | ||||||||||||||||||||||||||||
| 645 | #pod data => [ "Version 1.0", "Version 2.0", "Version 3.0" ], | ||||||||||||||||||||||||||||
| 646 | #pod }); | ||||||||||||||||||||||||||||
| 647 | #pod }; | ||||||||||||||||||||||||||||
| 648 | #pod | ||||||||||||||||||||||||||||
| 649 | #pod =end testing | ||||||||||||||||||||||||||||
| 650 | #pod | ||||||||||||||||||||||||||||
| 651 | #pod =cut | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | #pod =method B<SSL_verify_none> | ||||||||||||||||||||||||||||
| 656 | #pod | ||||||||||||||||||||||||||||
| 657 | #pod Sets to false the SSL options C<SSL_verify_mode> and C<verify_hostname> on | ||||||||||||||||||||||||||||
| 658 | #pod the L<LWP::UserAgent|LWP::UserAgent> object that is used by | ||||||||||||||||||||||||||||
| 659 | #pod L<REST::Client|REST::Client> (which, in turn, is used by | ||||||||||||||||||||||||||||
| 660 | #pod L<JIRA::REST|JIRA::REST>, which is used by this module). | ||||||||||||||||||||||||||||
| 661 | #pod | ||||||||||||||||||||||||||||
| 662 | #pod =cut | ||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | 1 | ▶ | sub SSL_verify_none { ## no critic (NamingConventions::Capitalization) | ||||||||||||||||||||||||||
|
Subroutine
SSL_verify_none: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 665 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 666 | 1 | return $self->REST_CLIENT->getUseragent()->ssl_opts( | |||||||||||||||||||||||||||
| 667 | SSL_verify_mode => 0, | ||||||||||||||||||||||||||||
| 668 | verify_hostname => 0 | ||||||||||||||||||||||||||||
| 669 | ); | ||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||
| 672 | #pod =internal_method B<rest_api_url_base> | ||||||||||||||||||||||||||||
| 673 | #pod | ||||||||||||||||||||||||||||
| 674 | #pod Returns the base URL for this JIRA server's REST API. For example, if your JIRA server is at C<http://jira.example.com>, this would return C<http://jira.example.com/rest/api/latest>. | ||||||||||||||||||||||||||||
| 675 | #pod | ||||||||||||||||||||||||||||
| 676 | #pod =cut | ||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||
| 678 | 2 | ▶ | sub rest_api_url_base { | ||||||||||||||||||||||||||
|
Subroutine
rest_api_url_base: called CC=4 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||
| 679 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 680 | 2 | ▶ | if ( $self->_JIRA_REST_version_has_separate_path ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 681 | 2 | ( my $host = $self->REST_CLIENT->getHost ) =~ s{/$}{}xms; | |||||||||||||||||||||||||||
| 682 | 2 | ▶ | my $path = $self->JIRA_REST->{path} // q{/rest/api/latest}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->JIRA_REST->{"path"} // "/rest/api/latest"
MC/DC0%0/1
$self->JIRA_REST->{"path"} // "/rest/api/latest"
$self->JIRA_REST->{"path"}
Truth table50%1/2
A
A= $self->JIRA_REST->{"path"}
| |||||||||||||||||||||||||||||
| 683 | 2 | return $host . $path; | |||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||
| 685 | else { | ||||||||||||||||||||||||||||
| 686 | 0 | my ( $base ) | |||||||||||||||||||||||||||
| 687 | = $self->REST_CLIENT->getHost =~ m{^(.+?rest/api/[^/]+)/?}xms; | ||||||||||||||||||||||||||||
| 688 | 0 | ▶ | return $base // $self->REST_CLIENT->getHost . '/rest/api/latest'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$base // $self->REST_CLIENT->getHost . '/rest/api/latest'
MC/DC0%0/1
$base // $self->REST_CLIENT->getHost . '/rest/api/latest'
$base
Truth table0%0/2
A
A= $base
| |||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | #pod =internal_method B<strip_protocol_and_host> | ||||||||||||||||||||||||||||
| 693 | #pod | ||||||||||||||||||||||||||||
| 694 | #pod A method to take the provided URL and strip the protocol and host from it. For example, if the URL C<http://jira.example.com/rest/api/latest> was passed to this method, C</rest/api/latest> would be returned. | ||||||||||||||||||||||||||||
| 695 | #pod | ||||||||||||||||||||||||||||
| 696 | #pod =cut | ||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | 1 | ▶ | sub strip_protocol_and_host { | ||||||||||||||||||||||||||
|
Subroutine
strip_protocol_and_host: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 699 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 700 | 1 | my $host = $self->REST_CLIENT->getHost; | |||||||||||||||||||||||||||
| 701 | 1 | ( my $url = shift ) =~ s{^$host}{}xms; | |||||||||||||||||||||||||||
| 702 | 1 | return $url; | |||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||
| 705 | #pod =accessor B<args> | ||||||||||||||||||||||||||||
| 706 | #pod | ||||||||||||||||||||||||||||
| 707 | #pod An accessor that returns a copy of the arguments passed to the | ||||||||||||||||||||||||||||
| 708 | #pod constructor. Useful for passing around to utility objects. | ||||||||||||||||||||||||||||
| 709 | #pod | ||||||||||||||||||||||||||||
| 710 | #pod =cut | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | 14 | ▶ | sub args { return shift->{args} } | ||||||||||||||||||||||||||
|
Subroutine
args: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | #pod =accessor B<url> | ||||||||||||||||||||||||||||
| 715 | #pod | ||||||||||||||||||||||||||||
| 716 | #pod An accessor that returns the C<url> parameter passed to this object's | ||||||||||||||||||||||||||||
| 717 | #pod constructor. | ||||||||||||||||||||||||||||
| 718 | #pod | ||||||||||||||||||||||||||||
| 719 | #pod =cut | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | 2 | ▶ | sub url { return shift->args->{url} } | ||||||||||||||||||||||||||
|
Subroutine
url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||
| 723 | #pod =accessor B<username> | ||||||||||||||||||||||||||||
| 724 | #pod | ||||||||||||||||||||||||||||
| 725 | #pod An accessor that returns the username used to connect to the JIRA server, | ||||||||||||||||||||||||||||
| 726 | #pod even if the username was read from a C<.netrc> or | ||||||||||||||||||||||||||||
| 727 | #pod L<Config::Identity|Config::Identity> file. | ||||||||||||||||||||||||||||
| 728 | #pod | ||||||||||||||||||||||||||||
| 729 | #pod =cut | ||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||
| 731 | 2 | ▶ | sub username { | ||||||||||||||||||||||||||
|
Subroutine
username: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 732 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | 2 | ▶ | unless ( defined $self->args->{username} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 735 | 0 | $self->args->{username} = $self->user_object->name; | |||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | 2 | return $self->args->{username}; | |||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||
| 741 | #pod =accessor B<user_object> | ||||||||||||||||||||||||||||
| 742 | #pod | ||||||||||||||||||||||||||||
| 743 | #pod An accessor that returns the user used to connect to the JIRA server as a | ||||||||||||||||||||||||||||
| 744 | #pod L<JIRA::REST::Class::User|JIRA::REST::Class::User> object, even if the username | ||||||||||||||||||||||||||||
| 745 | #pod was read from a C<.netrc> or L<Config::Identity|Config::Identity> file. Works | ||||||||||||||||||||||||||||
| 746 | #pod by making the JIRA REST API call L</rest/api/latest/myself|https://docs.atlassian.com/jira/REST/cloud/#api/2/myself>. | ||||||||||||||||||||||||||||
| 747 | #pod | ||||||||||||||||||||||||||||
| 748 | #pod =cut | ||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||
| 750 | 1 | ▶ | sub user_object { | ||||||||||||||||||||||||||
|
Subroutine
user_object: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 751 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | 1 | ▶ | unless ( defined $self->{userobj} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 754 | 1 | my $data = $self->get( '/myself' ); | |||||||||||||||||||||||||||
| 755 | 1 | $self->{userobj} = $self->make_object( 'user', { data => $data } ); | |||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||
| 758 | 1 | return $self->{userobj}; | |||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||
| 761 | #pod =accessor B<password> | ||||||||||||||||||||||||||||
| 762 | #pod | ||||||||||||||||||||||||||||
| 763 | #pod An accessor that returns the password used to connect to the JIRA server, | ||||||||||||||||||||||||||||
| 764 | #pod even if the username was read from a C<.netrc> or | ||||||||||||||||||||||||||||
| 765 | #pod L<Config::Identity|Config::Identity> file. | ||||||||||||||||||||||||||||
| 766 | #pod | ||||||||||||||||||||||||||||
| 767 | #pod =cut | ||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | 2 | ▶ | sub password { | ||||||||||||||||||||||||||
|
Subroutine
password: called CC=3 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||
| 770 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||
| 772 | 2 | ▶ | unless ( $self->args->{password} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||
| 774 | # we don't have the password cached, so get it from | ||||||||||||||||||||||||||||
| 775 | # the Authorization header we're sending to JIRA | ||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||
| 777 | 0 | my $rest = $self->JIRA_REST->{rest}; | |||||||||||||||||||||||||||
| 778 | 0 | ▶ | if ( my $auth = $rest->{_headers}->{Authorization} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 779 | 0 | my ( undef, $encoded ) = split /\s+/, $auth; | |||||||||||||||||||||||||||
| 780 | 0 | ( undef, $self->args->{password} ) = | |||||||||||||||||||||||||||
| 781 | split /:/, decode_base64 $encoded; | ||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||
| 785 | 2 | return $self->args->{password}; | |||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||
| 788 | #pod =accessor B<rest_client_config> | ||||||||||||||||||||||||||||
| 789 | #pod | ||||||||||||||||||||||||||||
| 790 | #pod An accessor that returns the C<rest_client_config> parameter passed to this | ||||||||||||||||||||||||||||
| 791 | #pod object's constructor. | ||||||||||||||||||||||||||||
| 792 | #pod | ||||||||||||||||||||||||||||
| 793 | #pod =cut | ||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||
| 795 | 1 | ▶ | sub rest_client_config { return shift->args->{rest_client_config} } | ||||||||||||||||||||||||||
|
Subroutine
rest_client_config: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||
| 797 | #pod =accessor B<anonymous> | ||||||||||||||||||||||||||||
| 798 | #pod | ||||||||||||||||||||||||||||
| 799 | #pod An accessor that returns the C<anonymous> parameter passed to this object's constructor. | ||||||||||||||||||||||||||||
| 800 | #pod | ||||||||||||||||||||||||||||
| 801 | #pod =cut | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | 1 | ▶ | sub anonymous { return shift->args->{anonymous} } | ||||||||||||||||||||||||||
|
Subroutine
anonymous: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||
| 805 | #pod =accessor B<proxy> | ||||||||||||||||||||||||||||
| 806 | #pod | ||||||||||||||||||||||||||||
| 807 | #pod An accessor that returns the C<proxy> parameter passed to this object's constructor. | ||||||||||||||||||||||||||||
| 808 | #pod | ||||||||||||||||||||||||||||
| 809 | #pod =cut | ||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||
| 811 | 1 | ▶ | sub proxy { return shift->args->{proxy} } | ||||||||||||||||||||||||||
|
Subroutine
proxy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||
| 813 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||
| 815 | #pod =begin testing parameter_accessors 15 | ||||||||||||||||||||||||||||
| 816 | #pod | ||||||||||||||||||||||||||||
| 817 | #pod try { | ||||||||||||||||||||||||||||
| 818 | #pod print "#\n# Checking parameter accessors\n#\n"; | ||||||||||||||||||||||||||||
| 819 | #pod | ||||||||||||||||||||||||||||
| 820 | #pod my $test = get_test_client(); | ||||||||||||||||||||||||||||
| 821 | #pod my $url = TestServer_url(); | ||||||||||||||||||||||||||||
| 822 | #pod | ||||||||||||||||||||||||||||
| 823 | #pod my $args = { | ||||||||||||||||||||||||||||
| 824 | #pod url => $url, | ||||||||||||||||||||||||||||
| 825 | #pod username => 'username', | ||||||||||||||||||||||||||||
| 826 | #pod password => 'password', | ||||||||||||||||||||||||||||
| 827 | #pod proxy => undef, | ||||||||||||||||||||||||||||
| 828 | #pod anonymous => undef, | ||||||||||||||||||||||||||||
| 829 | #pod rest_client_config => undef, | ||||||||||||||||||||||||||||
| 830 | #pod ssl_verify_none => undef, | ||||||||||||||||||||||||||||
| 831 | #pod }; | ||||||||||||||||||||||||||||
| 832 | #pod | ||||||||||||||||||||||||||||
| 833 | #pod # the args accessor will have keys for ALL the possible arguments, | ||||||||||||||||||||||||||||
| 834 | #pod # whether they were passed in or not. | ||||||||||||||||||||||||||||
| 835 | #pod | ||||||||||||||||||||||||||||
| 836 | #pod cmp_deeply( $test, | ||||||||||||||||||||||||||||
| 837 | #pod methods( args => { %$args, }, | ||||||||||||||||||||||||||||
| 838 | #pod url => $args->{url}, | ||||||||||||||||||||||||||||
| 839 | #pod username => $args->{username}, | ||||||||||||||||||||||||||||
| 840 | #pod password => $args->{password}, | ||||||||||||||||||||||||||||
| 841 | #pod proxy => $args->{proxy}, | ||||||||||||||||||||||||||||
| 842 | #pod anonymous => $args->{anonymous}, | ||||||||||||||||||||||||||||
| 843 | #pod rest_client_config => $args->{rest_client_config} ), | ||||||||||||||||||||||||||||
| 844 | #pod q{All accessors for parameters passed }. | ||||||||||||||||||||||||||||
| 845 | #pod q{into the constructor okay}); | ||||||||||||||||||||||||||||
| 846 | #pod | ||||||||||||||||||||||||||||
| 847 | #pod my $ua = $test->REST_CLIENT->getUseragent(); | ||||||||||||||||||||||||||||
| 848 | #pod $test->SSL_verify_none; | ||||||||||||||||||||||||||||
| 849 | #pod cmp_deeply($ua->{ssl_opts}, { SSL_verify_mode => 0, verify_hostname => 0 }, | ||||||||||||||||||||||||||||
| 850 | #pod q{SSL_verify_none() does disable SSL verification}); | ||||||||||||||||||||||||||||
| 851 | #pod | ||||||||||||||||||||||||||||
| 852 | #pod is($test->rest_api_url_base($url . "/rest/api/latest/foo"), | ||||||||||||||||||||||||||||
| 853 | #pod $url . "/rest/api/latest", q{rest_api_url_base() works as expected}); | ||||||||||||||||||||||||||||
| 854 | #pod | ||||||||||||||||||||||||||||
| 855 | #pod is($test->strip_protocol_and_host($test->REST_CLIENT->getHost . "/foo"), | ||||||||||||||||||||||||||||
| 856 | #pod "/foo", q{strip_protocol_and_host() works as expected}); | ||||||||||||||||||||||||||||
| 857 | #pod | ||||||||||||||||||||||||||||
| 858 | #pod is($test->maxResults, 50, q{maxResults() default is correct}); | ||||||||||||||||||||||||||||
| 859 | #pod | ||||||||||||||||||||||||||||
| 860 | #pod is($test->maxResults(10), 10, q{maxResults(N) returns N}); | ||||||||||||||||||||||||||||
| 861 | #pod | ||||||||||||||||||||||||||||
| 862 | #pod is($test->maxResults, 10, | ||||||||||||||||||||||||||||
| 863 | #pod q{maxResults() was successfully set by previous call}); | ||||||||||||||||||||||||||||
| 864 | #pod | ||||||||||||||||||||||||||||
| 865 | #pod print "# testing user_object() accessor\n"; | ||||||||||||||||||||||||||||
| 866 | #pod my $userobj = $test->user_object(); | ||||||||||||||||||||||||||||
| 867 | #pod | ||||||||||||||||||||||||||||
| 868 | #pod validate_expected_fields( $userobj, { | ||||||||||||||||||||||||||||
| 869 | #pod key => 'packy', | ||||||||||||||||||||||||||||
| 870 | #pod name => 'packy', | ||||||||||||||||||||||||||||
| 871 | #pod displayName => "Packy Anderson", | ||||||||||||||||||||||||||||
| 872 | #pod emailAddress => 'packy\@cpan.org', | ||||||||||||||||||||||||||||
| 873 | #pod }); | ||||||||||||||||||||||||||||
| 874 | #pod | ||||||||||||||||||||||||||||
| 875 | #pod }; | ||||||||||||||||||||||||||||
| 876 | #pod | ||||||||||||||||||||||||||||
| 877 | #pod =end testing | ||||||||||||||||||||||||||||
| 878 | #pod | ||||||||||||||||||||||||||||
| 879 | #pod =cut | ||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||
| 881 | #--------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||
| 883 | 4 | 1; | |||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||
| 885 | __END__ | ||||||||||||||||||||||||||||