Refactor upload API to easier to read variables

This commit is contained in:
Tom Bloor 2017-04-20 12:33:56 +01:00
parent ab9bfdf221
commit 7f18aa7173
6 changed files with 220 additions and 226 deletions

View file

@ -4,7 +4,7 @@ use Data::Dumper;
=head2 post_upload =head2 post_upload
Takes a file upload, with a file key of 'file2', and a json string under the Takes a file upload, with a file key of 'file', and a json string under the
'json' key. 'json' key.
The json string should be an object, with the following keys: The json string should be an object, with the following keys:
@ -45,30 +45,25 @@ The postcode of an organisation, optional key. Used when transaction_Type is 3.
has error_messages => sub { has error_messages => sub {
return { return {
transactionAdditionType => { transaction_type => {
required => { message => 'transactionAdditionType is missing.', status => 400 }, required => { message => 'transaction_type is missing.', status => 400 },
in => { message => 'transactionAdditionType is not a valid value.', status => 400 }, in => { message => 'transaction_type is not a valid value.', status => 400 },
}, },
microCurrencyValue => { transaction_value => {
required => { message => 'microCurrencyValue is missing', status => 400 }, required => { message => 'transaction_value is missing', status => 400 },
number => { message => 'microCurrencyValue does not look like a number', status => 400 }, number => { message => 'transaction_value does not look like a number', status => 400 },
gt_num => { message => 'microCurrencyValue cannot be equal to or less than zero', status => 400 }, gt_num => { message => 'transaction_value cannot be equal to or less than zero', status => 400 },
}, },
file2 => { file => {
required => { message => 'No file uploaded', status => 400 }, required => { message => 'No file uploaded', status => 400 },
}, },
addValidatedId => { organisation_id => {
required => { message => 'addValidatedId is missing', status => 400 }, required => { message => 'organisation_id is missing', status => 400 },
number => { message => 'organisation_id is not a number', status => 400 }, number => { message => 'organisation_id is not a number', status => 400 },
in_resultset => { message => 'addValidatedId does not exist in the database', status => 400 }, in_resultset => { message => 'organisation_id does not exist in the database', status => 400 },
}, },
addUnvalidatedId => { organisation_name => {
required => { message => 'addUnvalidatedId is missing', status => 400 }, required => { message => 'organisation_name is missing', status => 400 },
number => { message => 'addUnvalidatedId does not look like a number', status => 400 },
in_resultset => { message => 'addUnvalidatedId does not exist in the database for the user', status => 400 },
},
organisationName => {
required => { message => 'organisationName is missing', status => 400 },
}, },
}; };
}; };
@ -82,44 +77,43 @@ sub post_upload {
my $validation = $c->validation; my $validation = $c->validation;
# Test for file before loading the JSON in to the validator # Test for file before loading the JSON in to the validator
$validation->required('file2'); $validation->required('file');
$validation->input( $c->stash->{api_json} ); $validation->input( $c->stash->{api_json} );
$validation->required('microCurrencyValue')->number->gt_num(0); $validation->required('transaction_value')->number->gt_num(0);
$validation->required('transactionAdditionType')->in( 1, 2, 3 ); $validation->required('transaction_type')->in( 1, 2, 3 );
# First pass of required items # First pass of required items
return $c->api_validation_error if $validation->has_error; return $c->api_validation_error if $validation->has_error;
my $type = $validation->param('transactionAdditionType'); my $type = $validation->param('transaction_type');
if ( $type == 1 ) { if ( $type == 1 ) {
# Validated Organisation # Validated Organisation
my $valid_org_rs = $c->schema->resultset('Organisation'); my $valid_org_rs = $c->schema->resultset('Organisation');
$validation->required('addValidatedId')->number->in_resultset( 'organisationalid', $valid_org_rs ); $validation->required('organisation_id')->number->in_resultset( 'organisationalid', $valid_org_rs );
} elsif ( $type == 2 ) { } elsif ( $type == 2 ) {
# Unvalidated Organisation # Unvalidated Organisation
my $valid_org_rs = $c->schema->resultset('PendingOrganisation')->search({ usersubmitted_fk => $user->id }); my $valid_org_rs = $c->schema->resultset('PendingOrganisation')->search({ usersubmitted_fk => $user->id });
$validation->required('addUnvalidatedId')->number->in_resultset( 'pendingorganisationid', $valid_org_rs ); $validation->required('organisation_id')->number->in_resultset( 'pendingorganisationid', $valid_org_rs );
} elsif ( $type == 3 ) { } elsif ( $type == 3 ) {
# Unknown Organisation # Unknown Organisation
$validation->required('organisationName'); $validation->required('organisation_name');
$validation->optional('streetName'); $validation->optional('street_name');
$validation->optional('town'); $validation->optional('town');
$validation->optional('postcode')->postcode; $validation->optional('postcode')->postcode;
} }
return $c->api_validation_error if $validation->has_error; return $c->api_validation_error if $validation->has_error;
my $transactionAdditionType = $type; my $transaction_value = $validation->param('transaction_value');
my $microCurrencyValue = $validation->param('microCurrencyValue');
my $json = $c->stash->{api_json}; my $json = $c->stash->{api_json};
my $userId = $user->id; my $userId = $user->id;
my $file = $self->req->upload('file2'); my $file = $self->req->upload('file');
my $ext = '.jpg'; my $ext = '.jpg';
my $uuid = Data::UUID->new->create_str; my $uuid = Data::UUID->new->create_str;
@ -140,8 +134,8 @@ sub post_upload {
# Validated organisation # Validated organisation
$c->schema->resultset('Transaction')->create({ $c->schema->resultset('Transaction')->create({
buyeruserid_fk => $user->id, buyeruserid_fk => $user->id,
sellerorganisationid_fk => $validation->param('addValidatedId'), sellerorganisationid_fk => $validation->param('organisation_id'),
valuemicrocurrency => $microCurrencyValue, valuemicrocurrency => $transaction_value,
proofimage => $filename, proofimage => $filename,
timedatesubmitted => DateTime->now, timedatesubmitted => DateTime->now,
}); });
@ -151,23 +145,23 @@ sub post_upload {
# Unvalidated Organisation # Unvalidated Organisation
$c->schema->resultset('PendingTransaction')->create({ $c->schema->resultset('PendingTransaction')->create({
buyeruserid_fk => $user->id, buyeruserid_fk => $user->id,
pendingsellerorganisationid_fk => $validation->param('addUnvalidatedId'), pendingsellerorganisationid_fk => $validation->param('organisation_id'),
valuemicrocurrency => $microCurrencyValue, valuemicrocurrency => $transaction_value,
proofimage => $filename, proofimage => $filename,
timedatesubmitted => DateTime->now, timedatesubmitted => DateTime->now,
}); });
$file->move_to('images/' . $filename); $file->move_to('images/' . $filename);
} elsif ( $type == 3 ) { } elsif ( $type == 3 ) {
my $organisationName = $validation->param('organisationName'); my $organisation_name = $validation->param('organisation_name');
my $streetName = $validation->param('streetName'); my $street_name = $validation->param('street_name');
my $town = $validation->param('town'); my $town = $validation->param('town');
my $postcode = $validation->param('postcode'); my $postcode = $validation->param('postcode');
my $fullAddress = ""; my $fullAddress = "";
if ( defined $streetName && ! ($streetName =~ m/^\s*$/) ){ if ( defined $street_name && ! ($street_name =~ m/^\s*$/) ){
$fullAddress = $streetName; $fullAddress = $street_name;
} }
if ( defined $town && ! ($town =~ m/^\s*$/) ){ if ( defined $town && ! ($town =~ m/^\s*$/) ){
@ -183,7 +177,7 @@ sub post_upload {
my $pending_org = $c->schema->resultset('PendingOrganisation')->create({ my $pending_org = $c->schema->resultset('PendingOrganisation')->create({
usersubmitted_fk => $user->id, usersubmitted_fk => $user->id,
timedatesubmitted => DateTime->now, timedatesubmitted => DateTime->now,
name => $organisationName, name => $organisation_name,
fulladdress => $fullAddress, fulladdress => $fullAddress,
postcode => $postcode, postcode => $postcode,
}); });
@ -191,7 +185,7 @@ sub post_upload {
$c->schema->resultset('PendingTransaction')->create({ $c->schema->resultset('PendingTransaction')->create({
buyeruserid_fk => $user->id, buyeruserid_fk => $user->id,
pendingsellerorganisationid_fk => $pending_org->pendingorganisationid, pendingsellerorganisationid_fk => $pending_org->pendingorganisationid,
valuemicrocurrency => $microCurrencyValue, valuemicrocurrency => $transaction_value,
proofimage => $filename, proofimage => $filename,
timedatesubmitted => DateTime->now, timedatesubmitted => DateTime->now,
}); });

View file

@ -113,15 +113,15 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ;
my $nameToTestTurtle = 'Turtle\'s Paradise'; my $nameToTestTurtle = 'Turtle\'s Paradise';
$json = { $json = {
microCurrencyValue => 20, transaction_value => 20,
transactionAdditionType => 3, transaction_type => 3,
organisationName => $nameToTestTurtle, organisation_name => $nameToTestTurtle,
streetName => "Town centre", street_name => "Town centre",
town => " Wutai", town => " Wutai",
postcode => "NW1 5RU", postcode => "NW1 5RU",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -172,15 +172,15 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ;
my $nameToTestKalm = 'Kalm Inn'; my $nameToTestKalm = 'Kalm Inn';
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
organisationName => $nameToTestKalm, organisation_name => $nameToTestKalm,
streetName => "Town centre", street_name => "Town centre",
town => "Kalm", town => "Kalm",
postcode => "NW11 7GZ", postcode => "NW11 7GZ",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -195,12 +195,12 @@ my $newPendingKalmOrgId = $t->app->schema->resultset('PendingOrganisation')->fin
print "test 11 - add valid transaction (type 2: unvalidated organisation)\n"; print "test 11 - add valid transaction (type 2: unvalidated organisation)\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $newPendingKalmOrgId, organisation_id => $newPendingKalmOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -212,15 +212,15 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
print "test 12 - add valid transaction (type 3: new organisation)\n"; print "test 12 - add valid transaction (type 3: new organisation)\n";
my $nameToTestJunon = 'Store'; my $nameToTestJunon = 'Store';
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
organisationName => $nameToTestJunon, organisation_name => $nameToTestJunon,
streetName => "Main street", street_name => "Main street",
town => "Under Junon", town => "Under Junon",
postcode => "NW1W 7GF", postcode => "NW1W 7GF",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload) $t->post_ok('/api/upload' => form => $upload)
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -236,12 +236,12 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
print "test 13 - add valid transaction (type 2: unvalidated organisation)\n"; print "test 13 - add valid transaction (type 2: unvalidated organisation)\n";
$json = { $json = {
microCurrencyValue => 20, transaction_value => 20,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $newPendingJunonOrgId, organisation_id => $newPendingJunonOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true) ->json_is('/success', Mojo::JSON->true)
@ -254,12 +254,12 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
print "test 14 - add valid transaction (type 2: unvalidated organisation)\n"; print "test 14 - add valid transaction (type 2: unvalidated organisation)\n";
$json = { $json = {
microCurrencyValue => 30, transaction_value => 30,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $newPendingJunonOrgId, organisation_id => $newPendingJunonOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true) ->json_is('/success', Mojo::JSON->true)

View file

@ -111,15 +111,15 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ;
my $nameToTestTurtle = 'Turtle\'s Paradise'; my $nameToTestTurtle = 'Turtle\'s Paradise';
$json = { $json = {
microCurrencyValue => 20, transaction_value => 20,
transactionAdditionType => 3, transaction_type => 3,
organisationName => $nameToTestTurtle, organisation_name => $nameToTestTurtle,
streetName => "Town centre", street_name => "Town centre",
town => " Wutai", town => " Wutai",
postcode => "NW10 8HH", postcode => "NW10 8HH",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -161,15 +161,15 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
my $nameToTestTurtlePartial = 'Turtle\'s Paradise2'; my $nameToTestTurtlePartial = 'Turtle\'s Paradise2';
$json = { $json = {
microCurrencyValue => 20, transaction_value => 20,
transactionAdditionType => 3, transaction_type => 3,
organisationName => $nameToTestTurtlePartial, organisation_name => $nameToTestTurtlePartial,
streetName => "", street_name => "",
town => "", town => "",
postcode => "", postcode => "",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -187,12 +187,12 @@ print "Turtle Id 2: " . $newPendingTurtleOrgIdPartial . "\n";
print "test 10 - add valid transaction (type 2: unvalidated organisation)\n"; print "test 10 - add valid transaction (type 2: unvalidated organisation)\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $newPendingTurtleOrgIdPartial, organisation_id => $newPendingTurtleOrgIdPartial,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -205,15 +205,15 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
print "test 11 - add valid transaction (type 3: new organisation)\n"; print "test 11 - add valid transaction (type 3: new organisation)\n";
my $nameToTestJunon = 'Store'; my $nameToTestJunon = 'Store';
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
organisationName => $nameToTestJunon, organisation_name => $nameToTestJunon,
streetName => "Main street", street_name => "Main street",
town => "Under Junon", town => "Under Junon",
postcode => "NW9 5EB", postcode => "NW9 5EB",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload) $t->post_ok('/api/upload' => form => $upload)
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -229,12 +229,12 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
print "test 12 - add valid transaction (type 2: unvalidated organisation)\n"; print "test 12 - add valid transaction (type 2: unvalidated organisation)\n";
$json = { $json = {
microCurrencyValue => 20, transaction_value => 20,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $newPendingJunonOrgId, organisation_id => $newPendingJunonOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -246,12 +246,12 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef,
print "test 13 - add valid transaction (type 2: unvalidated organisation)\n"; print "test 13 - add valid transaction (type 2: unvalidated organisation)\n";
$json = { $json = {
microCurrencyValue => 30, transaction_value => 30,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $newPendingJunonOrgId, organisation_id => $newPendingJunonOrgId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);

View file

@ -132,15 +132,15 @@ login_rufus();
print "test 4 - Added something containing 'fish'\n"; print "test 4 - Added something containing 'fish'\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
organisationName => 'Shoreway Fisheries', organisation_name => 'Shoreway Fisheries',
streetName => "2 James St", street_name => "2 James St",
town => "Lancaster", town => "Lancaster",
postcode => "LA1 1UP", postcode => "LA1 1UP",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -159,30 +159,30 @@ login_billy();
print "test 7 - Added something containing 'bar'\n"; print "test 7 - Added something containing 'bar'\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
organisationName => 'The Palatine Bar', organisation_name => 'The Palatine Bar',
streetName => "The Crescent", street_name => "The Crescent",
town => "Morecambe", town => "Morecambe",
postcode => "LA4 5BZ", postcode => "LA4 5BZ",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
print "test 8 - Added another thing containing 'bar'\n"; print "test 8 - Added another thing containing 'bar'\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
organisationName => 'The Sun Hotel & Bar', organisation_name => 'The Sun Hotel & Bar',
streetName => "63-65 Church Street", street_name => "63-65 Church Street",
town => "Lancaster", town => "Lancaster",
postcode => "LA1 1ET", postcode => "LA1 1ET",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);

View file

@ -98,7 +98,7 @@ $t->post_ok('/api/login' => json => $testJson)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
my $session_key = $t->tx->res->json('/session_key'); my $session_key = $t->tx->res->json('/session_key');
print "test 5 - JSON missing\n"; print "test 5 - JSON missing\n";
my $upload = {file2 => {file => './t/test.jpg'}}; my $upload = {file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
@ -106,86 +106,86 @@ $t->post_ok('/api/upload' => form => $upload )
#TODO Check for malformed JSON. #TODO Check for malformed JSON.
print "test 6 - microCurrencyValue missing\n"; print "test 6 - transaction_value missing\n";
my $json = { my $json = {
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => $companyIdNumShinra, organisation_id => $companyIdNumShinra,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/microCurrencyValue is missing/i); ->content_like(qr/transaction_value is missing/i);
print "test 7 - microCurrencyValue non-numbers\n"; print "test 7 - transaction_value non-numbers\n";
$json = { $json = {
microCurrencyValue => 'Abc', transaction_value => 'Abc',
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => $companyIdNumShinra, organisation_id => $companyIdNumShinra,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/microCurrencyValue does not look like a number/i); ->content_like(qr/transaction_value does not look like a number/i);
print "test 8 - microCurrencyValue equal to zero\n"; print "test 8 - transaction_value equal to zero\n";
$json = { $json = {
microCurrencyValue => 0, transaction_value => 0,
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => $companyIdNumShinra, organisation_id => $companyIdNumShinra,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/microCurrencyValue cannot be equal to or less than zero/i); ->content_like(qr/transaction_value cannot be equal to or less than zero/i);
print "test 9 - microCurrencyValue less than zero\n"; print "test 9 - transaction_value less than zero\n";
$json = { $json = {
microCurrencyValue => -1, transaction_value => -1,
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => $companyIdNumShinra, organisation_id => $companyIdNumShinra,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/microCurrencyValue cannot be equal to or less than zero/i); ->content_like(qr/transaction_value cannot be equal to or less than zero/i);
print "test 10 - transactionAdditionType missing\n"; print "test 10 - transaction_type missing\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/transactionAdditionType is missing/i); ->content_like(qr/transaction_type is missing/i);
print "test 11 - transactionAdditionType invalid.\n"; print "test 11 - transaction_type invalid.\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 4, transaction_type => 4,
session_key => $session_key, session_key => $session_key,
# addValidatedId => $companyIdNumShinra # organisation_id => $companyIdNumShinra
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/transactionAdditionType is not a valid value/i); ->content_like(qr/transaction_type is not a valid value/i);
print "test 12 - file not uploaded.\n"; print "test 12 - file not uploaded.\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => 1, organisation_id => 1,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json)}; $upload = {json => Mojo::JSON::encode_json($json)};
@ -194,41 +194,41 @@ $t->post_ok('/api/upload' => form => $upload )
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/no file uploaded/i); ->content_like(qr/no file uploaded/i);
print "test 13 - addValidatedId missing (type 1: already validated)\n"; print "test 13 - organisation_id missing (type 1: already validated)\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 1, transaction_type => 1,
session_key => $session_key, session_key => $session_key,
# addValidatedId => $companyIdNumShinra # organisation_id => $companyIdNumShinra
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/addValidatedId is missing/i); ->content_like(qr/organisation_id is missing/i);
print "test 14 - addValidatedId for non-existent id. (type 1: already validated)\n"; print "test 14 - organisation_id for non-existent id. (type 1: already validated)\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => ($companyIdNumShinra + 100), organisation_id => ($companyIdNumShinra + 100),
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/addValidatedId does not exist in the database/i); ->content_like(qr/organisation_id does not exist in the database/i);
print "test 15 - valid addition. (type 1: already validated)\n"; print "test 15 - valid addition. (type 1: already validated)\n";
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions")}[0],0,"no transactions"; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions")}[0],0,"no transactions";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => $companyIdNumShinra, organisation_id => $companyIdNumShinra,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true) ->json_is('/success', Mojo::JSON->true)
@ -239,33 +239,33 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions")}[0],1,
print "test 16 - organsation missing (type 3: new organisation)\n"; print "test 16 - organsation missing (type 3: new organisation)\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
streetName => "Slums, Sector 7", street_name => "Slums, Sector 7",
town => "Midgar", town => "Midgar",
postcode => "E1 0AA", postcode => "E1 0AA",
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/organisationName is missing/i); ->content_like(qr/organisation_name is missing/i);
print "test 17 - add valid transaction (type 3: new organisation)\n"; print "test 17 - add valid transaction (type 3: new organisation)\n";
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations")}[0],0,"No pending organisations"; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations")}[0],0,"No pending organisations";
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],0,"No pending transactions"; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],0,"No pending transactions";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
organisationName => '7th Heaven', organisation_name => '7th Heaven',
streetName => "Slums, Sector 7", street_name => "Slums, Sector 7",
town => "Midgar", town => "Midgar",
postcode => "E1 0AA", postcode => "E1 0AA",
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true) ->json_is('/success', Mojo::JSON->true)
@ -275,43 +275,43 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")
# Add type 2 (unverified organisation) checking. # Add type 2 (unverified organisation) checking.
print "test 18 - addUnvalidatedId missing (type 2: existing organisation)\n"; print "test 18 - organisation_id missing (type 2: existing organisation)\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 2, transaction_type => 2,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/addUnvalidatedId is missing/i); ->content_like(qr/organisation_id is missing/i);
print "test 19 - addUnvalidatedId not a number (type 2: existing organisation)\n"; print "test 19 - organisation_id not a number (type 2: existing organisation)\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => "Abc", organisation_id => "Abc",
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/addUnvalidatedId does not look like a number/i); ->content_like(qr/organisation_id is not a number/i);
print "test 20 - id does not exist (type 2: existing organisation)\n"; print "test 20 - id does not exist (type 2: existing organisation)\n";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => 1000, #Id that does not exist organisation_id => 1000, #Id that does not exist
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/addUnvalidatedId does not exist in the database for the user/i); ->content_like(qr/organisation_id does not exist in the database/i);
print "test 21 - Logout Rufus (type 2: existing organisation)\n"; print "test 21 - Logout Rufus (type 2: existing organisation)\n";
$t->post_ok('/api/logout', json => { session_key => $session_key } ) $t->post_ok('/api/logout', json => { session_key => $session_key } )
@ -339,16 +339,16 @@ my $org_result = $schema->resultset('PendingOrganisation')->find({ name => '7th
my $unvalidatedOrganisationId = $org_result->pendingorganisationid; my $unvalidatedOrganisationId = $org_result->pendingorganisationid;
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],1,"1 pending transaction"; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],1,"1 pending transaction";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $unvalidatedOrganisationId, organisation_id => $unvalidatedOrganisationId,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->content_like(qr/addUnvalidatedId does not exist in the database for the user/i); ->content_like(qr/organisation_id does not exist in the database/i);
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],1,"1 pending transaction"; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],1,"1 pending transaction";
print "test 24 - Logout Hojo\n"; print "test 24 - Logout Hojo\n";
@ -375,12 +375,12 @@ $session_key = $t->tx->res->json('/session_key');
print "test 26 - add valid transaction (type 2: existing organisation)\n"; print "test 26 - add valid transaction (type 2: existing organisation)\n";
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],1,"1 pending transaction"; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions")}[0],1,"1 pending transaction";
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $unvalidatedOrganisationId, organisation_id => $unvalidatedOrganisationId,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true) ->json_is('/success', Mojo::JSON->true)
@ -412,12 +412,12 @@ $session_key = $t->tx->res->json('/session_key');
print "test 29 - organisation buy from another organisation\n"; print "test 29 - organisation buy from another organisation\n";
is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions")}[0],1,"1 transaction"; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions")}[0],1,"1 transaction";
$json = { $json = {
microCurrencyValue => 100000, transaction_value => 100000,
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => $companyIdNumShinra, organisation_id => $companyIdNumShinra,
session_key => $session_key, session_key => $session_key,
}; };
$upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true) ->json_is('/success', Mojo::JSON->true)

