test_deeply.pl untested

filter: Statementstmt 0.0% 0 / 75 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 82 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!perl
2  
3 use Net::OAuth::Yahoo;
4 use Data::Dumper;
5 use Test::More qw/no_plan/;
6  
7 BEGIN { use_ok('Net::OAuth::Yahoo'); }
8  
9 print "Please enter the consumer_key: ";
10 chomp( my $consumer_key = <STDIN> );
11 print "Please enter the consumer_secret: ";
12 chomp( my $consumer_secret = <STDIN> );
13 print "Please enter yahoo login to test with: ";
14 chomp( my $yahoo_login = <STDIN> );
15 print "Please enter yahoo password to test with: ";
16 chomp( my $yahoo_password = <STDIN> );
17 print "Please enter a Yahoo API URL to test with: ";
18 chomp( my $api_url = <STDIN> );
19 print "Please enter the filename of token (it will be cleaned up at the end of this test script): ";
20 chomp( my $file = <STDIN> );
21  
22 my $oauth = Net::OAuth::Yahoo->new();
23 ok( $Net::OAuth::Yahoo::ERRMSG eq "_validate_params() failed", "_validate_params() test without params" );
24  
25 my $args = {
26 "consumer_key" => $consumer_key,
27 "consumer_secret" => $consumer_secret,
28 "signature_method" => "HMAC-SHA1",
29 "nonce" => "random_string",
30 "callback" => "oob",
31 };
32  
33 $oauth = Net::OAuth::Yahoo->new($args);
34 my $url1 = $oauth->get("token_url");
35  
36 ok( $url1 eq "https://api.login.yahoo.com/oauth/v2/get_token", "new() object creation test" );
37  
38 my $request_token = $oauth->get_request_token();
39 my $obj_req_token = $oauth->get("request_token");
40 is_deeply( $request_token, $obj_req_token, "get_request_token() test" );
41  
42 my $url = $oauth->request_auth();
43 ok( $Net::OAuth::Yahoo::ERRMSG eq "request_auth() did not receive a valid request token",
44 "request_auth() test without URL" );
45  
46 $url = $oauth->request_auth($request_token);
47 like( $url, qr/oauth_token/, "request_auth() test to see if URL is fetched properly" );
48  
49 my $yid = {
50 "login" => $yahoo_login,
51 "passwd" => $yahoo_password,
52 };
53  
54 my $oauth_verifier = $oauth->sim_present_auth();
55 ok( $Net::OAuth::Yahoo::ERRMSG eq "sim_present_auth() did not receive correct set of params",
56 "sim_present_auth() test without params" );
57  
58 $oauth_verifier = $oauth->sim_present_auth( $url, $yid );
59 like( $oauth_verifier, qr/\w{6}/, "sim_present_auth() should return 6 word characters" );
60  
61 my $token = $oauth->get_token();
62 ok( $Net::OAuth::Yahoo::ERRMSG eq "get_token() invoked without oauth_verifier", "get_token() test without params" );
63  
64 $token = $oauth->get_token($oauth_verifier);
65 my $obj_token = $oauth->get("token");
66 is_deeply( $token, $obj_token, "get_token() test with oauth_verifier" );
67  
68 $oauth->access_api();
69 ok( $Net::OAuth::Yahoo::ERRMSG eq "access_api() did not receive a token or URL", "access_api() test without params" );
70  
71 my $json = $oauth->access_api( $token, $api_url );
72 like( $json, qr/yahoo/, "access_api() test with token & URL" );
73  
74 $oauth->save_token();
75 ok( $Net::OAuth::Yahoo::ERRMSG eq "save_token() did not receive filename or, object did not have a token",
76 "save_token() test without a filename" );
77  
78 $oauth->save_token($file);
79 my $check;
80  
81 if ( -f $file ) {
82 $check = 1;
83 }
84 else {
85 $check = 0;
86 }
87 is( $check, 1, "save_token() test with a filename" );
88  
89 $oauth->load_token();
90 ok( $Net::OAuth::Yahoo::ERRMSG eq "load_token() could not find the file specified",
91 "load_token() test without a filename" );
92  
93 $oauth->load_token($file);
94 $obj_token = $oauth->get("token");
95 is_deeply( $token, $obj_token, "load_token() test. compares token before saving and after loading" );
96  
97 $oauth->test_token();
98 ok( $Net::OAuth::Yahoo::ERRMSG eq "test_token() did not receive the right params", "test_token() without params" );
99  
100 my $ret = $oauth->test_token( $token, $url );
101 is( $ret, 1, "test_token() test with a token, url" );
102  
103 unlink $file