diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-09-13 13:31:56 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-09-13 13:31:56 +0200 |
| commit | 3e3dc478fc9b4eb90681df89156dfcc8f7f81481 (patch) | |
| tree | b9788b0d48f524bc4c0aeeb48c744a8f7b097910 /t/spore-middleware/auth-basic.t | |
| download | net-http-spore-3e3dc478fc9b4eb90681df89156dfcc8f7f81481.tar.gz | |
initial import
Diffstat (limited to '')
| -rw-r--r-- | t/spore-middleware/auth-basic.t | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/t/spore-middleware/auth-basic.t b/t/spore-middleware/auth-basic.t new file mode 100644 index 0000000..92776ba --- /dev/null +++ b/t/spore-middleware/auth-basic.t @@ -0,0 +1,32 @@ +use strict; +use warnings; + +use Test::More; +use MIME::Base64; + +use Net::HTTP::Spore; + +ok my $client = + Net::HTTP::Spore->new_from_spec( 't/specs/couchdb.json', + api_base_url => 'http://localhost:5984' ); + +my $username = 'franck'; +my $password = 's3kr3t'; + +$client->enable( 'Auth::Basic', username => $username, password => $password ); +$client->enable( + 'Test::Response', + body => 'result is ok', + headers => [ 'Content-Type' => 'text/html' ] +); + +my $res = $client->get_all_documents( database => 'test_spore' ); +is $res->[0], 200; + +my $req = $res->request; + +is $req->header('Authorization'), + 'Basic ' . encode_base64( $username . ':' . $password, '' ); + +done_testing; + |
