aboutsummaryrefslogtreecommitdiffstats
path: root/t/Mock
diff options
context:
space:
mode:
Diffstat (limited to 't/Mock')
-rw-r--r--t/Mock/Bing.pm47
-rw-r--r--t/Mock/MapIt.pm5
-rw-r--r--t/Mock/Nominatim.pm5
-rw-r--r--t/Mock/OpenIDConnect.pm48
-rw-r--r--t/Mock/Tilma.pm2
5 files changed, 105 insertions, 2 deletions
diff --git a/t/Mock/Bing.pm b/t/Mock/Bing.pm
index 3dfb8fbe0..cc4dab845 100644
--- a/t/Mock/Bing.pm
+++ b/t/Mock/Bing.pm
@@ -14,6 +14,53 @@ has json => (
sub dispatch_request {
my $self = shift;
+ sub (GET + /REST/v1/Locations + ?*) {
+ my ($self, $query) = @_;
+ my $results = [ {
+ point => { coordinates => [ 51, -1 ] },
+ name => 'Constitution Hill, London, SW1A',
+ confidence => 'High',
+ address => {
+ addressLine => 'Constitution Hill',
+ locality => 'London',
+ countryRegion => 'United Kingdom',
+ }
+ } ];
+ if ($query->{q} =~ /two results/) {
+ push @$results, {
+ point => { coordinates => [ 51, -1 ] },
+ name => 'Constitution Hill again, United Kingdom',
+ confidence => 'High',
+ address => {
+ addressLine => 'Constitution Hill again',
+ locality => 'London',
+ countryRegion => 'United Kingdom',
+ }
+ };
+ }
+ if ($query->{q} =~ /low/) {
+ push @$results, {
+ point => { coordinates => [ 52, -2 ] },
+ name => 'Constitution Hill elsewhere, United Kingdom',
+ confidence => 'Low',
+ address => {
+ addressLine => 'Constitution Hill elsewhere',
+ locality => 'London',
+ countryRegion => 'United Kingdom',
+ }
+ };
+ }
+ if ($query->{q} =~ /onlylow/) {
+ @$results = map { $_->{confidence} = 'Low'; $_ } @$results;
+ }
+ my $data = {
+ statusCode => 200,
+ resourceSets => [ { resources => $results } ],
+ };
+ my $json = $self->json->encode($data);
+ return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ];
+ },
+
sub (GET + /REST/v1/Locations/* + ?*) {
my ($self, $location, $query) = @_;
my $data = {
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index d49294a6a..74e360974 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -44,13 +44,14 @@ my @PLACES = (
[ 'NN1 2NS', 52.238301, -0.889992, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
[ '?', 52.238827, -0.894970, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
[ '?', 52.23025, -1.015826, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
+ [ 'E8 1DY', 51.552267, -0.063316, 2508, 'Hackney Borough Council', 'LBO' ],
+ [ 'E8 2DY', 51.552287, -0.063326, 2508, 'Hackney Council', 'LBO' ],
[ 'TW7 5JN', 51.482286, -0.328163, 2483, 'Hounslow Borough Council', 'LBO' ],
[ '?', 51.48111, -0.327219, 2483, 'Hounslow Borough Council', 'LBO' ],
[ '?', 51.482045, -0.327219, 2483, 'Hounslow Borough Council', 'LBO' ],
[ '?', 51.345714, -0.227959, 2457, 'Epsom and Ewell Borough Council', 'DIS' ],
[ 'CW11 1HZ', 53.145324, -2.370437, 21069, 'Cheshire East Council', 'UTA', 135301, 'Sandbach Town', 'UTW' ],
[ '?', 50.78301, -0.646929 ],
- [ 'TA1 1QP', 51.023569, -3.099055, 2239, 'Somerset County Council', 'CTY', 2429, 'Taunton Deane Borough Council', 'DIS' ],
[ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ],
[ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ],
[ 'PO30 5XJ', 50.71086, -1.29573, 2636, 'Isle of Wight Council', 'UTA' ],
@@ -121,6 +122,8 @@ sub dispatch_request {
$self->output({2326 => {parent_area => undef, id => 2326, name => "Cheltenham Borough Council", type => "DIS"}});
} elsif ($areas eq 'UTA') {
$self->output({2650 => {parent_area => undef, id => 2650, name => "Aberdeen Council", type => "UTA"}});
+ } elsif ($areas eq 'DIS,LBO,MTD,UTA,CTY,COI,LGD') {
+ $self->output({2508 => {parent_area => undef, id => 2508, name => "Hackney Council", type => "LBO"}});
} elsif ($areas eq 'GRE') {
$self->output({2493 => {parent_area => undef, id => 2493, name => "Greenwich Borough Council", type => "LBO"}});
} elsif ($areas eq 'LBO') {
diff --git a/t/Mock/Nominatim.pm b/t/Mock/Nominatim.pm
index 806ebbfd3..d108256f5 100644
--- a/t/Mock/Nominatim.pm
+++ b/t/Mock/Nominatim.pm
@@ -1,6 +1,7 @@
package t::Mock::Nominatim;
use JSON::MaybeXS;
+use LWP::Protocol::PSGI;
use Web::Simple;
has json => (
@@ -35,6 +36,10 @@ sub query {
{"osm_type"=>"way","osm_id"=>"4684282","lat"=>"55.9504009","lon"=>"-3.1858425","display_name"=>"High Street, Old Town, City of Ed\x{ed}nburgh, Scotland, EH1 1SP, United Kingdom","class"=>"highway","type"=>"tertiary","importance"=>0.55892577838734},
{"osm_type"=>"node","osm_id"=>"27424410","lat"=>"55.8596449","lon"=>"-4.240377","display_name"=>"High Street, Collegelands, Merchant City, Glasgow, Glasgow City, Scotland, G, United Kingdom","class"=>"railway","type"=>"station","importance"=>0.53074299592768}
];
+ } elsif ($q eq 'edinburgh') {
+ return [
+ {"osm_type"=>"node","osm_id"=>"17898859","lat"=>"55.9533456","lon"=>"-3.1883749","display_name"=>"Edinburgh","class"=>"place","type"=>"place:city","importance"=>0.676704}
+ ];
}
return [];
}
diff --git a/t/Mock/OpenIDConnect.pm b/t/Mock/OpenIDConnect.pm
index ba7d03b1d..61a67f329 100644
--- a/t/Mock/OpenIDConnect.pm
+++ b/t/Mock/OpenIDConnect.pm
@@ -27,6 +27,11 @@ sub dispatch_request {
return [ 200, [ 'Content-Type' => 'text/html' ], [ 'OpenID Connect login page' ] ];
},
+ sub (GET + /oauth2/v2.0/authorize_google + ?*) {
+ my ($self) = @_;
+ return [ 200, [ 'Content-Type' => 'text/html' ], [ 'OpenID Connect login page' ] ];
+ },
+
sub (GET + /oauth2/v2.0/logout + ?*) {
my ($self) = @_;
return [ 200, [ 'Content-Type' => 'text/html' ], [ 'OpenID Connect logout page' ] ];
@@ -72,6 +77,49 @@ sub dispatch_request {
my $json = $self->json->encode($data);
return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ];
},
+
+ sub (POST + /oauth2/v2.0/token_google + ?*) {
+ my ($self) = @_;
+ my $header = {
+ typ => "JWT",
+ alg => "RS256",
+ kid => "XXXfakeKEY1234",
+ };
+ my $now = DateTime->now->epoch;
+ my $payload = {
+ exp => $now + 3600,
+ nbf => $now,
+ locale => 'en-GB',
+ ver => "1.0",
+ iss => 'https://accounts.google.com',
+ sub => "my_google_user_id",
+ aud => "example_client_id",
+ iat => $now,
+ auth_time => $now,
+ given_name => "Andy",
+ family_name => "Dwyer",
+ name => "Andy Dwyer",
+ nonce => 'MyAwesomeRandomValue',
+ hd => 'example.org',
+ };
+ $payload->{email} = 'pkg-tappcontrollerauth_socialt-oidc_google@example.org' if $self->returns_email;
+ $payload->{email_verified} = JSON->true if $self->returns_email;
+ my $signature = "dummy";
+ my $id_token = join(".", (
+ encode_base64($self->json->encode($header), ''),
+ encode_base64($self->json->encode($payload), ''),
+ encode_base64($signature, '')
+ ));
+ my $data = {
+ id_token => $id_token,
+ token_type => "Bearer",
+ not_before => $now,
+ id_token_expires_in => 3600,
+ profile_info => encode_base64($self->json->encode({}), ''),
+ };
+ my $json = $self->json->encode($data);
+ return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ];
+ },
}
__PACKAGE__->run_if_script;
diff --git a/t/Mock/Tilma.pm b/t/Mock/Tilma.pm
index 7542b1f5e..b7ef2be2f 100644
--- a/t/Mock/Tilma.pm
+++ b/t/Mock/Tilma.pm
@@ -28,7 +28,7 @@ sub dispatch_request {
sub (GET + /mapserver/tfl + ?*) {
my ($self, $args) = @_;
my $features = [];
- if ($args->{Filter} =~ /540512,169141/) {
+ if ($args->{Filter} =~ /540512,169141|534371,185488/) {
$features = [
{ type => "Feature", properties => { HA_ID => "19" }, geometry => { type => "Polygon", coordinates => [ [
[ 539408.94, 170607.58 ],