Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rename to ::Extension::NetworkedHelpDesk

  • Loading branch information...
commit fe51dcc2bdc16c907c3e27ad63a42effc9fab9d9 1 parent fce47f2
@ruz ruz authored
View
2  META.yml
@@ -13,7 +13,7 @@ license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
-name: RT-Extension-NHD
+name: RT-Extension-NetworkedHelpDesk
no_index:
directory:
- etc
View
6 Makefile.PL
@@ -1,7 +1,7 @@
use inc::Module::Install;
-RTx('RT-Extension-NHD');
-all_from('lib/RT/Extension/NHD.pm');
-#readme_from('lib/RT/Extension/NHD.pm');
+RTx('RT-Extension-NetworkedHelpDesk');
+all_from('lib/RT/Extension/NetworkedHelpDesk.pm');
+readme_from('lib/RT/Extension/NetworkedHelpDesk.pm');
WriteAll;
View
32 html/NoAuth/NHD/1.0/agreements/dhandler
@@ -8,52 +8,52 @@ $status => undef
</%ARGS>
<%INIT>
my $duuid = $m->dhandler_arg;
-unless ( RT::Extension::NHD->CheckUUID( $duuid ) ) {
- return RT::Extension::NHD->BadWebRequest(
+unless ( RT::Extension::NetworkedHelpDesk->CheckUUID( $duuid ) ) {
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest(
'Unprocessable Entity',
"Value in the URI isn't a UUID"
);
}
-my $action = RT::Extension::NHD->WebRequestAction;
-return RT::Extension::NHD->BadWebRequest('Method Not Allowed')
+my $action = RT::Extension::NetworkedHelpDesk->WebRequestAction;
+return RT::Extension::NetworkedHelpDesk->BadWebRequest('Method Not Allowed')
unless $action;
if ( $action ne 'create' ) {
$ARGS{'uuid'} = $uuid ||= $duuid;
} elsif ( ($uuid||'') ne $duuid ) {
- return RT::Extension::NHD->BadWebRequest(
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest(
'Unprocessable Entity',
"UUIDs in the URI and body don't match"
);
}
my $token = $r->headers_in->{'X-Ticket-Sharing-Token'};
-return RT::Extension::NHD->BadWebRequest('Unauthorized')
+return RT::Extension::NetworkedHelpDesk->BadWebRequest('Unauthorized')
unless $token;
my $agreement = RT::NHD::Agreement->new( RT->SystemUser );
$agreement->Load( $uuid );
if ( $action eq 'create' && $agreement->id ) {
- return RT::Extension::NHD->BadWebRequest(
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest(
'Unprocessable Entity',
"Couldn't create an agreement: record already exists"
);
}
elsif ( $action ne 'create' ) {
- return RT::Extension::NHD->BadWebRequest('Not Found')
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest('Not Found')
unless $agreement->id;
if ( $token ne join ':', $agreement->UUID, $agreement->AccessKey ) {
- return RT::Extension::NHD->BadWebRequest('Forbidden')
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest('Forbidden')
}
}
my %data = %{ $agreement->FromJSON( \%ARGS ) };
my ($user, $msg) = $agreement->LoadOrCreateUser( %data );
-return RT::Extension::NHD->BadWebRequest(
+return RT::Extension::NetworkedHelpDesk->BadWebRequest(
'Unprocessable Entity',
"Couldn't create user: $msg"
) unless $user;
@@ -63,26 +63,26 @@ $agreement->CurrentUser( RT::CurrentUser->new( $user ) );
if ( $agreement->id ) {
if ( $action eq 'show' ) {
- return RT::Extension::NHD->WebSendJSON( $agreement->ForJSON );
+ return RT::Extension::NetworkedHelpDesk->WebSendJSON( $agreement->ForJSON );
}
elsif ( $action eq 'update' ) {
my ($status, $msg) = $agreement->Update( %data );
unless ( $status ) {
RT->Logger->error("Couldn't update NHD agreement: $msg");
- return RT::Extension::NHD->BadWebRequest('Unprocessable Entity');
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest('Unprocessable Entity');
}
- return RT::Extension::NHD->GoodWebRequest;
+ return RT::Extension::NetworkedHelpDesk->GoodWebRequest;
}
else {
- return RT::Extension::NHD->BadWebRequest;
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest;
}
}
else {
my ($status, $msg) = $agreement->Create( %data );
unless ( $status ) {
RT->Logger->error("Couldn't create NHD agreement: $msg");
- return RT::Extension::NHD->BadWebRequest('Unprocessable Entity');
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest('Unprocessable Entity');
}
- return RT::Extension::NHD->GoodWebRequest('Created');
+ return RT::Extension::NetworkedHelpDesk->GoodWebRequest('Created');
}
</%INIT>
View
6 html/NoAuth/NHD/1.0/autohandler
@@ -1,7 +1,7 @@
<%INIT>
my $version = $r->headers_in->{'X-Ticket-Sharing-Version'};
if ( ($version||'') ne '1' ) {
- return RT::Extension::NHD->BadWebRequest('Precondition Failed');
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest('Precondition Failed');
}
my $ct = $r->headers_in->{'Content-Type'};
@@ -15,8 +15,8 @@ if ( $method ne 'GET' && (!$ct || $ct =~ m{^text/x-json}) ) {
seek $input, 0, 0;
my $content = do { local $/; <$input> };
- $data = RT::Extension::NHD->FromJSON( $content );
- return RT::Extension::NHD->BadWebRequest unless $data;
+ $data = RT::Extension::NetworkedHelpDesk->FromJSON( $content );
+ return RT::Extension::NetworkedHelpDesk->BadWebRequest unless $data;
}
$m->call_next( %$data );
View
6 lib/RT/Extension/NHD.pm → lib/RT/Extension/NetworkedHelpDesk.pm
@@ -2,12 +2,12 @@ use 5.008003;
use strict;
use warnings;
-package RT::Extension::NHD;
+package RT::Extension::NetworkedHelpDesk;
our $VERSION = '0.01';
=head1 NAME
-RT::Extension::NHD - Networked Help Desk protocol for Request Tracker
+RT::Extension::NetworkedHelpDesk - Networked Help Desk protocol for Request Tracker
=head1 DESCRIPTION
@@ -39,7 +39,7 @@ sub JSONRequest {
my ($method, $uri, %args) = @_;
my $data;
- $data = RT::Extension::NHD->ToJSON( delete $args{'Data'} )
+ $data = RT::Extension::NetworkedHelpDesk->ToJSON( delete $args{'Data'} )
unless uc($method) eq 'GET';
my %headers = %{ delete $args{'Headers'} || {} };
%headers = (
View
22 lib/RT/Extension/NHD/Test.pm → lib/RT/Extension/NetworkedHelpDesk/Test.pm
@@ -4,7 +4,7 @@ use warnings;
### after: use lib qw(@RT_LIB_PATH@);
use lib qw(/opt/rt4/local/lib /opt/rt4/lib);
-package RT::Extension::NHD::Test;
+package RT::Extension::NetworkedHelpDesk::Test;
use base 'RT::Test';
sub import {
@@ -13,17 +13,17 @@ sub import {
$args{'requires'} ||= [];
if ( $args{'testing'} ) {
- unshift @{ $args{'requires'} }, 'RT::Extension::NHD';
+ unshift @{ $args{'requires'} }, 'RT::Extension::NetworkedHelpDesk';
} else {
- $args{'testing'} = 'RT::Extension::NHD';
+ $args{'testing'} = 'RT::Extension::NetworkedHelpDesk';
}
$class->SUPER::import( %args );
$class->export_to_level(1);
no strict 'subs';
- my $orig = \&RT::Extension::NHD::SendRequest;
- *RT::Extension::NHD::SendRequest = sub {
+ my $orig = \&RT::Extension::NetworkedHelpDesk::SendRequest;
+ *RT::Extension::NetworkedHelpDesk::SendRequest = sub {
return $orig->(@_) if $_[1] && $_[1]->uri =~ RT->Config->Get('WebDomain');
my $self = shift;
@@ -34,18 +34,18 @@ sub import {
sub new_agent {
my $self = shift;
- require RT::Extension::NHD::Test::Web;
- return RT::Extension::NHD::Test::Web->new_agent( @_ );
+ require RT::Extension::NetworkedHelpDesk::Test::Web;
+ return RT::Extension::NetworkedHelpDesk::Test::Web->new_agent( @_ );
}
-sub remote_requests { return RT::Extension::NHD::Test->get_objects_from_file('requests') }
+sub remote_requests { return RT::Extension::NetworkedHelpDesk::Test->get_objects_from_file('requests') }
sub set_next_remote_response {
my $self = shift;
my $code = shift;
my %args = @_;
- my $msg = $args{'Message'} || $RT::Extension::NHD::HTTP_MESSAGE{ $code }
+ my $msg = $args{'Message'} || $RT::Extension::NetworkedHelpDesk::HTTP_MESSAGE{ $code }
|| die "no message for code $code";
my %headers = %{ $args{'Headers'} || {} };
@@ -54,9 +54,9 @@ sub set_next_remote_response {
'X-Ticket-Sharing-Version' => '1',
);
my $content = $args{'Data'};
- $content = RT::Extension::NHD->ToJSON( $content )
+ $content = RT::Extension::NetworkedHelpDesk->ToJSON( $content )
if ref $content;
- RT::Extension::NHD::Test->push_object_into_file( responses => HTTP::Response->new(
+ RT::Extension::NetworkedHelpDesk::Test->push_object_into_file( responses => HTTP::Response->new(
$code, $msg, [%headers], $content,
) );
return;
View
6 lib/RT/Extension/NHD/Test/Web.pm → ...T/Extension/NetworkedHelpDesk/Test/Web.pm
@@ -1,10 +1,10 @@
use strict;
use warnings;
-package RT::Extension::NHD::Test::Web;
+package RT::Extension::NetworkedHelpDesk::Test::Web;
use base qw(RT::Test::Web);
-require RT::Extension::NHD::Test;
+require RT::Extension::NetworkedHelpDesk::Test;
require Test::More;
sub new_agent {
@@ -20,7 +20,7 @@ sub json_request {
my $self = shift;
my ($method, $uri, %args) = @_;
$uri = $self->rt_base_url .'NoAuth/NHD/1.0'. $uri;
- RT::Extension::NHD->JSONRequest( $method, $uri, %args );
+ RT::Extension::NetworkedHelpDesk->JSONRequest( $method, $uri, %args );
}
1;
View
10 lib/RT/NHD/Agreement.pm
@@ -14,7 +14,7 @@ sub Table {'NHDAgreements'}
sub Load {
my $self = shift;
my $value = shift;
- if ( RT::Extension::NHD->CheckUUID($value) ) {
+ if ( RT::Extension::NetworkedHelpDesk->CheckUUID($value) ) {
return $self->LoadByCols( @_, UUID => $value );
}
return $self->SUPER::Load( $value, @_ );
@@ -157,11 +157,11 @@ sub Send {
return (0, 'We are neither sender nor receiver')
unless $recipient;
- my $method = RT::Extension::NHD->ActionToWebMethod( $action );
+ my $method = RT::Extension::NetworkedHelpDesk->ActionToWebMethod( $action );
return (0, "Unknown action '$action'")
unless $method;
- my $response = RT::Extension::NHD->JSONRequest(
+ my $response = RT::Extension::NetworkedHelpDesk->JSONRequest(
$method => $self->$recipient() .'/agreements/'. $self->UUID,
Headers => {
'X-Ticket-Sharing-Token' => $self->UUID .':'. $self->AccessKey,
@@ -243,8 +243,8 @@ sub LoadOrCreateUser {
return ($user, 'Created');
}
-sub ValidateUUID { return RT::Extension::NHD->CheckUUID( $_[1] ) }
-sub ValidateAccessKey { return RT::Extension::NHD->CheckUUID( $_[1] ) }
+sub ValidateUUID { return RT::Extension::NetworkedHelpDesk->CheckUUID( $_[1] ) }
+sub ValidateAccessKey { return RT::Extension::NetworkedHelpDesk->CheckUUID( $_[1] ) }
sub ValidateStatus {
my $self = shift;
View
10 t/api/agreement.t
@@ -3,12 +3,12 @@
use strict;
use warnings;
-use RT::Extension::NHD::Test tests => 58;
-my $test = 'RT::Extension::NHD::Test';
+use RT::Extension::NetworkedHelpDesk::Test tests => 58;
+my $test = 'RT::Extension::NetworkedHelpDesk::Test';
use Digest::SHA1 qw(sha1_hex);
-use_ok 'RT::Extension::NHD';
+use_ok 'RT::Extension::NetworkedHelpDesk';
{
my $agreement = RT::NHD::Agreement->new( RT->SystemUser );
@@ -196,7 +196,7 @@ my $i = 0;
$agreement->UUID .':'. $agreement->AccessKey;
is lc $requests[0]->header('Content-Type'), 'text/x-json; charset="utf-8"';
is_deeply(
- RT::Extension::NHD->FromJSON( $requests[0]->content ),
+ RT::Extension::NetworkedHelpDesk->FromJSON( $requests[0]->content ),
$agreement->ForJSON,
);
@@ -222,7 +222,7 @@ my $i = 0;
};
is lc $requests[0]->header('Content-Type'), 'text/x-json; charset="utf-8"';
is_deeply(
- RT::Extension::NHD->FromJSON( $requests[0]->content ),
+ RT::Extension::NetworkedHelpDesk->FromJSON( $requests[0]->content ),
$agreement->ForJSON( Fields => ['Name', 'AccessKey'] ),
);
}
View
8 t/rest/agreement.t
@@ -3,12 +3,12 @@
use strict;
use warnings;
-use RT::Extension::NHD::Test tests => 18;
+use RT::Extension::NetworkedHelpDesk::Test tests => 18;
use Digest::SHA1 qw(sha1_hex);
-RT::Extension::NHD::Test->started_ok;
+RT::Extension::NetworkedHelpDesk::Test->started_ok;
-my $m = RT::Extension::NHD::Test->new_agent;
+my $m = RT::Extension::NetworkedHelpDesk::Test->new_agent;
my $i = 0;
{
@@ -59,7 +59,7 @@ my $i = 0;
);
is( $response->code, 200, 'got agreement' );
is_deeply(
- RT::Extension::NHD->FromJSON( $response->content ),
+ RT::Extension::NetworkedHelpDesk->FromJSON( $response->content ),
{
uuid => $uuid,
name => 'Test Company',
View
6 t/web/agreement.t
@@ -3,8 +3,8 @@
use strict;
use warnings;
-use RT::Extension::NHD::Test tests => 18;
-my $test = 'RT::Extension::NHD::Test';
+use RT::Extension::NetworkedHelpDesk::Test tests => 18;
+my $test = 'RT::Extension::NetworkedHelpDesk::Test';
use Digest::SHA1 qw(sha1_hex);
my $org = 'Cool Company Sharing Tickets';
@@ -40,7 +40,7 @@ my $remote_url = 'http://hoster.example.com/sharing';
$agreement->UUID .':'. $agreement->AccessKey;
is lc $requests[0]->header('Content-Type'), 'text/x-json; charset="utf-8"';
is_deeply(
- RT::Extension::NHD->FromJSON( $requests[0]->content ),
+ RT::Extension::NetworkedHelpDesk->FromJSON( $requests[0]->content ),
$agreement->ForJSON,
);
}
Please sign in to comment.
Something went wrong with that request. Please try again.