summaryrefslogtreecommitdiff
path: root/t/spore-middleware
diff options
context:
space:
mode:
Diffstat (limited to 't/spore-middleware')
-rw-r--r--t/spore-middleware/auth-oauth.t40
-rw-r--r--t/spore-middleware/redirection.t27
2 files changed, 67 insertions, 0 deletions
diff --git a/t/spore-middleware/auth-oauth.t b/t/spore-middleware/auth-oauth.t
new file mode 100644
index 0000000..a704e24
--- /dev/null
+++ b/t/spore-middleware/auth-oauth.t
@@ -0,0 +1,40 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+plan tests => 3;
+
+use NET::HTTP::Spore;
+use JSON;
+
+my $api = {
+ base_url => "http://term.ie/oauth/example",
+ name => "term.ie",
+ methods => {
+ echo => {
+ path => "/echo_api.php",
+ method => "GET",
+ expected_status => [200],
+ authentication => 1,
+ }
+ },
+};
+
+SKIP: {
+ skip "require RUN_HTTP_TEST", 3 unless $ENV{RUN_HTTP_TEST};
+
+ my $client = Net::HTTP::Spore->new_from_string( JSON::encode_json($api) );
+
+ $client->enable(
+ 'Auth::OAuth',
+ consumer_key => 'key',
+ consumer_secret => 'secret',
+ token => 'accesskey',
+ token_secret => 'accesssecret',
+ );
+
+ ok my $r = $client->echo(method => 'foo', bar => 'baz');
+ is $r->status, 200;
+ like $r->body, qr/bar=baz&method=foo/;
+}
diff --git a/t/spore-middleware/redirection.t b/t/spore-middleware/redirection.t
new file mode 100644
index 0000000..fe239f9
--- /dev/null
+++ b/t/spore-middleware/redirection.t
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+plan tests => 2;
+
+use Net::HTTP::Spore;
+
+SKIP: {
+ skip "require RUN_HTTP_TEST", 2 unless $ENV{RUN_HTTP_TEST};
+ my $client = Net::HTTP::Spore->new_from_string(
+ '{
+ "base_url" : "http://fperrad.googlepages.com",
+ "name" : "googlepages",
+ "methods"
+ : { "get_home"
+ : { "path" : "/home", "method" : "GET", "expected_status" : [200] } }
+ }');
+
+ $client->enable('Redirection');
+
+ my $r = $client->get_home();
+ is $r->status, 200;
+ is $r->request->uri,
+ 'http://sites.google.com/site/fperrad/home';
+}