Moved all API endpoints under /api, fixed all tests
This commit is contained in:
parent
dbc2c59461
commit
f2f2a543fa
15 changed files with 215 additions and 215 deletions
|
@ -39,17 +39,17 @@ sub startup {
|
|||
$r->any('/')->to('root#index');
|
||||
my $api = $r->any('/api');
|
||||
|
||||
$api->post("/register")->to('register#post_register');
|
||||
$api->post("/upload")->to('upload#post_upload');
|
||||
$api->post("/search")->to('upload#post_search');
|
||||
$api->post("/admin-approve")->to('admin#post_admin_approve');
|
||||
$api->post("/admin-merge")->to('admin#post_admin_merge');
|
||||
$api->get("/login")->to('auth#get_login');
|
||||
$api->post("/login")->to('auth#post_login');
|
||||
$api->post("/logout")->to('auth#post_logout');
|
||||
$api->post("/edit")->to('api#post_edit');
|
||||
$api->post("/fetchuser")->to('api#post_fetchuser');
|
||||
$api->post("/user-history")->to('user#post_user_history');
|
||||
$api->post("/register")->to('api-register#post_register');
|
||||
$api->post("/upload")->to('api-upload#post_upload');
|
||||
$api->post("/search")->to('api-upload#post_search');
|
||||
$api->post("/admin-approve")->to('api-admin#post_admin_approve');
|
||||
$api->post("/admin-merge")->to('api-admin#post_admin_merge');
|
||||
$api->get("/login")->to('api-auth#get_login');
|
||||
$api->post("/login")->to('api-auth#post_login');
|
||||
$api->post("/logout")->to('api-auth#post_logout');
|
||||
$api->post("/edit")->to('api-api#post_edit');
|
||||
$api->post("/fetchuser")->to('api-api#post_fetchuser');
|
||||
$api->post("/user-history")->to('api-user#post_user_history');
|
||||
|
||||
$api->any( '/' => sub {
|
||||
my $self = shift;
|
||||
|
@ -80,18 +80,18 @@ $self->hook( before_dispatch => sub {
|
|||
if ($hasBeenExtended) {
|
||||
$self->app->log->debug('Path: file:' . __FILE__ . ', line: ' . __LINE__);
|
||||
#If logged in and requestine the login page redirect to the main page.
|
||||
if ($path eq '/login') {
|
||||
if ($path eq '/api/login') {
|
||||
$self->app->log->debug('Path: file:' . __FILE__ . ', line: ' . __LINE__);
|
||||
#Force expire and redirect.
|
||||
$self->res->code(303);
|
||||
$self->redirect_to('/');
|
||||
$self->redirect_to('/api');
|
||||
}
|
||||
}
|
||||
#Has expired or did not exist in the first place and the path is not login
|
||||
elsif ($path ne '/login' && $path ne '/register') {
|
||||
elsif ($path ne '/api/login' && $path ne '/api/register') {
|
||||
$self->app->log->debug('Path Error: file:' . __FILE__ . ', line: ' . __LINE__);
|
||||
$self->res->code(303);
|
||||
$self->redirect_to('/login');
|
||||
$self->redirect_to('/api/login');
|
||||
}
|
||||
$self->app->log->debug('Path: file:' . __FILE__ . ', line: ' . __LINE__);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package Pear::LocalLoop::Controller::Admin;
|
||||
package Pear::LocalLoop::Controller::Api::Admin;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Data::Dumper;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Pear::LocalLoop::Controller::Api;
|
||||
package Pear::LocalLoop::Controller::Api::Api;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Data::Dumper;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Pear::LocalLoop::Controller::Auth;
|
||||
package Pear::LocalLoop::Controller::Api::Auth;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Data::Dumper;
|
||||
use Mojo::JSON;
|
|
@ -1,4 +1,4 @@
|
|||
package Pear::LocalLoop::Controller::Register;
|
||||
package Pear::LocalLoop::Controller::Api::Register;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Data::Dumper;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Pear::LocalLoop::Controller::Upload;
|
||||
package Pear::LocalLoop::Controller::Api::Upload;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Data::Dumper;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Pear::LocalLoop::Controller::User;
|
||||
package Pear::LocalLoop::Controller::Api::User;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Data::Dumper;
|
||||
use Mojo::JSON;
|
|
@ -46,7 +46,7 @@ my $testJson = {
|
|||
'password' => $passwordReno,
|
||||
'age' => '20-35'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -62,7 +62,7 @@ my $testJson = {
|
|||
'password' => $passwordBilly,
|
||||
'fulladdress' => 'Chocobo Farm, Eastern Continent, Gaia'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -79,7 +79,7 @@ my $testJson = {
|
|||
'password' => $passwordAdmin,
|
||||
'age' => '35-50'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -99,7 +99,7 @@ $testJson = {
|
|||
'email' => $emailReno,
|
||||
'password' => $passwordReno,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -119,7 +119,7 @@ $json = {
|
|||
postcode => "NW1 W01"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/unvalidatedOrganisationId');
|
||||
|
@ -135,14 +135,14 @@ print "test 7 - Non-admin (customer) tries to approve their organisation and fai
|
|||
$json = {
|
||||
unvalidatedOrganisationId => $newPendingTurtleOrgId,
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(403)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/You are not an admin/i);
|
||||
|
||||
|
||||
print "test 8 - Logout Reno\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -157,7 +157,7 @@ $testJson = {
|
|||
'email' => $emailBilly,
|
||||
'password' => $passwordBilly,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -177,7 +177,7 @@ $json = {
|
|||
postcode => "E2 M02"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/unvalidatedOrganisationId');
|
||||
|
@ -197,7 +197,7 @@ $json = {
|
|||
addUnvalidatedId => $newPendingKalmOrgId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_hasnt('/unvalidatedOrganisationId');
|
||||
|
@ -217,7 +217,7 @@ $json = {
|
|||
postcode => "E6 M02"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload)
|
||||
$t->post_ok('/api/upload' => form => $upload)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/unvalidatedOrganisationId');
|
||||
|
@ -238,7 +238,7 @@ $json = {
|
|||
addUnvalidatedId => $newPendingJunonOrgId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_hasnt('/unvalidatedOrganisationId');
|
||||
|
@ -255,7 +255,7 @@ $json = {
|
|||
addUnvalidatedId => $newPendingJunonOrgId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_hasnt('/unvalidatedOrganisationId');
|
||||
|
@ -268,13 +268,13 @@ print "test 15 - Non-admin (organisation) tries to approve their organisation an
|
|||
$json = {
|
||||
unvalidatedOrganisationId => $newPendingKalmOrgId,
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(403)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/You are not an admin/i);
|
||||
|
||||
print "test 16 - Logout Choco Billy\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -289,13 +289,13 @@ $testJson = {
|
|||
'email' => $emailAdmin,
|
||||
'password' => $passwordAdmin,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
||||
print "test 18 - JSON is missing.\n";
|
||||
$t->post_ok('/admin-approve' => json)
|
||||
$t->post_ok('/api/admin-approve' => json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/JSON is missing/i);
|
||||
|
@ -303,7 +303,7 @@ $t->post_ok('/admin-approve' => json)
|
|||
print "test 19 - unvalidatedOrganisationId missing (non-modify).\n";
|
||||
$json = {
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/unvalidatedOrganisationId is missing/i);
|
||||
|
@ -312,7 +312,7 @@ print "test 20 - unvalidatedOrganisationId not number (non-modify).\n";
|
|||
$json = {
|
||||
unvalidatedOrganisationId => 'Abc',
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/unvalidatedOrganisationId does not look like a number/i);
|
||||
|
@ -323,7 +323,7 @@ my ($maxPendingId) = $t->app->db->selectrow_array("SELECT MAX(PendingOrganisatio
|
|||
$json = {
|
||||
unvalidatedOrganisationId => ($maxPendingId + 1),
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/the specified unvalidatedOrganisationId does not exist/i);
|
||||
|
@ -338,7 +338,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
|
|||
$json = {
|
||||
unvalidatedOrganisationId => $newPendingKalmOrgId,
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],2,"2 unverified organisation." ;
|
||||
|
@ -359,7 +359,7 @@ $json = {
|
|||
fullAddress => $testFullAddress,
|
||||
postCode => $testPostCode,
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],1,"1 unverified organisation." ;
|
||||
|
@ -377,7 +377,7 @@ $json = {
|
|||
unvalidatedOrganisationId => $newPendingJunonOrgId,
|
||||
name => $testName,
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],0,"0 unverified organisation." ;
|
||||
|
|
|
@ -46,7 +46,7 @@ my $testJson = {
|
|||
'password' => $passwordReno,
|
||||
'age' => '20-35'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -62,7 +62,7 @@ my $testJson = {
|
|||
'password' => $passwordBilly,
|
||||
'fulladdress' => 'Chocobo Farm, Eastern Continent, Gaia'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -79,7 +79,7 @@ my $testJson = {
|
|||
'password' => $passwordAdmin,
|
||||
'age' => '35-50'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -99,7 +99,7 @@ $testJson = {
|
|||
'email' => $emailReno,
|
||||
'password' => $passwordReno,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -118,7 +118,7 @@ $json = {
|
|||
postcode => "NW1 W01"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],1,"1 unverified organisation." ;
|
||||
|
@ -131,7 +131,7 @@ print "Turtle Id: " . $newPendingTurtleOrgId . "\n";
|
|||
|
||||
|
||||
print "test 7 - Logout Reno\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -146,7 +146,7 @@ $testJson = {
|
|||
'email' => $emailBilly,
|
||||
'password' => $passwordBilly,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -167,7 +167,7 @@ $json = {
|
|||
postcode => ""
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],2,"2 unverified organisations." ;
|
||||
|
@ -189,7 +189,7 @@ $json = {
|
|||
addUnvalidatedId => $newPendingTurtleOrgIdPartial,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],2,"2 unverified organisations." ;
|
||||
|
@ -209,7 +209,7 @@ $json = {
|
|||
postcode => "E6 M02"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload)
|
||||
$t->post_ok('/api/upload' => form => $upload)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -229,7 +229,7 @@ $json = {
|
|||
addUnvalidatedId => $newPendingJunonOrgId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],3,"3 unverified organisations." ;
|
||||
|
@ -245,7 +245,7 @@ $json = {
|
|||
addUnvalidatedId => $newPendingJunonOrgId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],3,"3 unverified organisations." ;
|
||||
|
@ -255,7 +255,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
|
|||
|
||||
|
||||
print "test 14 - Logout Choco Billy\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -270,7 +270,7 @@ $testJson = {
|
|||
'email' => $emailAdmin,
|
||||
'password' => $passwordAdmin,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -282,7 +282,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
|
|||
my $json = {
|
||||
unvalidatedOrganisationId => $newPendingTurtleOrgId,
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
my $turtleValidatedId = $t->tx->res->json->{validatedOrganisationId};
|
||||
|
@ -292,7 +292,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef
|
|||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],1,"1 verified transaction.";
|
||||
|
||||
print "test 17 - Logout Admin\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -307,7 +307,7 @@ $testJson = {
|
|||
'email' => $emailBilly,
|
||||
'password' => $passwordBilly,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -317,13 +317,13 @@ $json = {
|
|||
unvalidatedOrganisationId => $newPendingTurtleOrgIdPartial,
|
||||
validatedOrganisationId => $turtleValidatedId,
|
||||
};
|
||||
$t->post_ok('/admin-merge' => json => $json)
|
||||
$t->post_ok('/api/admin-merge' => json => $json)
|
||||
->status_is(403)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/You are not an admin/i);
|
||||
|
||||
print "test 20 - Logout Choco Billy\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -338,13 +338,13 @@ $testJson = {
|
|||
'email' => $emailAdmin,
|
||||
'password' => $passwordAdmin,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
||||
print "test 22 - JSON is missing.\n";
|
||||
$t->post_ok('/admin-merge' => json)
|
||||
$t->post_ok('/api/admin-merge' => json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/JSON is missing/i);
|
||||
|
@ -354,7 +354,7 @@ print "test 23 - unvalidatedOrganisationId missing.\n";
|
|||
$json = {
|
||||
validatedOrganisationId => $turtleValidatedId,
|
||||
};
|
||||
$t->post_ok('/admin-merge' => json => $json)
|
||||
$t->post_ok('/api/admin-merge' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/unvalidatedOrganisationId is missing/i);
|
||||
|
@ -365,7 +365,7 @@ $json = {
|
|||
unvalidatedOrganisationId => "ABC",
|
||||
validatedOrganisationId => $turtleValidatedId,
|
||||
};
|
||||
$t->post_ok('/admin-merge' => json => $json)
|
||||
$t->post_ok('/api/admin-merge' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/unvalidatedOrganisationId does not look like a number/i);
|
||||
|
@ -375,7 +375,7 @@ print "test 25 - validatedOrganisationId missing.\n";
|
|||
$json = {
|
||||
unvalidatedOrganisationId => $newPendingTurtleOrgIdPartial,
|
||||
};
|
||||
$t->post_ok('/admin-merge' => json => $json)
|
||||
$t->post_ok('/api/admin-merge' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/validatedOrganisationId is missing/i);
|
||||
|
@ -386,7 +386,7 @@ $json = {
|
|||
unvalidatedOrganisationId => $newPendingTurtleOrgIdPartial,
|
||||
validatedOrganisationId => "ABC",
|
||||
};
|
||||
$t->post_ok('/admin-merge' => json => $json)
|
||||
$t->post_ok('/api/admin-merge' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/validatedOrganisationId does not look like a number/i);
|
||||
|
@ -398,7 +398,7 @@ $json = {
|
|||
unvalidatedOrganisationId => ($maxPendingId + 1),
|
||||
validatedOrganisationId => $turtleValidatedId,
|
||||
};
|
||||
$t->post_ok('/admin-merge' => json => $json)
|
||||
$t->post_ok('/api/admin-merge' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/unvalidatedOrganisationId does not exist in the database/i);
|
||||
|
@ -410,7 +410,7 @@ $json = {
|
|||
unvalidatedOrganisationId => $newPendingTurtleOrgIdPartial,
|
||||
validatedOrganisationId => ($maxId + 1),
|
||||
};
|
||||
$t->post_ok('/admin-merge' => json => $json)
|
||||
$t->post_ok('/api/admin-merge' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/validatedOrganisationId does not exist in the database/i);
|
||||
|
@ -427,7 +427,7 @@ $json = {
|
|||
unvalidatedOrganisationId => $newPendingTurtleOrgIdPartial,
|
||||
validatedOrganisationId => $turtleValidatedId,
|
||||
};
|
||||
$t->post_ok('/admin-merge' => json => $json)
|
||||
$t->post_ok('/api/admin-merge' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations", undef, ())}[0],1,"1 unverified organisation." ;
|
||||
|
|
|
@ -9,6 +9,6 @@ BEGIN {
|
|||
}
|
||||
|
||||
my $t = Test::Mojo->new("Pear::LocalLoop");
|
||||
$t->get_ok('/login')->status_is(200)->content_like(qr/login page/);
|
||||
$t->get_ok('/api/login')->status_is(200)->content_like(qr/login page/);
|
||||
|
||||
done_testing();
|
||||
|
|
66
t/login.t
66
t/login.t
|
@ -49,7 +49,7 @@ my $testJson = {
|
|||
'password' => $password,
|
||||
'age' => '20-35'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -60,7 +60,7 @@ $testJson = {
|
|||
'email' => $email,
|
||||
'password' => $password,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has("/$sessionTokenJsonName")
|
||||
|
@ -68,7 +68,7 @@ $t->post_ok('/login' => json => $testJson)
|
|||
|
||||
print "test 3 - Login, no redirect on login paths (cookies)\n";
|
||||
#No redirect, as you're logged in.
|
||||
$t->get_ok('/')
|
||||
$t->get_ok('/api/')
|
||||
->status_is(200);
|
||||
|
||||
my $location_is = sub {
|
||||
|
@ -80,14 +80,14 @@ my $location_is = sub {
|
|||
|
||||
print "test 4 - Login, redirect to root as already logged in (cookies)\n";
|
||||
#Check for redirect to root when logged in.
|
||||
$t->get_ok('/login')
|
||||
$t->get_ok('/api/login')
|
||||
->status_is(303)
|
||||
->$location_is('/');
|
||||
->$location_is('/api');
|
||||
|
||||
|
||||
#Does login/logout work with a cookie based session.
|
||||
print "test 5 - Logout (cookies)\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->content_like(qr/you were successfully logged out/i);
|
||||
|
@ -100,7 +100,7 @@ $testJson = {
|
|||
'email' => $email,
|
||||
'password' => $password,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has("/$sessionTokenJsonName")
|
||||
|
@ -115,30 +115,30 @@ $t->reset_session;
|
|||
|
||||
#Redirect, as no cookies are set
|
||||
print "test 7 - Login, no cookies or json redirect to login\n";
|
||||
$t->get_ok('/')
|
||||
$t->get_ok('/api/')
|
||||
->status_is(303)
|
||||
->$location_is('/login');
|
||||
->$location_is('/api/login');
|
||||
|
||||
print "test 8 - Login, no redirect on login paths (json)\n";
|
||||
$t->get_ok('/' => json => {$sessionTokenJsonName => $sessionToken})
|
||||
$t->get_ok('/api/' => json => {$sessionTokenJsonName => $sessionToken})
|
||||
->status_is(200);
|
||||
|
||||
#No token send so redirect
|
||||
print "test 9 - Logout, no cookies or json\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(303)
|
||||
->$location_is('/login');
|
||||
->$location_is('/api/login');
|
||||
|
||||
#Token sent logout
|
||||
print "test 10 - Logout, (json)\n";
|
||||
$t->post_ok('/logout' => json => {$sessionTokenJsonName => $sessionToken})
|
||||
$t->post_ok('/api/logout' => json => {$sessionTokenJsonName => $sessionToken})
|
||||
->status_is(200);
|
||||
|
||||
#Send logged out expired token,
|
||||
print "test 11 - Logout,expired session redirect (json)\n";
|
||||
$t->post_ok('/logout' => json => {$sessionTokenJsonName => $sessionToken})
|
||||
$t->post_ok('/api/logout' => json => {$sessionTokenJsonName => $sessionToken})
|
||||
->status_is(303)
|
||||
->$location_is('/login');
|
||||
->$location_is('/api/login');
|
||||
|
||||
$t->reset_session;
|
||||
|
||||
|
@ -150,7 +150,7 @@ $testJson = {
|
|||
'email' => $email,
|
||||
'password' => $password,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has("/$sessionTokenJsonName")
|
||||
|
@ -168,9 +168,9 @@ Time::Fake->offset("+".($sessionTimeSeconds * 2)."s");
|
|||
|
||||
#Send time expired token,
|
||||
print "test 13 - Fake time expired session redirect (json)\n";
|
||||
$t->post_ok('/logout' => json => {$sessionTokenJsonName => $sessionToken})
|
||||
$t->post_ok('/api/logout' => json => {$sessionTokenJsonName => $sessionToken})
|
||||
->status_is(303)
|
||||
->$location_is('/login');
|
||||
->$location_is('/api/login');
|
||||
|
||||
Time::Fake->reset();
|
||||
|
||||
|
@ -179,25 +179,25 @@ $t->reset_session;
|
|||
#Attempt to logout without any session
|
||||
# This is different from the one above as it's has no state.
|
||||
print "test 14 - Logout, no session\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(303)
|
||||
->$location_is('/login');
|
||||
->$location_is('/api/login');
|
||||
|
||||
#Clear the session state
|
||||
$t->reset_session;
|
||||
|
||||
#Not logged in, redirect to login.
|
||||
print "test 15 - Not logged in, get request redirect to login\n";
|
||||
$t->get_ok('/')
|
||||
$t->get_ok('/api/')
|
||||
->status_is(303)
|
||||
->$location_is('/login');
|
||||
->$location_is('/api/login');
|
||||
|
||||
$t->reset_session;
|
||||
|
||||
#Not logged in, redirect to login.
|
||||
print "test 16 - Not logged in, get request one redirection is ok.\n";
|
||||
$t->ua->max_redirects(1);
|
||||
$t->get_ok('/')
|
||||
$t->get_ok('/api/')
|
||||
->status_is(200);
|
||||
$t->ua->max_redirects(0);
|
||||
|
||||
|
@ -205,16 +205,16 @@ $t->reset_session;
|
|||
|
||||
#Not logged in, redirect to login.
|
||||
print "test 17 - Not logged in, post request redirect to login\n";
|
||||
$t->post_ok('/')
|
||||
$t->post_ok('/api/')
|
||||
->status_is(303)
|
||||
->$location_is('/login');
|
||||
->$location_is('/api/login');
|
||||
|
||||
$t->reset_session;
|
||||
|
||||
#Not logged in, redirect to login.
|
||||
print "test 18 - Not logged in, post request one redirection is ok.\n";
|
||||
$t->ua->max_redirects(1);
|
||||
$t->post_ok('/')
|
||||
$t->post_ok('/api/')
|
||||
->status_is(200);
|
||||
$t->ua->max_redirects(0);
|
||||
|
||||
|
@ -224,7 +224,7 @@ $t->reset_session;
|
|||
|
||||
#Test no JSON sent.
|
||||
print "test 19 - No JSON sent.\n";
|
||||
$t->post_ok('/login')
|
||||
$t->post_ok('/api/login')
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/No json sent/i);
|
||||
|
@ -236,7 +236,7 @@ print "test 20 - Email missing\n";
|
|||
$testJson = {
|
||||
'password' => $password,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/No email sent/i);
|
||||
|
@ -249,7 +249,7 @@ $testJson = {
|
|||
'email' => ($email . '@'),
|
||||
'password' => $password,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/email is invalid/i);
|
||||
|
@ -261,7 +261,7 @@ print "test 22 - No password sent.\n";
|
|||
$testJson = {
|
||||
'email' => $email,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/No password sent/i);
|
||||
|
@ -274,7 +274,7 @@ $testJson = {
|
|||
'email' => 'heidegger@shinra.energy',
|
||||
'password' => $password,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(401)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/Email or password is invalid/i);
|
||||
|
@ -287,7 +287,7 @@ $testJson = {
|
|||
'email' => $email,
|
||||
'password' => ($password . 'MoreText'),
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(401)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/Email or password is invalid/i);
|
||||
|
@ -300,7 +300,7 @@ $t->reset_session;
|
|||
# 'email' => $email,
|
||||
# 'password' => $password,
|
||||
#};
|
||||
#$t->post_ok('/login' => json => $testJson)
|
||||
#$t->post_ok('/api/login' => json => $testJson)
|
||||
# ->status_is(200)
|
||||
# ->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
|
48
t/register.t
48
t/register.t
|
@ -35,7 +35,7 @@ foreach (@tokens){
|
|||
|
||||
#No JSON sent
|
||||
print "test1\n\n";
|
||||
$t->post_ok('/register')
|
||||
$t->post_ok('/api/register')
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no json sent/i);
|
||||
|
@ -43,7 +43,7 @@ $t->post_ok('/register')
|
|||
#Empty JSON
|
||||
print "test2\n\n";
|
||||
my $testJson = {};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->json_is('/success', Mojo::JSON->false);
|
||||
|
||||
#token missing JSON
|
||||
|
@ -56,7 +56,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no token sent/i);
|
||||
|
@ -73,7 +73,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(401)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/token/i)
|
||||
|
@ -89,7 +89,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no username sent/i);
|
||||
|
@ -106,7 +106,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/blank/i)
|
||||
|
@ -123,7 +123,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/username/i);
|
||||
|
@ -142,7 +142,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -157,7 +157,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '35-50'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -172,7 +172,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '20-35'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -187,7 +187,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(403)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/exists/i);
|
||||
|
@ -202,7 +202,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no email sent/i);
|
||||
|
@ -218,7 +218,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '35-50'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/email/i)
|
||||
|
@ -235,7 +235,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '35-50'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/email/i)
|
||||
|
@ -252,7 +252,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '35-50'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(403)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/email/i)
|
||||
|
@ -268,7 +268,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no postcode sent/i);
|
||||
|
@ -285,7 +285,7 @@ my $testJson = {
|
|||
'postcode' => 'LA1 1AA',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no password sent/i);
|
||||
|
@ -302,7 +302,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => '50+'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no usertype sent/i);
|
||||
|
@ -318,7 +318,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'fulladdress' => 'mary lane testing....'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/usertype/i)
|
||||
|
@ -335,7 +335,7 @@ my $testJson = {
|
|||
'postcode' => 'LA1 1AA',
|
||||
'password' => 'Meh',
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no age sent/i);
|
||||
|
@ -351,7 +351,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'age' => 'invalid'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/age/i)
|
||||
|
@ -367,7 +367,7 @@ my $testJson = {
|
|||
'postcode' => 'LA1 1AA',
|
||||
'password' => 'Meh',
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no fulladdress sent/i);
|
||||
|
@ -385,7 +385,7 @@ my $testJson = {
|
|||
'password' => 'Meh',
|
||||
'fulladdress' => 'mary lane testing....'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -401,7 +401,7 @@ $t->post_ok('/register' => json => $testJson)
|
|||
# 'password' => 'Meh',
|
||||
# 'age' => '50+'
|
||||
#};
|
||||
#$t->post_ok('/register' => json => $testJson)
|
||||
#$t->post_ok('/api/register' => json => $testJson)
|
||||
# ->status_is(401)->or(sub{ diag $t->tx->res->body})
|
||||
# ->json_is('/success', Mojo::JSON->false)
|
||||
# ->content_like(qr/token/i);
|
||||
|
|
20
t/search.t
20
t/search.t
|
@ -71,7 +71,7 @@ my $testJson = {
|
|||
'password' => $passwordRufus,
|
||||
'age' => '20-35'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -88,7 +88,7 @@ my $testJson = {
|
|||
'password' => $passwordBilly,
|
||||
'fulladdress' => 'Market St, Lancaster'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -97,7 +97,7 @@ sub login_rufus {
|
|||
'email' => $emailRufus,
|
||||
'password' => $passwordRufus,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
};
|
||||
|
@ -107,13 +107,13 @@ sub login_billy {
|
|||
'email' => $emailBilly,
|
||||
'password' => $passwordBilly,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
};
|
||||
|
||||
sub log_out{
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ $json = {
|
|||
postcode => "LA1 1UP"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -162,7 +162,7 @@ $json = {
|
|||
postcode => "LA4 5BZ"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -176,7 +176,7 @@ $json = {
|
|||
postcode => "LA1 1ET"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -193,7 +193,7 @@ print "test 10 - Login - Rufus (cookies, customer)\n";
|
|||
login_rufus();
|
||||
|
||||
print "test 11 - search blank\n";
|
||||
$t->post_ok('/search' => json => {searchName => " "})
|
||||
$t->post_ok('/api/search' => json => {searchName => " "})
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/searchName is blank/i);
|
||||
|
@ -201,7 +201,7 @@ $t->post_ok('/search' => json => {searchName => " "})
|
|||
sub check_vars{
|
||||
my ($searchTerm, $numValidated, $numUnvalidated) = @_;
|
||||
|
||||
$t->post_ok('/search' => json => {searchName => $searchTerm})
|
||||
$t->post_ok('/api/search' => json => {searchName => $searchTerm})
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has("unvalidated")
|
||||
|
|
58
t/upload.t
58
t/upload.t
|
@ -58,7 +58,7 @@ my $testJson = {
|
|||
'password' => $passwordRufus,
|
||||
'age' => '20-35'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -74,7 +74,7 @@ my $testJson = {
|
|||
'password' => $passwordHojo,
|
||||
'age' => '35-50'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -90,7 +90,7 @@ my $testJson = {
|
|||
'password' => $passwordBilly,
|
||||
'fulladdress' => 'Chocobo Farm, Eastern Continent, Gaia'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -104,13 +104,13 @@ $testJson = {
|
|||
'email' => $emailRufus,
|
||||
'password' => $passwordRufus,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
print "test 5 - JSON missing\n";
|
||||
my $upload = {file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/JSON is missing/i);
|
||||
|
@ -123,7 +123,7 @@ my $json = {
|
|||
addValidatedId => $companyIdNumShinra
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/microCurrencyValue is missing/i);
|
||||
|
@ -135,7 +135,7 @@ my $json = {
|
|||
addValidatedId => $companyIdNumShinra
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/microCurrencyValue does not look like a number/i);
|
||||
|
@ -147,7 +147,7 @@ my $json = {
|
|||
addValidatedId => $companyIdNumShinra
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/microCurrencyValue cannot be equal to or less than zero/i);
|
||||
|
@ -159,7 +159,7 @@ my $json = {
|
|||
addValidatedId => $companyIdNumShinra
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/microCurrencyValue cannot be equal to or less than zero/i);
|
||||
|
@ -169,7 +169,7 @@ $json = {
|
|||
microCurrencyValue => 10,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/transactionAdditionType is missing/i);
|
||||
|
@ -181,7 +181,7 @@ $json = {
|
|||
# addValidatedId => $companyIdNumShinra
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/transactionAdditionType is not a valid value/i);
|
||||
|
@ -193,7 +193,7 @@ $json = {
|
|||
addValidatedId => 1,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json)};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/no file uploaded/i);
|
||||
|
@ -205,7 +205,7 @@ $json = {
|
|||
# addValidatedId => $companyIdNumShinra
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/addValidatedId is missing/i);
|
||||
|
@ -217,7 +217,7 @@ $json = {
|
|||
addValidatedId => ($companyIdNumShinra + 100)
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/addValidatedId does not exist in the database/i);
|
||||
|
@ -230,7 +230,7 @@ $json = {
|
|||
addValidatedId => $companyIdNumShinra,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->content_like(qr/Added transaction for validated organisation/i);
|
||||
|
@ -247,7 +247,7 @@ $json = {
|
|||
postcode => "E1 MS07"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/organisationName is missing/i);
|
||||
|
@ -265,7 +265,7 @@ $json = {
|
|||
postcode => "E1 MS07"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/unvalidatedOrganisationId')
|
||||
|
@ -283,7 +283,7 @@ $json = {
|
|||
transactionAdditionType => 2,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/addUnvalidatedId is missing/i);
|
||||
|
@ -295,7 +295,7 @@ $json = {
|
|||
addUnvalidatedId => "Abc",
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/addUnvalidatedId does not look like a number/i);
|
||||
|
@ -307,13 +307,13 @@ $json = {
|
|||
addUnvalidatedId => 1000, #Id that does not exist
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/addUnvalidatedId does not exist in the database for the user/i);
|
||||
|
||||
print "test 21 - Logout Rufus (type 2: existing organisation)\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -328,7 +328,7 @@ $testJson = {
|
|||
'email' => $emailHojo,
|
||||
'password' => $passwordHojo,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -341,14 +341,14 @@ $json = {
|
|||
addUnvalidatedId => $unvalidatedOrganisationId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/addUnvalidatedId does not exist in the database for the user/i);
|
||||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],1,"1 pending transaction";
|
||||
|
||||
print "test 24 - Logout Hojo\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -363,7 +363,7 @@ $testJson = {
|
|||
'email' => $emailRufus,
|
||||
'password' => $passwordRufus,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -376,7 +376,7 @@ $json = {
|
|||
addUnvalidatedId => $unvalidatedOrganisationId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->content_like(qr/Added transaction for unvalidated organisation./i);
|
||||
|
@ -384,7 +384,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")
|
|||
|
||||
|
||||
print "test 27 - Logout Rufus\n";
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -399,7 +399,7 @@ $testJson = {
|
|||
'email' => $emailBilly,
|
||||
'password' => $passwordBilly,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -412,7 +412,7 @@ $json = {
|
|||
addValidatedId => $companyIdNumShinra,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->content_like(qr/Added transaction for validated organisation/i);
|
||||
|
|
|
@ -68,7 +68,7 @@ my $testJson = {
|
|||
'password' => $passwordReno,
|
||||
'age' => '20-35'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -84,7 +84,7 @@ my $testJson = {
|
|||
'password' => $passwordBilly,
|
||||
'fulladdress' => 'Chocobo Farm, Eastern Continent, Gaia'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -101,7 +101,7 @@ my $testJson = {
|
|||
'password' => $passwordAdmin,
|
||||
'age' => '35-50'
|
||||
};
|
||||
$t->post_ok('/register' => json => $testJson)
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -112,7 +112,7 @@ $t->app->db->prepare("INSERT INTO Administrators (UserId) VALUES (?)")->execute(
|
|||
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Administrators")}[0],1,"1 admin";
|
||||
|
||||
sub logout {
|
||||
$t->post_ok('/logout')
|
||||
$t->post_ok('/api/logout')
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ sub login_reno {
|
|||
'email' => $emailReno,
|
||||
'password' => $passwordReno,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ sub login_chocobilly {
|
|||
'email' => $emailBilly,
|
||||
'password' => $passwordBilly,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ sub login_admin {
|
|||
'email' => $emailAdmin,
|
||||
'password' => $passwordAdmin,
|
||||
};
|
||||
$t->post_ok('/login' => json => $testJson)
|
||||
$t->post_ok('/api/login' => json => $testJson)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ $json = {
|
|||
postcode => "NW1 W01"
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
my $unvalidatedOrganisationId = $t->tx->res->json->{unvalidatedOrganisationId};
|
||||
|
@ -177,7 +177,7 @@ $json = {
|
|||
addUnvalidatedId => $unvalidatedOrganisationId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -188,7 +188,7 @@ $json = {
|
|||
addUnvalidatedId => $unvalidatedOrganisationId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -208,7 +208,7 @@ $json = {
|
|||
addUnvalidatedId => $unvalidatedOrganisationId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -228,7 +228,7 @@ $json = {
|
|||
addUnvalidatedId => $unvalidatedOrganisationId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -245,7 +245,7 @@ print "test 17 - Admin approves Turtle\'s Paradise.\n";
|
|||
$json = {
|
||||
unvalidatedOrganisationId => $unvalidatedOrganisationId,
|
||||
};
|
||||
$t->post_ok('/admin-approve' => json => $json)
|
||||
$t->post_ok('/api/admin-approve' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
my $validatedOrganisationId = $t->tx->res->json->{validatedOrganisationId};
|
||||
|
@ -265,7 +265,7 @@ $json = {
|
|||
addValidatedId => $validatedOrganisationId,
|
||||
};
|
||||
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}};
|
||||
$t->post_ok('/upload' => form => $upload )
|
||||
$t->post_ok('/api/upload' => form => $upload )
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
|
@ -282,7 +282,7 @@ login_reno();
|
|||
|
||||
|
||||
print "test 23 - No JSON\n";
|
||||
$t->post_ok('/user-history')
|
||||
$t->post_ok('/api/user-history')
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/JSON is missing/i);
|
||||
|
@ -293,7 +293,7 @@ $json = {
|
|||
monthNumber => $dateTimePlusThreeDays->month(),
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/retrieveType is missing/i);
|
||||
|
@ -305,7 +305,7 @@ $json = {
|
|||
monthNumber => $dateTimePlusThreeDays->month(),
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/retrieveType does not look like a number/i);
|
||||
|
@ -317,7 +317,7 @@ $json = {
|
|||
monthNumber => $dateTimePlusThreeDays->month(),
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/retrieveType can only be 1 or 2./i);
|
||||
|
@ -330,7 +330,7 @@ $json = {
|
|||
monthNumber => $dateTimePlusThreeDays->month(),
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/dayNumber is missing./i);
|
||||
|
@ -342,7 +342,7 @@ $json = {
|
|||
monthNumber => $dateTimePlusThreeDays->month(),
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/dayNumber does not look like a number./i);
|
||||
|
@ -353,7 +353,7 @@ $json = {
|
|||
dayNumber => $dateTimePlusThreeDays->day(),
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/monthNumber is missing./i);
|
||||
|
@ -365,7 +365,7 @@ $json = {
|
|||
monthNumber => "ABC",
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/monthNumber does not look like a number./i);
|
||||
|
@ -376,7 +376,7 @@ $json = {
|
|||
dayNumber => $dateTimePlusThreeDays->day(),
|
||||
monthNumber => $dateTimePlusThreeDays->month(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/year is missing./i);
|
||||
|
@ -388,7 +388,7 @@ $json = {
|
|||
monthNumber => $dateTimePlusThreeDays->month(),
|
||||
year => "I1",
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/year does not look like a number./i);
|
||||
|
@ -400,7 +400,7 @@ $json = {
|
|||
monthNumber => ($dateTimePlusThreeDays->month() + 13),
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/date is invalid./i);
|
||||
|
@ -416,7 +416,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/startDayNumber is missing./i);
|
||||
|
@ -431,7 +431,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/startDayNumber does not look like a number./i);
|
||||
|
@ -446,7 +446,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/startMonthNumber is missing./i);
|
||||
|
@ -461,7 +461,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/startMonthNumber does not look like a number./i);
|
||||
|
@ -475,7 +475,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/startYear is missing./i);
|
||||
|
@ -490,7 +490,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/startYear does not look like a number./i);
|
||||
|
@ -505,7 +505,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/start date is invalid./i);
|
||||
|
@ -521,7 +521,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/endDayNumber is missing./i);
|
||||
|
@ -536,7 +536,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/endDayNumber does not look like a number./i);
|
||||
|
@ -550,7 +550,7 @@ $json = {
|
|||
endDayNumber => $dateTimePlusOneYear->day(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/endMonthNumber is missing./i);
|
||||
|
@ -565,7 +565,7 @@ $json = {
|
|||
endMonthNumber => "A5G",
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/endMonthNumber does not look like a number./i);
|
||||
|
@ -579,7 +579,7 @@ $json = {
|
|||
endDayNumber => $dateTimePlusOneYear->day(),
|
||||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/endYear is missing./i);
|
||||
|
@ -594,7 +594,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => "ABC",
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/endYear does not look like a number./i);
|
||||
|
@ -609,7 +609,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(400)
|
||||
->json_is('/success', Mojo::JSON->false)
|
||||
->content_like(qr/end date is invalid./i);
|
||||
|
@ -623,7 +623,7 @@ $json = {
|
|||
monthNumber => $dateTimePlusThreeDays->month(),
|
||||
year => $dateTimePlusThreeDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/microCurencySpent')
|
||||
|
@ -640,7 +640,7 @@ $json = {
|
|||
monthNumber => $dateTimeInitial->month(),
|
||||
year => $dateTimeInitial->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/microCurencySpent')
|
||||
|
@ -657,7 +657,7 @@ $json = {
|
|||
monthNumber => $dateTimePlusTwoDays->month(),
|
||||
year => $dateTimePlusTwoDays->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/microCurencySpent')
|
||||
|
@ -677,7 +677,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneMonthMinusOneDay->month(),
|
||||
endYear => $dateTimePlusOneMonthMinusOneDay->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/microCurencySpent')
|
||||
|
@ -699,7 +699,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneMonthMinusOneDay->month(),
|
||||
endYear => $dateTimePlusOneMonthMinusOneDay->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/microCurencySpent')
|
||||
|
@ -722,7 +722,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/microCurencySpent')
|
||||
|
@ -748,7 +748,7 @@ $json = {
|
|||
endMonthNumber => $dateTimePlusOneYear->month(),
|
||||
endYear => $dateTimePlusOneYear->year(),
|
||||
};
|
||||
$t->post_ok('/user-history' => json => $json)
|
||||
$t->post_ok('/api/user-history' => json => $json)
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_has('/microCurencySpent')
|
||||
|
|
Reference in a new issue