View file

@ -159,15 +159,15 @@ login_reno();
print "test 6 - Reno spends at Turtle\'s Paradise\n"; print "test 6 - Reno spends at Turtle\'s Paradise\n";
my $nameToTestTurtle = 'Turtle\'s Paradise'; my $nameToTestTurtle = 'Turtle\'s Paradise';
$json = { $json = {
microCurrencyValue => 10, transaction_value => 10,
transactionAdditionType => 3, transaction_type => 3,
organisationName => $nameToTestTurtle, organisation_name => $nameToTestTurtle,
streetName => "Town centre", street_name => "Town centre",
town => " Wutai", town => " Wutai",
postcode => "NW11 8AD", postcode => "NW11 8AD",
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -178,24 +178,24 @@ Time::Fake->offset("+" . $dateTimePlusTwoDaysSecondsDiff . "s");
print "test 7 - Reno spends at Turtle\'s Paradise, 2 days later, transaction 1/2\n"; print "test 7 - Reno spends at Turtle\'s Paradise, 2 days later, transaction 1/2\n";
$json = { $json = {
microCurrencyValue => 20, transaction_value => 20,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $unvalidatedOrganisationId, organisation_id => $unvalidatedOrganisationId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
print "test 8 - Reno spends at Turtle\'s Paradise, 2 days later, transaction 2/2\n"; print "test 8 - Reno spends at Turtle\'s Paradise, 2 days later, transaction 2/2\n";
$json = { $json = {
microCurrencyValue => 40, transaction_value => 40,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $unvalidatedOrganisationId, organisation_id => $unvalidatedOrganisationId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -211,12 +211,12 @@ login_reno();
print "test 11 - Reno spends at Turtle\'s Paradise, 1 month later\n"; print "test 11 - Reno spends at Turtle\'s Paradise, 1 month later\n";
$json = { $json = {
microCurrencyValue => 80, transaction_value => 80,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $unvalidatedOrganisationId, organisation_id => $unvalidatedOrganisationId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -232,12 +232,12 @@ login_reno();
print "test 14 - Reno spends at Turtle\'s Paradise, 1 year later\n"; print "test 14 - Reno spends at Turtle\'s Paradise, 1 year later\n";
$json = { $json = {
microCurrencyValue => 160, transaction_value => 160,
transactionAdditionType => 2, transaction_type => 2,
addUnvalidatedId => $unvalidatedOrganisationId, organisation_id => $unvalidatedOrganisationId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);
@ -271,12 +271,12 @@ login_chocobilly();
print "test 20 - Chocobilly spends at Turtle\'s Paradise, 2 days later\n"; print "test 20 - Chocobilly spends at Turtle\'s Paradise, 2 days later\n";
#Added to test and see if the later values from different users merge together. They shouldn't #Added to test and see if the later values from different users merge together. They shouldn't
$json = { $json = {
microCurrencyValue => 320, transaction_value => 320,
transactionAdditionType => 1, transaction_type => 1,
addValidatedId => $validatedOrganisationId, organisation_id => $validatedOrganisationId,
session_key => $session_key, session_key => $session_key,
}; };
my $upload = {json => Mojo::JSON::encode_json($json), file2 => {file => './t/test.jpg'}}; my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}};
$t->post_ok('/api/upload' => form => $upload ) $t->post_ok('/api/upload' => form => $upload )
->status_is(200) ->status_is(200)
->json_is('/success', Mojo::JSON->true); ->json_is('/success', Mojo::JSON->true);