aboutsummaryrefslogtreecommitdiffstats
path: root/t/Mock/Twitter.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-04-22 11:11:41 +0100
committerMatthew Somerville <matthew@mysociety.org>2016-04-22 11:11:41 +0100
commit49f064bedcc97d571779a8ca76770778145aeab1 (patch)
tree721a9ddfd9bf12529e01030c146980543752a111 /t/Mock/Twitter.pm
parentf71c0242734c134ad7b9588f438f5e7d15038720 (diff)
parent9716a5224acbae7f2e68bdcd9688fa6b67ff2843 (diff)
Merge remote-tracking branch 'origin/twitter-login'
Diffstat (limited to 't/Mock/Twitter.pm')
-rw-r--r--t/Mock/Twitter.pm43
1 files changed, 43 insertions, 0 deletions
diff --git a/t/Mock/Twitter.pm b/t/Mock/Twitter.pm
new file mode 100644
index 000000000..930895e28
--- /dev/null
+++ b/t/Mock/Twitter.pm
@@ -0,0 +1,43 @@
+package t::Mock::Twitter;
+
+use JSON::MaybeXS;
+use Web::Simple;
+use MooX::Types::MooseLike::Base qw(:all);
+
+has json => (
+ is => 'lazy',
+ default => sub {
+ JSON->new->pretty->allow_blessed->convert_blessed;
+ },
+);
+
+sub dispatch_request {
+ my $self = shift;
+
+ sub (GET + /oauth/authenticate + ?*) {
+ my ($self) = @_;
+ return [ 200, [ 'Content-Type' => 'text/html' ], [ 'TwitteB login page' ] ];
+ },
+
+ sub (GET + /oauth/access_token + ?*) {
+ my ($self) = @_;
+ return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'oauth_token=access_token&oauth_token_secret=secret' ] ];
+ },
+
+ sub (GET + /oauth/request_token + ?*) {
+ my ($self) = @_;
+ return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'oauth_token=request-token&oauth_token_secret=secret&oauth_callback_confirmed=true' ] ];
+ },
+
+ sub (GET + /1.1/account/verify_credentials.json + ?*) {
+ my ($self) = @_;
+ my $data = {
+ id => '987654321',
+ name => 'Fiona Tester',
+ };
+ my $json = $self->json->encode($data);
+ return [ 200, [ 'Content-Type' => 'text/html' ], [ $json ] ];
+ },
+}
+
+__PACKAGE__->run_if_script;