signet 0.11.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +51 -15
- data/Gemfile +5 -4
- data/README.md +4 -6
- data/Rakefile +107 -37
- data/lib/signet.rb +17 -14
- data/lib/signet/errors.rb +4 -4
- data/lib/signet/oauth_1.rb +129 -154
- data/lib/signet/oauth_1/client.rb +309 -343
- data/lib/signet/oauth_1/credential.rb +40 -37
- data/lib/signet/oauth_1/server.rb +197 -203
- data/lib/signet/oauth_1/signature_methods/hmac_sha1.rb +11 -10
- data/lib/signet/oauth_1/signature_methods/plaintext.rb +8 -7
- data/lib/signet/oauth_1/signature_methods/rsa_sha1.rb +11 -11
- data/lib/signet/oauth_2.rb +41 -43
- data/lib/signet/oauth_2/client.rb +328 -313
- data/lib/signet/version.rb +2 -73
- data/signet.gemspec +37 -39
- data/spec/signet/oauth_1/client_spec.rb +313 -315
- data/spec/signet/oauth_1/credential_spec.rb +64 -56
- data/spec/signet/oauth_1/server_spec.rb +362 -362
- data/spec/signet/oauth_1/signature_methods/hmac_sha1_spec.rb +26 -26
- data/spec/signet/oauth_1/signature_methods/plaintext_spec.rb +28 -28
- data/spec/signet/oauth_1/signature_methods/rsa_sha1_spec.rb +34 -35
- data/spec/signet/oauth_1_spec.rb +553 -524
- data/spec/signet/oauth_2/client_spec.rb +652 -576
- data/spec/signet/oauth_2_spec.rb +88 -89
- data/spec/signet_spec.rb +41 -41
- data/spec/spec_helper.rb +7 -7
- data/spec/spec_helper_spec.rb +8 -8
- metadata +64 -52
- data/tasks/clobber.rake +0 -2
- data/tasks/gem.rake +0 -34
- data/tasks/git.rake +0 -40
- data/tasks/metrics.rake +0 -41
- data/tasks/spec.rake +0 -34
- data/tasks/wiki.rake +0 -38
- data/tasks/yard.rake +0 -21
| @@ -11,51 +11,51 @@ | |
| 11 11 | 
             
            #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 12 | 
             
            #    See the License for the specific language governing permissions and
         | 
| 13 13 | 
             
            #    limitations under the License.
         | 
| 14 | 
            -
            require  | 
| 15 | 
            -
            require  | 
| 16 | 
            -
            require  | 
| 17 | 
            -
            require  | 
| 14 | 
            +
            require "spec_helper"
         | 
| 15 | 
            +
            require "signet"
         | 
| 16 | 
            +
            require "signet/oauth_1"
         | 
| 17 | 
            +
            require "signet/oauth_1/signature_methods/hmac_sha1"
         | 
| 18 18 |  | 
| 19 19 | 
             
            describe Signet::OAuth1::HMACSHA1 do
         | 
| 20 | 
            -
              it  | 
| 20 | 
            +
              it "should correctly generate a signature" do
         | 
| 21 21 | 
             
                method = "GET"
         | 
| 22 22 | 
             
                uri = "http://photos.example.net/photos"
         | 
| 23 23 | 
             
                parameters = {
         | 
| 24 | 
            -
                  "oauth_consumer_key" | 
| 25 | 
            -
                  "oauth_token" | 
| 24 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 25 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 26 26 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 27 | 
            -
                  "oauth_timestamp" | 
| 28 | 
            -
                  "oauth_nonce" | 
| 29 | 
            -
                  "oauth_version" | 
| 30 | 
            -
                  "file" | 
| 31 | 
            -
                  "size" | 
| 27 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 28 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 29 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 30 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 31 | 
            +
                  "size"                   => "original"
         | 
| 32 32 | 
             
                }
         | 
| 33 33 | 
             
                client_credential_secret = "kd94hf93k423kf44"
         | 
| 34 34 | 
             
                token_credential_secret = "pfkkdhi9sl3r4s00"
         | 
| 35 | 
            -
                base_string = Signet::OAuth1.generate_base_string | 
| 35 | 
            +
                base_string = Signet::OAuth1.generate_base_string method, uri, parameters
         | 
| 36 36 | 
             
                expect(Signet::OAuth1::HMACSHA1.generate_signature(
         | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 37 | 
            +
                         base_string, client_credential_secret, token_credential_secret
         | 
| 38 | 
            +
                       )).to eq "tR3+Ty81lMeYAr/Fid0kMTYa/WM="
         | 
| 39 39 | 
             
              end
         | 
| 40 40 |  | 
| 41 | 
            -
              it  | 
| 41 | 
            +
              it "should correctly generate a signature" do
         | 
| 42 42 | 
             
                method = "GET"
         | 
| 43 43 | 
             
                uri = "http://photos.example.net/photos"
         | 
| 44 44 | 
             
                parameters = {
         | 
| 45 | 
            -
                  "oauth_consumer_key" | 
| 46 | 
            -
                  "oauth_token" | 
| 45 | 
            +
                  "oauth_consumer_key"     => "www.example.com",
         | 
| 46 | 
            +
                  "oauth_token"            => "4/QL2GT6b5uznYem1ZGH6v+-9mMvRL",
         | 
| 47 47 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 48 | 
            -
                  "oauth_timestamp" | 
| 49 | 
            -
                  "oauth_nonce" | 
| 50 | 
            -
                  "oauth_version" | 
| 51 | 
            -
                  "file" | 
| 52 | 
            -
                  "size" | 
| 48 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 49 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 50 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 51 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 52 | 
            +
                  "size"                   => "original"
         | 
| 53 53 | 
             
                }
         | 
| 54 54 | 
             
                client_credential_secret = "Kv+o2XXL/9RxkQW3lO3QTVlH"
         | 
| 55 55 | 
             
                token_credential_secret = "QllSuL9eQ5FXFO1Z/HcgL4ON"
         | 
| 56 | 
            -
                base_string = Signet::OAuth1.generate_base_string | 
| 56 | 
            +
                base_string = Signet::OAuth1.generate_base_string method, uri, parameters
         | 
| 57 57 | 
             
                expect(Signet::OAuth1::HMACSHA1.generate_signature(
         | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 58 | 
            +
                         base_string, client_credential_secret, token_credential_secret
         | 
| 59 | 
            +
                       )).to eq "G/nkdbmbpEA+6RD1Sc5uIefhFfQ="
         | 
| 60 60 | 
             
              end
         | 
| 61 61 | 
             
            end
         | 
| @@ -11,51 +11,51 @@ | |
| 11 11 | 
             
            #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 12 | 
             
            #    See the License for the specific language governing permissions and
         | 
| 13 13 | 
             
            #    limitations under the License.
         | 
| 14 | 
            -
            require  | 
| 15 | 
            -
            require  | 
| 16 | 
            -
            require  | 
| 17 | 
            -
            require  | 
| 14 | 
            +
            require "spec_helper"
         | 
| 15 | 
            +
            require "signet"
         | 
| 16 | 
            +
            require "signet/oauth_1"
         | 
| 17 | 
            +
            require "signet/oauth_1/signature_methods/plaintext"
         | 
| 18 18 |  | 
| 19 19 | 
             
            describe Signet::OAuth1::PLAINTEXT do
         | 
| 20 | 
            -
              it  | 
| 20 | 
            +
              it "should correctly generate a signature" do
         | 
| 21 21 | 
             
                method = "GET"
         | 
| 22 22 | 
             
                uri = "http://photos.example.net/photos"
         | 
| 23 23 | 
             
                parameters = {
         | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 24 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 25 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 26 | 
            +
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 27 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 28 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 29 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 30 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 31 | 
            +
                  "size"                   => "original"
         | 
| 32 32 | 
             
                }
         | 
| 33 33 | 
             
                client_credential_secret = "kd94hf93k423kf44"
         | 
| 34 34 | 
             
                token_credential_secret = "pfkkdhi9sl3r4s00"
         | 
| 35 | 
            -
                base_string = Signet::OAuth1.generate_base_string | 
| 35 | 
            +
                base_string = Signet::OAuth1.generate_base_string method, uri, parameters
         | 
| 36 36 | 
             
                expect(Signet::OAuth1::PLAINTEXT.generate_signature(
         | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 37 | 
            +
                         base_string, client_credential_secret, token_credential_secret
         | 
| 38 | 
            +
                       )).to eq "kd94hf93k423kf44%26pfkkdhi9sl3r4s00"
         | 
| 39 39 | 
             
              end
         | 
| 40 40 |  | 
| 41 | 
            -
              it  | 
| 41 | 
            +
              it "should correctly generate a signature" do
         | 
| 42 42 | 
             
                method = "GET"
         | 
| 43 43 | 
             
                uri = "http://photos.example.net/photos"
         | 
| 44 44 | 
             
                parameters = {
         | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 45 | 
            +
                  "oauth_consumer_key"     => "www.example.com",
         | 
| 46 | 
            +
                  "oauth_token"            => "4/QL2GT6b5uznYem1ZGH6v+-9mMvRL",
         | 
| 47 | 
            +
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 48 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 49 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 50 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 51 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 52 | 
            +
                  "size"                   => "original"
         | 
| 53 53 | 
             
                }
         | 
| 54 54 | 
             
                client_credential_secret = "Kv+o2XXL/9RxkQW3lO3QTVlH"
         | 
| 55 55 | 
             
                token_credential_secret = "QllSuL9eQ5FXFO1Z/HcgL4ON"
         | 
| 56 | 
            -
                base_string = Signet::OAuth1.generate_base_string | 
| 56 | 
            +
                base_string = Signet::OAuth1.generate_base_string method, uri, parameters
         | 
| 57 57 | 
             
                expect(Signet::OAuth1::PLAINTEXT.generate_signature(
         | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 58 | 
            +
                         base_string, client_credential_secret, token_credential_secret
         | 
| 59 | 
            +
                       )).to eq "Kv%252Bo2XXL%252F9RxkQW3lO3QTVlH%26QllSuL9eQ5FXFO1Z%252FHcgL4ON"
         | 
| 60 60 | 
             
              end
         | 
| 61 61 | 
             
            end
         | 
| @@ -11,21 +11,21 @@ | |
| 11 11 | 
             
            #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 12 | 
             
            #    See the License for the specific language governing permissions and
         | 
| 13 13 | 
             
            #    limitations under the License.
         | 
| 14 | 
            -
            require  | 
| 15 | 
            -
            require  | 
| 16 | 
            -
            require  | 
| 17 | 
            -
            require  | 
| 14 | 
            +
            require "spec_helper"
         | 
| 15 | 
            +
            require "signet"
         | 
| 16 | 
            +
            require "signet/oauth_1"
         | 
| 17 | 
            +
            require "signet/oauth_1/signature_methods/rsa_sha1"
         | 
| 18 18 |  | 
| 19 19 | 
             
            describe Signet::OAuth1::RSASHA1 do
         | 
| 20 | 
            -
              it  | 
| 20 | 
            +
              it "should correctly generate a signature" do
         | 
| 21 21 | 
             
                method = "GET"
         | 
| 22 22 | 
             
                uri = "http://term.ie/oauth/example/request_token.php"
         | 
| 23 23 | 
             
                parameters = {
         | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 24 | 
            +
                  "oauth_consumer_key"     => "key",
         | 
| 25 | 
            +
                  "oauth_signature_method" => "RSA-SHA1",
         | 
| 26 | 
            +
                  "oauth_timestamp"        => "1377815426",
         | 
| 27 | 
            +
                  "oauth_nonce"            => "c3839c47cb204a20e042b11a5cc9f971",
         | 
| 28 | 
            +
                  "oauth_version"          => "1.0"
         | 
| 29 29 | 
             
                }
         | 
| 30 30 | 
             
                client_credential_secret = "-----BEGIN PRIVATE KEY-----
         | 
| 31 31 | 
             
            MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
         | 
| @@ -44,26 +44,26 @@ AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54 | |
| 44 44 | 
             
            Lw03eHTNQghS0A==
         | 
| 45 45 | 
             
            -----END PRIVATE KEY-----"
         | 
| 46 46 | 
             
                token_credential_secret = "pfkkdhi9sl3r4s00"
         | 
| 47 | 
            -
                base_string = Signet::OAuth1.generate_base_string | 
| 47 | 
            +
                base_string = Signet::OAuth1.generate_base_string method, uri, parameters
         | 
| 48 48 |  | 
| 49 49 | 
             
                expect(Signet::OAuth1::RSASHA1.generate_signature(
         | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 50 | 
            +
                         base_string, client_credential_secret, token_credential_secret
         | 
| 51 | 
            +
                       )).to eq "P72T4RS8dVBneQPJSY71D3iLEjge2tiivxEasPVoaoDldDgPdwpQfhS1q0th19jB3B3+9P6tBWjpWaVPxrNZe3ssBCiwS/EmXZ/6VCJGU3YoDHMtz+0jCd36NjHj5I6TpLVQ8/rtfy6+EzpdUMz7ydnhKXYqJFPOWnNv8HM1W7I="
         | 
| 52 52 | 
             
              end
         | 
| 53 53 | 
             
            end
         | 
| 54 54 |  | 
| 55 55 | 
             
            describe Signet::OAuth1::RSASHA1 do
         | 
| 56 | 
            -
              it  | 
| 56 | 
            +
              it "should correctly generate a signature" do
         | 
| 57 57 | 
             
                method = "GET"
         | 
| 58 58 | 
             
                uri = "http://photos.example.net/photos"
         | 
| 59 59 | 
             
                parameters = {
         | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 60 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 61 | 
            +
                  "oauth_signature_method" => "RSA-SHA1",
         | 
| 62 | 
            +
                  "oauth_timestamp"        => "1196666512",
         | 
| 63 | 
            +
                  "oauth_nonce"            => "13917289812797014437",
         | 
| 64 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 65 | 
            +
                  "file"                   => "vacaction.jpg",
         | 
| 66 | 
            +
                  "size"                   => "original"
         | 
| 67 67 | 
             
                }
         | 
| 68 68 | 
             
                client_credential_secret = "-----BEGIN PRIVATE KEY-----
         | 
| 69 69 | 
             
            MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
         | 
| @@ -82,24 +82,24 @@ AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54 | |
| 82 82 | 
             
            Lw03eHTNQghS0A==
         | 
| 83 83 | 
             
            -----END PRIVATE KEY-----"
         | 
| 84 84 | 
             
                token_credential_secret = "pfkkdhi9sl3r4s00"
         | 
| 85 | 
            -
                base_string = Signet::OAuth1.generate_base_string | 
| 85 | 
            +
                base_string = Signet::OAuth1.generate_base_string method, uri, parameters
         | 
| 86 86 |  | 
| 87 87 | 
             
                expect(Signet::OAuth1::RSASHA1.generate_signature(
         | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 88 | 
            +
                         base_string, client_credential_secret, token_credential_secret
         | 
| 89 | 
            +
                       )).to eq "jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE="
         | 
| 90 90 | 
             
              end
         | 
| 91 91 |  | 
| 92 92 |  | 
| 93 | 
            -
              it  | 
| 93 | 
            +
              it "should correctly generate a signature" do
         | 
| 94 94 | 
             
                method = "GET"
         | 
| 95 95 | 
             
                uri = "http://term.ie/oauth/example/access_token.php"
         | 
| 96 96 | 
             
                parameters = {
         | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 97 | 
            +
                  "oauth_consumer_key"     => "key",
         | 
| 98 | 
            +
                  "oauth_token"            => "requestkey",
         | 
| 99 | 
            +
                  "oauth_signature_method" => "RSA-SHA1",
         | 
| 100 | 
            +
                  "oauth_timestamp"        => "1377815426",
         | 
| 101 | 
            +
                  "oauth_nonce"            => "8ae9ac8192dd3cd7372e0324bf879602",
         | 
| 102 | 
            +
                  "oauth_version"          => "1.0"
         | 
| 103 103 | 
             
                }
         | 
| 104 104 | 
             
                client_credential_secret = "-----BEGIN PRIVATE KEY-----
         | 
| 105 105 | 
             
            MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
         | 
| @@ -118,10 +118,9 @@ AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54 | |
| 118 118 | 
             
            Lw03eHTNQghS0A==
         | 
| 119 119 | 
             
            -----END PRIVATE KEY-----"
         | 
| 120 120 | 
             
                token_credential_secret = "QllSuL9eQ5FXFO1Z/HcgL4ON"
         | 
| 121 | 
            -
                base_string = Signet::OAuth1.generate_base_string | 
| 121 | 
            +
                base_string = Signet::OAuth1.generate_base_string method, uri, parameters
         | 
| 122 122 | 
             
                expect(Signet::OAuth1::RSASHA1.generate_signature(
         | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 123 | 
            +
                         base_string, client_credential_secret, token_credential_secret
         | 
| 124 | 
            +
                       )).to eq "Q1O7Ovi0jdacl/OTJoH3MAyOO/9H/tTXmoJzP/YqiKEJ+/wfShXo1RXX0xmlcjDR1XYxB1RMgHkFWQYYwz1qGCUhkXlH1c/to2qxPksptfPHRe7PJTxRClrdqLFOlhN7w2kO7tHVCeEp8IJIKON9q7cdXroTP7ctPPS+Q883SS0="
         | 
| 125 125 | 
             
              end
         | 
| 126 | 
            -
             | 
| 127 126 | 
             
            end
         | 
    
        data/spec/signet/oauth_1_spec.rb
    CHANGED
    
    | @@ -11,64 +11,67 @@ | |
| 11 11 | 
             
            #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 12 | 
             
            #    See the License for the specific language governing permissions and
         | 
| 13 13 | 
             
            #    limitations under the License.
         | 
| 14 | 
            -
            require  | 
| 15 | 
            -
            require  | 
| 16 | 
            -
            require  | 
| 17 | 
            -
            require  | 
| 14 | 
            +
            require "spec_helper"
         | 
| 15 | 
            +
            require "signet/oauth_1"
         | 
| 16 | 
            +
            require "signet/oauth_1/client"
         | 
| 17 | 
            +
            require "signet/oauth_1/credential"
         | 
| 18 18 |  | 
| 19 19 | 
             
            describe Signet::OAuth1 do
         | 
| 20 | 
            -
              it  | 
| 20 | 
            +
              it "should correctly normalize parameters" do
         | 
| 21 21 | 
             
                parameters = [
         | 
| 22 | 
            -
                  [ | 
| 22 | 
            +
                  %w[a 1],
         | 
| 23 23 | 
             
                  ["c", "hi there"],
         | 
| 24 | 
            -
                  [ | 
| 25 | 
            -
                  [ | 
| 26 | 
            -
                  [ | 
| 27 | 
            -
                  [ | 
| 28 | 
            -
                  [ | 
| 24 | 
            +
                  %w[f 25],
         | 
| 25 | 
            +
                  %w[f 50],
         | 
| 26 | 
            +
                  %w[f a],
         | 
| 27 | 
            +
                  %w[z p],
         | 
| 28 | 
            +
                  %w[z t]
         | 
| 29 29 | 
             
                ]
         | 
| 30 30 | 
             
                expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
         | 
| 31 | 
            -
                   | 
| 31 | 
            +
                  "a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t"
         | 
| 32 | 
            +
                )
         | 
| 32 33 | 
             
              end
         | 
| 33 34 |  | 
| 34 | 
            -
              it  | 
| 35 | 
            +
              it "should correctly normalize parameters" do
         | 
| 35 36 | 
             
                parameters = [
         | 
| 36 37 | 
             
                  ["b5", "=%3D"],
         | 
| 37 | 
            -
                  [ | 
| 38 | 
            +
                  %w[a3 a],
         | 
| 38 39 | 
             
                  ["c@", ""],
         | 
| 39 40 | 
             
                  ["a2", "r b"],
         | 
| 40 | 
            -
                  [ | 
| 41 | 
            -
                  [ | 
| 41 | 
            +
                  %w[oauth_consumer_key 9djdj82h48djs9d2],
         | 
| 42 | 
            +
                  %w[oauth_token kkk9d7dh3k39sjv7],
         | 
| 42 43 | 
             
                  ["oauth_signature_method", "HMAC-SHA1"],
         | 
| 43 | 
            -
                  [ | 
| 44 | 
            -
                  [ | 
| 44 | 
            +
                  %w[oauth_timestamp 137131201],
         | 
| 45 | 
            +
                  %w[oauth_nonce 7d8f3e4a],
         | 
| 45 46 | 
             
                  ["c2", ""],
         | 
| 46 47 | 
             
                  ["a3", "2 q"]
         | 
| 47 48 | 
             
                ]
         | 
| 48 49 | 
             
                expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
         | 
| 49 | 
            -
                   | 
| 50 | 
            -
                   | 
| 51 | 
            -
                   | 
| 50 | 
            +
                  "a2=r%20b&a3=2%20q&a3=a&b5=%3D%253D&c%40=&c2=&oauth_consumer_key=9dj" \
         | 
| 51 | 
            +
                  "dj82h48djs9d2&oauth_nonce=7d8f3e4a&oauth_signature_method=HMAC-SHA1" \
         | 
| 52 | 
            +
                  "&oauth_timestamp=137131201&oauth_token=kkk9d7dh3k39sjv7"
         | 
| 53 | 
            +
                )
         | 
| 52 54 | 
             
              end
         | 
| 53 55 |  | 
| 54 56 | 
             
              it 'should exclude the "oauth_signature" parameter when normalizing' do
         | 
| 55 57 | 
             
                parameters = [
         | 
| 56 | 
            -
                  [ | 
| 57 | 
            -
                  [ | 
| 58 | 
            -
                  [ | 
| 59 | 
            -
                  [ | 
| 58 | 
            +
                  %w[a 1],
         | 
| 59 | 
            +
                  %w[b 2],
         | 
| 60 | 
            +
                  %w[c 3],
         | 
| 61 | 
            +
                  %w[oauth_signature dpf43f3p2l4k3l03]
         | 
| 60 62 | 
             
                ]
         | 
| 61 63 | 
             
                expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
         | 
| 62 | 
            -
                  "a=1&b=2&c=3" | 
| 64 | 
            +
                  "a=1&b=2&c=3"
         | 
| 65 | 
            +
                )
         | 
| 63 66 | 
             
              end
         | 
| 64 67 |  | 
| 65 | 
            -
              it  | 
| 68 | 
            +
              it "should raise an error if normalizing parameters with bogus values" do
         | 
| 66 69 | 
             
                expect(lambda do
         | 
| 67 | 
            -
                  Signet::OAuth1.normalize_parameters | 
| 70 | 
            +
                  Signet::OAuth1.normalize_parameters 42
         | 
| 68 71 | 
             
                end).to raise_error(TypeError)
         | 
| 69 72 | 
             
              end
         | 
| 70 73 |  | 
| 71 | 
            -
              it  | 
| 74 | 
            +
              it "should raise an error if generating a base string with bogus values" do
         | 
| 72 75 | 
             
                expect(lambda do
         | 
| 73 76 | 
             
                  Signet::OAuth1.generate_base_string(
         | 
| 74 77 | 
             
                    "GET", "http://photos.example.net/photos", 42
         | 
| @@ -76,25 +79,25 @@ describe Signet::OAuth1 do | |
| 76 79 | 
             
                end).to raise_error(TypeError)
         | 
| 77 80 | 
             
              end
         | 
| 78 81 |  | 
| 79 | 
            -
              it  | 
| 82 | 
            +
              it "should correctly generate a base string" do
         | 
| 80 83 | 
             
                method = "GET"
         | 
| 81 84 | 
             
                uri = "http://photos.example.net/photos"
         | 
| 82 85 | 
             
                parameters = {
         | 
| 83 | 
            -
                  "oauth_consumer_key" | 
| 84 | 
            -
                  "oauth_token" | 
| 86 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 87 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 85 88 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 86 | 
            -
                  "oauth_timestamp" | 
| 87 | 
            -
                  "oauth_nonce" | 
| 88 | 
            -
                  "oauth_version" | 
| 89 | 
            -
                  "file" | 
| 90 | 
            -
                  "size" | 
| 89 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 90 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 91 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 92 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 93 | 
            +
                  "size"                   => "original"
         | 
| 91 94 | 
             
                }
         | 
| 92 95 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 93 | 
            -
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26"  | 
| 94 | 
            -
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 95 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 96 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26"  | 
| 97 | 
            -
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26"  | 
| 96 | 
            +
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
         | 
| 97 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 98 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 99 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 100 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 98 101 | 
             
                  "oauth_version%3D1.0%26size%3Doriginal"
         | 
| 99 102 | 
             
                )
         | 
| 100 103 | 
             
              end
         | 
| @@ -103,22 +106,22 @@ describe Signet::OAuth1 do | |
| 103 106 | 
             
                method = "GET"
         | 
| 104 107 | 
             
                uri = "http://photos.example.net/https%3A%2F%2Fwww.example.com"
         | 
| 105 108 | 
             
                parameters = {
         | 
| 106 | 
            -
                  "oauth_consumer_key" | 
| 107 | 
            -
                  "oauth_token" | 
| 109 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 110 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 108 111 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 109 | 
            -
                  "oauth_timestamp" | 
| 110 | 
            -
                  "oauth_nonce" | 
| 111 | 
            -
                  "oauth_version" | 
| 112 | 
            -
                  "file" | 
| 113 | 
            -
                  "size" | 
| 112 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 113 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 114 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 115 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 116 | 
            +
                  "size"                   => "original"
         | 
| 114 117 | 
             
                }
         | 
| 115 118 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 116 | 
            -
                  "GET&http%3A%2F%2Fphotos.example.net%2F"  | 
| 117 | 
            -
                  "https%253A%252F%252Fwww.example.com&file%3Dvacation.jpg%26"  | 
| 118 | 
            -
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 119 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 120 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26"  | 
| 121 | 
            -
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26"  | 
| 119 | 
            +
                  "GET&http%3A%2F%2Fphotos.example.net%2F" \
         | 
| 120 | 
            +
                  "https%253A%252F%252Fwww.example.com&file%3Dvacation.jpg%26" \
         | 
| 121 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 122 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 123 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 124 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 122 125 | 
             
                  "oauth_version%3D1.0%26size%3Doriginal"
         | 
| 123 126 | 
             
                )
         | 
| 124 127 | 
             
              end
         | 
| @@ -127,327 +130,353 @@ describe Signet::OAuth1 do | |
| 127 130 | 
             
                method = "GET"
         | 
| 128 131 | 
             
                uri = "http://example.com/r%20v/X?id=123"
         | 
| 129 132 | 
             
                parameters = {
         | 
| 130 | 
            -
                  "oauth_consumer_key" | 
| 131 | 
            -
                  "oauth_token" | 
| 133 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 134 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 132 135 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 133 | 
            -
                  "oauth_timestamp" | 
| 134 | 
            -
                  "oauth_nonce" | 
| 135 | 
            -
                  "oauth_version" | 
| 136 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 137 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 138 | 
            +
                  "oauth_version"          => "1.0"
         | 
| 136 139 | 
             
                }
         | 
| 137 140 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 138 | 
            -
                  "GET&http%3A%2F%2Fexample.com%2Fr%2520v%2FX&"  | 
| 139 | 
            -
                  "id%3D123%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 140 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 141 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26"  | 
| 142 | 
            -
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26"  | 
| 141 | 
            +
                  "GET&http%3A%2F%2Fexample.com%2Fr%2520v%2FX&" \
         | 
| 142 | 
            +
                  "id%3D123%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 143 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 144 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 145 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 143 146 | 
             
                  "oauth_version%3D1.0"
         | 
| 144 147 | 
             
                )
         | 
| 145 148 | 
             
              end
         | 
| 146 149 |  | 
| 147 | 
            -
              it  | 
| 150 | 
            +
              it "should correctly generate a base string when port 8080 is specified" do
         | 
| 148 151 | 
             
                method = "GET"
         | 
| 149 152 | 
             
                uri = "http://www.example.net:8080/?q=1"
         | 
| 150 153 | 
             
                parameters = {
         | 
| 151 | 
            -
                  "oauth_consumer_key" | 
| 152 | 
            -
                  "oauth_token" | 
| 154 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 155 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 153 156 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 154 | 
            -
                  "oauth_timestamp" | 
| 155 | 
            -
                  "oauth_nonce" | 
| 156 | 
            -
                  "oauth_version" | 
| 157 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 158 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 159 | 
            +
                  "oauth_version"          => "1.0"
         | 
| 157 160 | 
             
                }
         | 
| 158 161 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 159 | 
            -
                  "GET&http%3A%2F%2Fwww.example.net%3A8080%2F&"  | 
| 160 | 
            -
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 161 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 162 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26"  | 
| 162 | 
            +
                  "GET&http%3A%2F%2Fwww.example.net%3A8080%2F&" \
         | 
| 163 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 164 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 165 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26" \
         | 
| 163 166 | 
             
                  "oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26q%3D1"
         | 
| 164 167 | 
             
                )
         | 
| 165 168 | 
             
              end
         | 
| 166 169 |  | 
| 167 | 
            -
              it  | 
| 170 | 
            +
              it "should correctly generate a base string when port 80 is specified" do
         | 
| 168 171 | 
             
                method = "GET"
         | 
| 169 172 | 
             
                uri = "http://photos.example.net:80/photos"
         | 
| 170 173 | 
             
                parameters = {
         | 
| 171 | 
            -
                  "oauth_consumer_key" | 
| 172 | 
            -
                  "oauth_token" | 
| 174 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 175 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 173 176 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 174 | 
            -
                  "oauth_timestamp" | 
| 175 | 
            -
                  "oauth_nonce" | 
| 176 | 
            -
                  "oauth_version" | 
| 177 | 
            -
                  "file" | 
| 178 | 
            -
                  "size" | 
| 177 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 178 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 179 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 180 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 181 | 
            +
                  "size"                   => "original"
         | 
| 179 182 | 
             
                }
         | 
| 180 183 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 181 | 
            -
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26"  | 
| 182 | 
            -
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 183 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 184 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26"  | 
| 185 | 
            -
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26"  | 
| 184 | 
            +
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
         | 
| 185 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 186 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 187 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 188 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 186 189 | 
             
                  "oauth_version%3D1.0%26size%3Doriginal"
         | 
| 187 190 | 
             
                )
         | 
| 188 191 | 
             
              end
         | 
| 189 192 |  | 
| 190 | 
            -
              it  | 
| 193 | 
            +
              it "should correctly generate a base string when port 443 is specified" do
         | 
| 191 194 | 
             
                method = "GET"
         | 
| 192 195 | 
             
                uri = "https://photos.example.net:443/photos"
         | 
| 193 196 | 
             
                parameters = {
         | 
| 194 | 
            -
                  "oauth_consumer_key" | 
| 195 | 
            -
                  "oauth_token" | 
| 197 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 198 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 196 199 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 197 | 
            -
                  "oauth_timestamp" | 
| 198 | 
            -
                  "oauth_nonce" | 
| 199 | 
            -
                  "oauth_version" | 
| 200 | 
            -
                  "file" | 
| 201 | 
            -
                  "size" | 
| 200 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 201 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 202 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 203 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 204 | 
            +
                  "size"                   => "original"
         | 
| 202 205 | 
             
                }
         | 
| 203 206 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 204 | 
            -
                  "GET&https%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26"  | 
| 205 | 
            -
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 206 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 207 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26"  | 
| 208 | 
            -
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26"  | 
| 207 | 
            +
                  "GET&https%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
         | 
| 208 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 209 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 210 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 211 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 209 212 | 
             
                  "oauth_version%3D1.0%26size%3Doriginal"
         | 
| 210 213 | 
             
                )
         | 
| 211 214 | 
             
              end
         | 
| 212 215 |  | 
| 213 | 
            -
              it  | 
| 214 | 
            -
                method =  | 
| 216 | 
            +
              it "should correctly generate a base signature with uppercase scheme" do
         | 
| 217 | 
            +
                method = "GET"
         | 
| 215 218 | 
             
                uri =
         | 
| 216 219 | 
             
                  "HTTP://photos.example.net/photos?file=vacation.jpg"
         | 
| 217 220 | 
             
                parameters = {
         | 
| 218 | 
            -
                  "oauth_consumer_key" | 
| 219 | 
            -
                  "oauth_token" | 
| 221 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 222 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 220 223 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 221 | 
            -
                  "oauth_timestamp" | 
| 222 | 
            -
                  "oauth_nonce" | 
| 223 | 
            -
                  "oauth_version" | 
| 224 | 
            -
                  "size" | 
| 224 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 225 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 226 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 227 | 
            +
                  "size"                   => "original"
         | 
| 225 228 | 
             
                }
         | 
| 226 229 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 227 | 
            -
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26"  | 
| 228 | 
            -
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 229 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 230 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26"  | 
| 231 | 
            -
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26"  | 
| 230 | 
            +
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
         | 
| 231 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 232 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 233 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 234 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 232 235 | 
             
                  "oauth_version%3D1.0%26size%3Doriginal"
         | 
| 233 236 | 
             
                )
         | 
| 234 237 | 
             
              end
         | 
| 235 238 |  | 
| 236 | 
            -
              it  | 
| 237 | 
            -
                method =  | 
| 239 | 
            +
              it "should correctly generate a base signature with mixedcase authority" do
         | 
| 240 | 
            +
                method = "GET"
         | 
| 238 241 | 
             
                uri =
         | 
| 239 242 | 
             
                  "http://photos.eXaMpLe.NET/photos?file=vacation.jpg"
         | 
| 240 243 | 
             
                parameters = {
         | 
| 241 | 
            -
                  "oauth_consumer_key" | 
| 242 | 
            -
                  "oauth_token" | 
| 244 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 245 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 243 246 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 244 | 
            -
                  "oauth_timestamp" | 
| 245 | 
            -
                  "oauth_nonce" | 
| 246 | 
            -
                  "oauth_version" | 
| 247 | 
            -
                  "size" | 
| 247 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 248 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 249 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 250 | 
            +
                  "size"                   => "original"
         | 
| 248 251 | 
             
                }
         | 
| 249 252 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 250 | 
            -
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26"  | 
| 251 | 
            -
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 252 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 253 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26"  | 
| 254 | 
            -
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26"  | 
| 253 | 
            +
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
         | 
| 254 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 255 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 256 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 257 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 255 258 | 
             
                  "oauth_version%3D1.0%26size%3Doriginal"
         | 
| 256 259 | 
             
                )
         | 
| 257 260 | 
             
              end
         | 
| 258 261 |  | 
| 259 | 
            -
              it  | 
| 262 | 
            +
              it "should correctly generate a base signature with a method symbol" do
         | 
| 260 263 | 
             
                method = :get
         | 
| 261 264 | 
             
                uri =
         | 
| 262 265 | 
             
                  "http://photos.example.net/photos?file=vacation.jpg"
         | 
| 263 266 | 
             
                parameters = {
         | 
| 264 | 
            -
                  "oauth_consumer_key" | 
| 265 | 
            -
                  "oauth_token" | 
| 267 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 268 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 266 269 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 267 | 
            -
                  "oauth_timestamp" | 
| 268 | 
            -
                  "oauth_nonce" | 
| 269 | 
            -
                  "oauth_version" | 
| 270 | 
            -
                  "size" | 
| 270 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 271 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 272 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 273 | 
            +
                  "size"                   => "original"
         | 
| 271 274 | 
             
                }
         | 
| 272 275 | 
             
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 273 | 
            -
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26"  | 
| 274 | 
            -
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26"  | 
| 275 | 
            -
                  "oauth_nonce%3Dkllo9940pd9333jh%26"  | 
| 276 | 
            -
                  "oauth_signature_method%3DHMAC-SHA1%26"  | 
| 277 | 
            -
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26"  | 
| 276 | 
            +
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
         | 
| 277 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 278 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 279 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 280 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 278 281 | 
             
                  "oauth_version%3D1.0%26size%3Doriginal"
         | 
| 279 282 | 
             
                )
         | 
| 280 283 | 
             
              end
         | 
| 281 284 |  | 
| 282 | 
            -
              it  | 
| 285 | 
            +
              it "should correctly generate a base signature with duplicated query params" do
         | 
| 286 | 
            +
                method = "GET"
         | 
| 287 | 
            +
                uri = "http://photos.example.net/photos?foo=bar&foo=baz&foo=qux"
         | 
| 288 | 
            +
                parameters = {
         | 
| 289 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 290 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 291 | 
            +
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 292 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 293 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 294 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 295 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 296 | 
            +
                  "size"                   => "original"
         | 
| 297 | 
            +
                }
         | 
| 298 | 
            +
                expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
         | 
| 299 | 
            +
                  "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
         | 
| 300 | 
            +
                  "foo%3Dbar%26" \
         | 
| 301 | 
            +
                  "foo%3Dbaz%26" \
         | 
| 302 | 
            +
                  "foo%3Dqux%26" \
         | 
| 303 | 
            +
                  "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
         | 
| 304 | 
            +
                  "oauth_nonce%3Dkllo9940pd9333jh%26" \
         | 
| 305 | 
            +
                  "oauth_signature_method%3DHMAC-SHA1%26" \
         | 
| 306 | 
            +
                  "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
         | 
| 307 | 
            +
                  "oauth_version%3D1.0%26size%3Doriginal"
         | 
| 308 | 
            +
                                                                                        )
         | 
| 309 | 
            +
              end
         | 
| 310 | 
            +
             | 
| 311 | 
            +
              it "should correctly generate an authorization header" do
         | 
| 283 312 | 
             
                parameters = [
         | 
| 284 | 
            -
                  [ | 
| 285 | 
            -
                  [ | 
| 313 | 
            +
                  %w[oauth_consumer_key 0685bd9184jfhq22],
         | 
| 314 | 
            +
                  %w[oauth_token ad180jjd733klru7],
         | 
| 286 315 | 
             
                  ["oauth_signature_method", "HMAC-SHA1"],
         | 
| 287 316 | 
             
                  ["oauth_signature", "wOJIO9A2W5mFwDgiDvZbTSMK/PY="],
         | 
| 288 | 
            -
                  [ | 
| 289 | 
            -
                  [ | 
| 317 | 
            +
                  %w[oauth_timestamp 137131200],
         | 
| 318 | 
            +
                  %w[oauth_nonce 4572616e48616d6d65724c61686176],
         | 
| 290 319 | 
             
                  ["oauth_version", "1.0"]
         | 
| 291 320 | 
             
                ]
         | 
| 292 321 | 
             
                expect(Signet::OAuth1.generate_authorization_header(
         | 
| 293 | 
            -
             | 
| 294 | 
            -
             | 
| 295 | 
            -
             | 
| 296 | 
            -
             | 
| 297 | 
            -
             | 
| 298 | 
            -
             | 
| 299 | 
            -
             | 
| 300 | 
            -
             | 
| 301 | 
            -
             | 
| 302 | 
            -
             | 
| 303 | 
            -
             | 
| 304 | 
            -
              end
         | 
| 305 | 
            -
             | 
| 306 | 
            -
              it  | 
| 307 | 
            -
             | 
| 322 | 
            +
                         parameters, "http://sp.example.com/"
         | 
| 323 | 
            +
                       )).to eq(
         | 
| 324 | 
            +
                         'OAuth realm="http://sp.example.com/", ' \
         | 
| 325 | 
            +
                         'oauth_consumer_key="0685bd9184jfhq22", ' \
         | 
| 326 | 
            +
                         'oauth_token="ad180jjd733klru7", ' \
         | 
| 327 | 
            +
                         'oauth_signature_method="HMAC-SHA1", ' \
         | 
| 328 | 
            +
                         'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
         | 
| 329 | 
            +
                         'oauth_timestamp="137131200", ' \
         | 
| 330 | 
            +
                         'oauth_nonce="4572616e48616d6d65724c61686176", ' \
         | 
| 331 | 
            +
                         'oauth_version="1.0"'
         | 
| 332 | 
            +
                       )
         | 
| 333 | 
            +
              end
         | 
| 334 | 
            +
             | 
| 335 | 
            +
              it "should raise an error if generating an authorization header " \
         | 
| 336 | 
            +
                 "with bogus values" do
         | 
| 308 337 | 
             
                expect(lambda do
         | 
| 309 | 
            -
                  Signet::OAuth1.generate_authorization_header | 
| 338 | 
            +
                  Signet::OAuth1.generate_authorization_header 42
         | 
| 310 339 | 
             
                end).to raise_error(TypeError)
         | 
| 311 340 | 
             
              end
         | 
| 312 341 |  | 
| 313 | 
            -
              it  | 
| 314 | 
            -
             | 
| 342 | 
            +
              it "should raise an error if generating an authorization header " \
         | 
| 343 | 
            +
                 'with the "realm" parameter specified the wrong way' do
         | 
| 315 344 | 
             
                parameters = [
         | 
| 316 345 | 
             
                  ["realm", "http://sp.example.com/"],
         | 
| 317 | 
            -
                  [ | 
| 318 | 
            -
                  [ | 
| 346 | 
            +
                  %w[oauth_consumer_key 0685bd9184jfhq22],
         | 
| 347 | 
            +
                  %w[oauth_token ad180jjd733klru7],
         | 
| 319 348 | 
             
                  ["oauth_signature_method", "HMAC-SHA1"],
         | 
| 320 349 | 
             
                  ["oauth_signature", "wOJIO9A2W5mFwDgiDvZbTSMK/PY="],
         | 
| 321 | 
            -
                  [ | 
| 322 | 
            -
                  [ | 
| 350 | 
            +
                  %w[oauth_timestamp 137131200],
         | 
| 351 | 
            +
                  %w[oauth_nonce 4572616e48616d6d65724c61686176],
         | 
| 323 352 | 
             
                  ["oauth_version", "1.0"]
         | 
| 324 353 | 
             
                ]
         | 
| 325 354 | 
             
                expect(lambda do
         | 
| 326 | 
            -
                  Signet::OAuth1.generate_authorization_header | 
| 355 | 
            +
                  Signet::OAuth1.generate_authorization_header parameters
         | 
| 327 356 | 
             
                end).to raise_error(ArgumentError)
         | 
| 328 357 | 
             
              end
         | 
| 329 358 |  | 
| 330 | 
            -
              it  | 
| 359 | 
            +
              it "should correctly parse an authorization header" do
         | 
| 331 360 | 
             
                parameters = Signet::OAuth1.parse_authorization_header(
         | 
| 332 | 
            -
                  'OAuth realm="http://sp.example.com/", '  | 
| 333 | 
            -
                  'oauth_consumer_key="0685bd9184jfhq22", '  | 
| 334 | 
            -
                  'oauth_token="ad180jjd733klru7", '  | 
| 335 | 
            -
                  'oauth_signature_method="HMAC-SHA1", '  | 
| 336 | 
            -
                  'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", '  | 
| 337 | 
            -
                  'oauth_timestamp="137131200", '  | 
| 338 | 
            -
                  'oauth_nonce="4572616e48616d6d65724c61686176", '  | 
| 361 | 
            +
                  'OAuth realm="http://sp.example.com/", ' \
         | 
| 362 | 
            +
                  'oauth_consumer_key="0685bd9184jfhq22", ' \
         | 
| 363 | 
            +
                  'oauth_token="ad180jjd733klru7", ' \
         | 
| 364 | 
            +
                  'oauth_signature_method="HMAC-SHA1", ' \
         | 
| 365 | 
            +
                  'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
         | 
| 366 | 
            +
                  'oauth_timestamp="137131200", ' \
         | 
| 367 | 
            +
                  'oauth_nonce="4572616e48616d6d65724c61686176", ' \
         | 
| 339 368 | 
             
                  'oauth_version="1.0"'
         | 
| 340 | 
            -
                ). | 
| 341 | 
            -
                expect(parameters[ | 
| 342 | 
            -
                expect(parameters[ | 
| 343 | 
            -
                expect(parameters[ | 
| 344 | 
            -
                expect(parameters[ | 
| 345 | 
            -
                expect(parameters[ | 
| 346 | 
            -
                expect(parameters[ | 
| 347 | 
            -
                expect(parameters[ | 
| 348 | 
            -
                expect(parameters[ | 
| 349 | 
            -
              end
         | 
| 350 | 
            -
             | 
| 351 | 
            -
              it  | 
| 369 | 
            +
                ).each_with_object({}) { |(k, v), h| h[k] = v; }
         | 
| 370 | 
            +
                expect(parameters["realm"]).to eq "http://sp.example.com/"
         | 
| 371 | 
            +
                expect(parameters["oauth_consumer_key"]).to eq "0685bd9184jfhq22"
         | 
| 372 | 
            +
                expect(parameters["oauth_token"]).to eq "ad180jjd733klru7"
         | 
| 373 | 
            +
                expect(parameters["oauth_signature_method"]).to eq "HMAC-SHA1"
         | 
| 374 | 
            +
                expect(parameters["oauth_signature"]).to eq "wOJIO9A2W5mFwDgiDvZbTSMK/PY="
         | 
| 375 | 
            +
                expect(parameters["oauth_timestamp"]).to eq "137131200"
         | 
| 376 | 
            +
                expect(parameters["oauth_nonce"]).to eq "4572616e48616d6d65724c61686176"
         | 
| 377 | 
            +
                expect(parameters["oauth_version"]).to eq "1.0"
         | 
| 378 | 
            +
              end
         | 
| 379 | 
            +
             | 
| 380 | 
            +
              it "should not unescape a realm in an authorization header" do
         | 
| 352 381 | 
             
                parameters = Signet::OAuth1.parse_authorization_header(
         | 
| 353 | 
            -
                  'OAuth realm="http%3A%2F%2Fsp.example.com%2F", '  | 
| 354 | 
            -
                  'domain="http%3A%2F%2Fsp.example.com%2F", '  | 
| 355 | 
            -
                  'oauth_consumer_key="0685bd9184jfhq22", '  | 
| 356 | 
            -
                  'oauth_token="ad180jjd733klru7", '  | 
| 357 | 
            -
                  'oauth_signature_method="HMAC-SHA1", '  | 
| 358 | 
            -
                  'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", '  | 
| 359 | 
            -
                  'oauth_timestamp="137131200", '  | 
| 360 | 
            -
                  'oauth_nonce="4572616e48616d6d65724c61686176", '  | 
| 382 | 
            +
                  'OAuth realm="http%3A%2F%2Fsp.example.com%2F", ' \
         | 
| 383 | 
            +
                  'domain="http%3A%2F%2Fsp.example.com%2F", ' \
         | 
| 384 | 
            +
                  'oauth_consumer_key="0685bd9184jfhq22", ' \
         | 
| 385 | 
            +
                  'oauth_token="ad180jjd733klru7", ' \
         | 
| 386 | 
            +
                  'oauth_signature_method="HMAC-SHA1", ' \
         | 
| 387 | 
            +
                  'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
         | 
| 388 | 
            +
                  'oauth_timestamp="137131200", ' \
         | 
| 389 | 
            +
                  'oauth_nonce="4572616e48616d6d65724c61686176", ' \
         | 
| 361 390 | 
             
                  'oauth_version="1.0"'
         | 
| 362 | 
            -
                ). | 
| 363 | 
            -
                expect(parameters[ | 
| 364 | 
            -
                expect(parameters[ | 
| 365 | 
            -
                expect(parameters[ | 
| 366 | 
            -
                expect(parameters[ | 
| 367 | 
            -
                expect(parameters[ | 
| 368 | 
            -
                expect(parameters[ | 
| 369 | 
            -
                expect(parameters[ | 
| 370 | 
            -
                expect(parameters[ | 
| 371 | 
            -
                expect(parameters[ | 
| 372 | 
            -
              end
         | 
| 373 | 
            -
             | 
| 374 | 
            -
              it  | 
| 375 | 
            -
             | 
| 391 | 
            +
                ).each_with_object({}) { |(k, v), h| h[k] = v; }
         | 
| 392 | 
            +
                expect(parameters["realm"]).to eq "http%3A%2F%2Fsp.example.com%2F"
         | 
| 393 | 
            +
                expect(parameters["domain"]).to eq "http://sp.example.com/"
         | 
| 394 | 
            +
                expect(parameters["oauth_consumer_key"]).to eq "0685bd9184jfhq22"
         | 
| 395 | 
            +
                expect(parameters["oauth_token"]).to eq "ad180jjd733klru7"
         | 
| 396 | 
            +
                expect(parameters["oauth_signature_method"]).to eq "HMAC-SHA1"
         | 
| 397 | 
            +
                expect(parameters["oauth_signature"]).to eq "wOJIO9A2W5mFwDgiDvZbTSMK/PY="
         | 
| 398 | 
            +
                expect(parameters["oauth_timestamp"]).to eq "137131200"
         | 
| 399 | 
            +
                expect(parameters["oauth_nonce"]).to eq "4572616e48616d6d65724c61686176"
         | 
| 400 | 
            +
                expect(parameters["oauth_version"]).to eq "1.0"
         | 
| 401 | 
            +
              end
         | 
| 402 | 
            +
             | 
| 403 | 
            +
              it "should raise an error if parsing an authorization header " \
         | 
| 404 | 
            +
                 "with bogus values" do
         | 
| 376 405 | 
             
                expect(lambda do
         | 
| 377 | 
            -
                  Signet::OAuth1.parse_authorization_header | 
| 406 | 
            +
                  Signet::OAuth1.parse_authorization_header 42
         | 
| 378 407 | 
             
                end).to raise_error(TypeError)
         | 
| 379 408 | 
             
              end
         | 
| 380 409 |  | 
| 381 | 
            -
              it  | 
| 410 | 
            +
              it "should raise an error if parsing a non-OAuth authorization header" do
         | 
| 382 411 | 
             
                expect(lambda do
         | 
| 383 412 | 
             
                  Signet::OAuth1.parse_authorization_header(
         | 
| 384 | 
            -
                     | 
| 413 | 
            +
                    "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
         | 
| 385 414 | 
             
                  )
         | 
| 386 415 | 
             
                end).to raise_error(Signet::ParseError)
         | 
| 387 416 | 
             
              end
         | 
| 388 417 |  | 
| 389 | 
            -
              it  | 
| 418 | 
            +
              it "should correctly parse a form encoded credential" do
         | 
| 390 419 | 
             
                credential = Signet::OAuth1.parse_form_encoded_credentials(
         | 
| 391 | 
            -
                   | 
| 420 | 
            +
                  "oauth_token=hh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03"
         | 
| 392 421 | 
             
                )
         | 
| 393 | 
            -
                expect(credential.key).to eq  | 
| 394 | 
            -
                expect(credential.secret).to eq  | 
| 422 | 
            +
                expect(credential.key).to eq "hh5s93j4hdidpola"
         | 
| 423 | 
            +
                expect(credential.secret).to eq "hdhd0244k9j7ao03"
         | 
| 395 424 | 
             
              end
         | 
| 396 425 |  | 
| 397 | 
            -
              it  | 
| 426 | 
            +
              it "should correctly parse a form encoded credential" do
         | 
| 398 427 | 
             
                credential = Signet::OAuth1.parse_form_encoded_credentials(
         | 
| 399 | 
            -
                   | 
| 400 | 
            -
                   | 
| 428 | 
            +
                  "oauth_token=hdk48Djdsa&oauth_token_secret=xyz4992k83j47x0b&" \
         | 
| 429 | 
            +
                  "oauth_callback_confirmed=true"
         | 
| 401 430 | 
             
                )
         | 
| 402 | 
            -
                expect(credential.key).to eq  | 
| 403 | 
            -
                expect(credential.secret).to eq  | 
| 431 | 
            +
                expect(credential.key).to eq "hdk48Djdsa"
         | 
| 432 | 
            +
                expect(credential.secret).to eq "xyz4992k83j47x0b"
         | 
| 404 433 | 
             
              end
         | 
| 405 434 |  | 
| 406 | 
            -
              it  | 
| 407 | 
            -
             | 
| 435 | 
            +
              it "should raise an error if parsing a form encoded credential " \
         | 
| 436 | 
            +
                 "with bogus values" do
         | 
| 408 437 | 
             
                expect(lambda do
         | 
| 409 | 
            -
                  Signet::OAuth1.parse_form_encoded_credentials | 
| 438 | 
            +
                  Signet::OAuth1.parse_form_encoded_credentials 42
         | 
| 410 439 | 
             
                end).to raise_error(TypeError)
         | 
| 411 440 | 
             
              end
         | 
| 412 441 |  | 
| 413 | 
            -
              it  | 
| 442 | 
            +
              it "should correctly generate a signature for a set of parameters" do
         | 
| 414 443 | 
             
                method = :get
         | 
| 415 444 | 
             
                uri = "http://photos.example.net/photos"
         | 
| 416 | 
            -
                client_credential_secret =  | 
| 417 | 
            -
                token_credential_secret =  | 
| 445 | 
            +
                client_credential_secret = "kd94hf93k423kf44"
         | 
| 446 | 
            +
                token_credential_secret = "pfkkdhi9sl3r4s00"
         | 
| 418 447 | 
             
                parameters = {
         | 
| 419 | 
            -
                  "oauth_consumer_key" | 
| 420 | 
            -
                  "oauth_token" | 
| 448 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 449 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 421 450 | 
             
                  "oauth_signature_method" => "HMAC-SHA1",
         | 
| 422 | 
            -
                  "oauth_timestamp" | 
| 423 | 
            -
                  "oauth_nonce" | 
| 424 | 
            -
                  "oauth_version" | 
| 425 | 
            -
                  "file" | 
| 426 | 
            -
                  "size" | 
| 451 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 452 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 453 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 454 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 455 | 
            +
                  "size"                   => "original"
         | 
| 427 456 | 
             
                }
         | 
| 428 457 | 
             
                expect(Signet::OAuth1.sign_parameters(
         | 
| 429 | 
            -
             | 
| 430 | 
            -
             | 
| 431 | 
            -
             | 
| 432 | 
            -
             | 
| 433 | 
            -
             | 
| 434 | 
            -
             | 
| 458 | 
            +
                         method,
         | 
| 459 | 
            +
                         uri,
         | 
| 460 | 
            +
                         parameters,
         | 
| 461 | 
            +
                         client_credential_secret,
         | 
| 462 | 
            +
                         token_credential_secret
         | 
| 463 | 
            +
                       )).to eq "tR3+Ty81lMeYAr/Fid0kMTYa/WM="
         | 
| 435 464 | 
             
              end
         | 
| 436 465 |  | 
| 437 | 
            -
              it  | 
| 466 | 
            +
              it "should raise an error when trying to sign with with unknown method" do
         | 
| 438 467 | 
             
                method = :get
         | 
| 439 468 | 
             
                uri = "http://photos.example.net/photos"
         | 
| 440 | 
            -
                client_credential_secret =  | 
| 441 | 
            -
                token_credential_secret =  | 
| 469 | 
            +
                client_credential_secret = "kd94hf93k423kf44"
         | 
| 470 | 
            +
                token_credential_secret = "pfkkdhi9sl3r4s00"
         | 
| 442 471 | 
             
                parameters = {
         | 
| 443 | 
            -
                  "oauth_consumer_key" | 
| 444 | 
            -
                  "oauth_token" | 
| 472 | 
            +
                  "oauth_consumer_key"     => "dpf43f3p2l4k3l03",
         | 
| 473 | 
            +
                  "oauth_token"            => "nnch734d00sl2jdk",
         | 
| 445 474 | 
             
                  "oauth_signature_method" => "HMAC-BOGUS", # Unknown signature method
         | 
| 446 | 
            -
                  "oauth_timestamp" | 
| 447 | 
            -
                  "oauth_nonce" | 
| 448 | 
            -
                  "oauth_version" | 
| 449 | 
            -
                  "file" | 
| 450 | 
            -
                  "size" | 
| 475 | 
            +
                  "oauth_timestamp"        => "1191242096",
         | 
| 476 | 
            +
                  "oauth_nonce"            => "kllo9940pd9333jh",
         | 
| 477 | 
            +
                  "oauth_version"          => "1.0",
         | 
| 478 | 
            +
                  "file"                   => "vacation.jpg",
         | 
| 479 | 
            +
                  "size"                   => "original"
         | 
| 451 480 | 
             
                }
         | 
| 452 481 | 
             
                expect(lambda do
         | 
| 453 482 | 
             
                  Signet::OAuth1.sign_parameters(
         | 
| @@ -460,548 +489,548 @@ describe Signet::OAuth1 do | |
| 460 489 | 
             
                end).to raise_error(NotImplementedError)
         | 
| 461 490 | 
             
              end
         | 
| 462 491 |  | 
| 463 | 
            -
              it  | 
| 464 | 
            -
                authorization_uri =  | 
| 465 | 
            -
                temporary_credential_key =  | 
| 466 | 
            -
                callback =  | 
| 492 | 
            +
              it "should correctly generate authorization URIs" do
         | 
| 493 | 
            +
                authorization_uri = "http://photos.example.net/authorize"
         | 
| 494 | 
            +
                temporary_credential_key = "hh5s93j4hdidpola"
         | 
| 495 | 
            +
                callback = "http://printer.example.com/request_token_ready"
         | 
| 467 496 | 
             
                parsed_uri = Addressable::URI.parse(
         | 
| 468 | 
            -
             | 
| 497 | 
            +
                  Signet::OAuth1.generate_authorization_uri(
         | 
| 469 498 | 
             
                    authorization_uri,
         | 
| 470 | 
            -
                    : | 
| 471 | 
            -
                    :callback | 
| 499 | 
            +
                    temporary_credential_key: temporary_credential_key,
         | 
| 500 | 
            +
                    callback:                 callback
         | 
| 472 501 | 
             
                  )
         | 
| 473 502 | 
             
                )
         | 
| 474 | 
            -
                expect(parsed_uri.query_values).to have_key( | 
| 475 | 
            -
                expect(parsed_uri.query_values[ | 
| 476 | 
            -
                expect(parsed_uri.query_values).to have_key( | 
| 477 | 
            -
                expect(parsed_uri.query_values[ | 
| 503 | 
            +
                expect(parsed_uri.query_values).to have_key("oauth_token")
         | 
| 504 | 
            +
                expect(parsed_uri.query_values["oauth_token"]).to eq temporary_credential_key
         | 
| 505 | 
            +
                expect(parsed_uri.query_values).to have_key("oauth_callback")
         | 
| 506 | 
            +
                expect(parsed_uri.query_values["oauth_callback"]).to eq callback
         | 
| 478 507 | 
             
              end
         | 
| 479 508 | 
             
            end
         | 
| 480 509 |  | 
| 481 | 
            -
            describe Signet::OAuth1,  | 
| 510 | 
            +
            describe Signet::OAuth1, "when generating temporary credentials parameters" do
         | 
| 482 511 | 
             
              before do
         | 
| 483 | 
            -
                @client_credential_key =  | 
| 484 | 
            -
                @callback =  | 
| 485 | 
            -
                @signature_method =  | 
| 486 | 
            -
                @scope =  | 
| 487 | 
            -
                @additional_parameters = [[ | 
| 512 | 
            +
                @client_credential_key = "dpf43f3p2l4k3l03"
         | 
| 513 | 
            +
                @callback = "http://printer.example.com/request_token_ready"
         | 
| 514 | 
            +
                @signature_method = "HMAC-SHA1"
         | 
| 515 | 
            +
                @scope = "http://photos.example.com/full_access"
         | 
| 516 | 
            +
                @additional_parameters = [["scope", @scope]]
         | 
| 488 517 | 
             
                @unsigned_parameters =
         | 
| 489 518 | 
             
                  Signet::OAuth1.unsigned_temporary_credential_parameters(
         | 
| 490 | 
            -
                    : | 
| 491 | 
            -
                    : | 
| 492 | 
            -
                    : | 
| 493 | 
            -
                    : | 
| 494 | 
            -
                  ). | 
| 519 | 
            +
                    client_credential_key: @client_credential_key,
         | 
| 520 | 
            +
                    callback:              @callback,
         | 
| 521 | 
            +
                    signature_method:      @signature_method,
         | 
| 522 | 
            +
                    additional_parameters: @additional_parameters
         | 
| 523 | 
            +
                  ).each_with_object({}) { |(k, v), h| h[k] = v; }
         | 
| 495 524 | 
             
              end
         | 
| 496 525 |  | 
| 497 | 
            -
              it  | 
| 526 | 
            +
              it "should raise an error if the client credential key is missing" do
         | 
| 498 527 | 
             
                expect(lambda do
         | 
| 499 528 | 
             
                  Signet::OAuth1.unsigned_temporary_credential_parameters(
         | 
| 500 | 
            -
                    : | 
| 501 | 
            -
                    : | 
| 502 | 
            -
                    : | 
| 503 | 
            -
                    : | 
| 529 | 
            +
                    client_credential_key: nil,
         | 
| 530 | 
            +
                    callback:              @callback,
         | 
| 531 | 
            +
                    signature_method:      @signature_method,
         | 
| 532 | 
            +
                    additional_parameters: @additional_parameters
         | 
| 504 533 | 
             
                  )
         | 
| 505 534 | 
             
                end).to raise_error(ArgumentError)
         | 
| 506 535 | 
             
              end
         | 
| 507 536 |  | 
| 508 | 
            -
              it  | 
| 509 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 510 | 
            -
                expect(@unsigned_parameters[ | 
| 537 | 
            +
              it "should have the correct client credential key" do
         | 
| 538 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_consumer_key")
         | 
| 539 | 
            +
                expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
         | 
| 511 540 | 
             
              end
         | 
| 512 541 |  | 
| 513 | 
            -
              it  | 
| 514 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 515 | 
            -
                expect(@unsigned_parameters[ | 
| 542 | 
            +
              it "should have the correct signature method" do
         | 
| 543 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_signature_method")
         | 
| 544 | 
            +
                expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
         | 
| 516 545 | 
             
              end
         | 
| 517 546 |  | 
| 518 | 
            -
              it  | 
| 547 | 
            +
              it "should have a valid timestamp" do
         | 
| 519 548 | 
             
                # Verify that we have a timestamp, it's in the correct format and within
         | 
| 520 549 | 
             
                # a reasonable range of the current time.
         | 
| 521 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 522 | 
            -
                expect(@unsigned_parameters[ | 
| 523 | 
            -
                expect(@unsigned_parameters[ | 
| 524 | 
            -
                expect(@unsigned_parameters[ | 
| 550 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_timestamp")
         | 
| 551 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
         | 
| 552 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
         | 
| 553 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
         | 
| 525 554 | 
             
              end
         | 
| 526 555 |  | 
| 527 | 
            -
              it  | 
| 556 | 
            +
              it "should have a valid nonce" do
         | 
| 528 557 | 
             
                # Verify that we have a nonce and that it has sufficient length for
         | 
| 529 558 | 
             
                # uniqueness.
         | 
| 530 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 531 | 
            -
                expect(@unsigned_parameters[ | 
| 559 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_nonce")
         | 
| 560 | 
            +
                expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
         | 
| 532 561 | 
             
              end
         | 
| 533 562 |  | 
| 534 | 
            -
              it  | 
| 535 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 536 | 
            -
                expect(@unsigned_parameters[ | 
| 563 | 
            +
              it "should have the correct callback" do
         | 
| 564 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_callback")
         | 
| 565 | 
            +
                expect(@unsigned_parameters["oauth_callback"]).to eq @callback
         | 
| 537 566 | 
             
              end
         | 
| 538 567 |  | 
| 539 | 
            -
              it  | 
| 540 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 541 | 
            -
                expect(@unsigned_parameters[ | 
| 568 | 
            +
              it "should have the correct scope parameter" do
         | 
| 569 | 
            +
                expect(@unsigned_parameters).to have_key("scope")
         | 
| 570 | 
            +
                expect(@unsigned_parameters["scope"]).to eq @scope
         | 
| 542 571 | 
             
              end
         | 
| 543 572 |  | 
| 544 | 
            -
              it  | 
| 545 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 546 | 
            -
                expect(@unsigned_parameters[ | 
| 573 | 
            +
              it "should have the correct OAuth version" do
         | 
| 574 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_version")
         | 
| 575 | 
            +
                expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
         | 
| 547 576 | 
             
              end
         | 
| 548 577 | 
             
            end
         | 
| 549 578 |  | 
| 550 | 
            -
            describe Signet::OAuth1,  | 
| 579 | 
            +
            describe Signet::OAuth1, "when generating token credential parameters" do
         | 
| 551 580 | 
             
              before do
         | 
| 552 | 
            -
                @client_credential_key =  | 
| 553 | 
            -
                @temporary_credential_key =  | 
| 554 | 
            -
                @verifier =  | 
| 555 | 
            -
                @signature_method =  | 
| 581 | 
            +
                @client_credential_key = "dpf43f3p2l4k3l03"
         | 
| 582 | 
            +
                @temporary_credential_key = "hh5s93j4hdidpola"
         | 
| 583 | 
            +
                @verifier = "473f82d3"
         | 
| 584 | 
            +
                @signature_method = "HMAC-SHA1"
         | 
| 556 585 | 
             
                @unsigned_parameters =
         | 
| 557 586 | 
             
                  Signet::OAuth1.unsigned_token_credential_parameters(
         | 
| 558 | 
            -
                    : | 
| 559 | 
            -
                    : | 
| 560 | 
            -
                    : | 
| 561 | 
            -
                    : | 
| 562 | 
            -
                  ). | 
| 587 | 
            +
                    client_credential_key:    @client_credential_key,
         | 
| 588 | 
            +
                    temporary_credential_key: @temporary_credential_key,
         | 
| 589 | 
            +
                    signature_method:         @signature_method,
         | 
| 590 | 
            +
                    verifier:                 @verifier
         | 
| 591 | 
            +
                  ).each_with_object({}) { |(k, v), h| h[k] = v; }
         | 
| 563 592 | 
             
              end
         | 
| 564 593 |  | 
| 565 | 
            -
              it  | 
| 594 | 
            +
              it "should raise an error if the client credential key is missing" do
         | 
| 566 595 | 
             
                expect(lambda do
         | 
| 567 596 | 
             
                  Signet::OAuth1.unsigned_token_credential_parameters(
         | 
| 568 | 
            -
                    : | 
| 569 | 
            -
                    : | 
| 570 | 
            -
                    : | 
| 571 | 
            -
                    : | 
| 597 | 
            +
                    client_credential_key:    nil,
         | 
| 598 | 
            +
                    temporary_credential_key: @temporary_credential_key,
         | 
| 599 | 
            +
                    signature_method:         @signature_method,
         | 
| 600 | 
            +
                    verifier:                 @verifier
         | 
| 572 601 | 
             
                  )
         | 
| 573 602 | 
             
                end).to raise_error(ArgumentError)
         | 
| 574 603 | 
             
              end
         | 
| 575 604 |  | 
| 576 | 
            -
              it  | 
| 605 | 
            +
              it "should raise an error if the temporary credential key is missing" do
         | 
| 577 606 | 
             
                expect(lambda do
         | 
| 578 607 | 
             
                  Signet::OAuth1.unsigned_token_credential_parameters(
         | 
| 579 | 
            -
                    : | 
| 580 | 
            -
                    : | 
| 581 | 
            -
                    : | 
| 582 | 
            -
                    : | 
| 608 | 
            +
                    client_credential_key:    @client_credential_key,
         | 
| 609 | 
            +
                    temporary_credential_key: nil,
         | 
| 610 | 
            +
                    signature_method:         @signature_method,
         | 
| 611 | 
            +
                    verifier:                 @verifier
         | 
| 583 612 | 
             
                  )
         | 
| 584 613 | 
             
                end).to raise_error(ArgumentError)
         | 
| 585 614 | 
             
              end
         | 
| 586 615 |  | 
| 587 | 
            -
              it  | 
| 616 | 
            +
              it "should raise an error if the verifier is missing" do
         | 
| 588 617 | 
             
                expect(lambda do
         | 
| 589 618 | 
             
                  Signet::OAuth1.unsigned_token_credential_parameters(
         | 
| 590 | 
            -
                    : | 
| 591 | 
            -
                    : | 
| 592 | 
            -
                    : | 
| 593 | 
            -
                    : | 
| 619 | 
            +
                    client_credential_key:    @client_credential_key,
         | 
| 620 | 
            +
                    temporary_credential_key: @temporary_credential_key,
         | 
| 621 | 
            +
                    signature_method:         @signature_method,
         | 
| 622 | 
            +
                    verifier:                 nil
         | 
| 594 623 | 
             
                  )
         | 
| 595 624 | 
             
                end).to raise_error(ArgumentError)
         | 
| 596 625 | 
             
              end
         | 
| 597 626 |  | 
| 598 | 
            -
              it  | 
| 599 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 600 | 
            -
                expect(@unsigned_parameters[ | 
| 627 | 
            +
              it "should have the correct client credential key" do
         | 
| 628 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_consumer_key")
         | 
| 629 | 
            +
                expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
         | 
| 601 630 | 
             
              end
         | 
| 602 631 |  | 
| 603 | 
            -
              it  | 
| 604 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 605 | 
            -
                expect(@unsigned_parameters[ | 
| 632 | 
            +
              it "should have the correct temporary credentials key" do
         | 
| 633 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_token")
         | 
| 634 | 
            +
                expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential_key
         | 
| 606 635 | 
             
              end
         | 
| 607 636 |  | 
| 608 | 
            -
              it  | 
| 609 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 610 | 
            -
                expect(@unsigned_parameters[ | 
| 637 | 
            +
              it "should have the correct signature method" do
         | 
| 638 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_signature_method")
         | 
| 639 | 
            +
                expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
         | 
| 611 640 | 
             
              end
         | 
| 612 641 |  | 
| 613 | 
            -
              it  | 
| 642 | 
            +
              it "should have a valid timestamp" do
         | 
| 614 643 | 
             
                # Verify that we have a timestamp, it's in the correct format and within
         | 
| 615 644 | 
             
                # a reasonable range of the current time.
         | 
| 616 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 617 | 
            -
                expect(@unsigned_parameters[ | 
| 618 | 
            -
                expect(@unsigned_parameters[ | 
| 619 | 
            -
                expect(@unsigned_parameters[ | 
| 645 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_timestamp")
         | 
| 646 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
         | 
| 647 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
         | 
| 648 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
         | 
| 620 649 | 
             
              end
         | 
| 621 650 |  | 
| 622 | 
            -
              it  | 
| 651 | 
            +
              it "should have a valid nonce" do
         | 
| 623 652 | 
             
                # Verify that we have a nonce and that it has sufficient length for
         | 
| 624 653 | 
             
                # uniqueness.
         | 
| 625 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 626 | 
            -
                expect(@unsigned_parameters[ | 
| 654 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_nonce")
         | 
| 655 | 
            +
                expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
         | 
| 627 656 | 
             
              end
         | 
| 628 657 |  | 
| 629 | 
            -
              it  | 
| 630 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 631 | 
            -
                expect(@unsigned_parameters[ | 
| 658 | 
            +
              it "should have the verifier" do
         | 
| 659 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_verifier")
         | 
| 660 | 
            +
                expect(@unsigned_parameters["oauth_verifier"]).to eq @verifier
         | 
| 632 661 | 
             
              end
         | 
| 633 662 |  | 
| 634 | 
            -
              it  | 
| 635 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 636 | 
            -
                expect(@unsigned_parameters[ | 
| 663 | 
            +
              it "should have the correct OAuth version" do
         | 
| 664 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_version")
         | 
| 665 | 
            +
                expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
         | 
| 637 666 | 
             
              end
         | 
| 638 667 | 
             
            end
         | 
| 639 668 |  | 
| 640 | 
            -
            describe Signet::OAuth1,  | 
| 669 | 
            +
            describe Signet::OAuth1, "when generating protected resource parameters" do
         | 
| 641 670 | 
             
              before do
         | 
| 642 | 
            -
                @client_credential_key =  | 
| 643 | 
            -
                @token_credential_key =  | 
| 644 | 
            -
                @signature_method =  | 
| 671 | 
            +
                @client_credential_key = "dpf43f3p2l4k3l03"
         | 
| 672 | 
            +
                @token_credential_key = "nnch734d00sl2jdk"
         | 
| 673 | 
            +
                @signature_method = "HMAC-SHA1"
         | 
| 645 674 | 
             
                @unsigned_parameters =
         | 
| 646 675 | 
             
                  Signet::OAuth1.unsigned_resource_parameters(
         | 
| 647 | 
            -
                    : | 
| 648 | 
            -
                    : | 
| 649 | 
            -
                    : | 
| 650 | 
            -
                  ). | 
| 676 | 
            +
                    client_credential_key: @client_credential_key,
         | 
| 677 | 
            +
                    token_credential_key:  @token_credential_key,
         | 
| 678 | 
            +
                    signature_method:      @signature_method
         | 
| 679 | 
            +
                  ).each_with_object({}) { |(k, v), h| h[k] = v; }
         | 
| 651 680 | 
             
              end
         | 
| 652 681 |  | 
| 653 | 
            -
              it  | 
| 682 | 
            +
              it "should raise an error if the client credential key is missing" do
         | 
| 654 683 | 
             
                expect(lambda do
         | 
| 655 684 | 
             
                  Signet::OAuth1.unsigned_resource_parameters(
         | 
| 656 | 
            -
                    : | 
| 657 | 
            -
                    : | 
| 658 | 
            -
                    : | 
| 685 | 
            +
                    client_credential_key: nil,
         | 
| 686 | 
            +
                    token_credential_key:  @token_credential_key,
         | 
| 687 | 
            +
                    signature_method:      @signature_method
         | 
| 659 688 | 
             
                  )
         | 
| 660 689 | 
             
                end).to raise_error(ArgumentError)
         | 
| 661 690 | 
             
              end
         | 
| 662 691 |  | 
| 663 | 
            -
              it  | 
| 692 | 
            +
              it "should raise an error if the token credential key is missing" do
         | 
| 664 693 | 
             
                expect(lambda do
         | 
| 665 694 | 
             
                  Signet::OAuth1.unsigned_resource_parameters(
         | 
| 666 | 
            -
                    : | 
| 667 | 
            -
                    : | 
| 668 | 
            -
                    : | 
| 695 | 
            +
                    client_credential_key: @client_credential_key,
         | 
| 696 | 
            +
                    token_credential_key:  nil,
         | 
| 697 | 
            +
                    signature_method:      @signature_method
         | 
| 669 698 | 
             
                  )
         | 
| 670 699 | 
             
                end).to raise_error(ArgumentError)
         | 
| 671 700 | 
             
              end
         | 
| 672 701 |  | 
| 673 | 
            -
              it  | 
| 674 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 675 | 
            -
                expect(@unsigned_parameters[ | 
| 702 | 
            +
              it "should have the correct client credential key" do
         | 
| 703 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_consumer_key")
         | 
| 704 | 
            +
                expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
         | 
| 676 705 | 
             
              end
         | 
| 677 706 |  | 
| 678 | 
            -
              it  | 
| 679 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 680 | 
            -
                expect(@unsigned_parameters[ | 
| 707 | 
            +
              it "should have the correct token credentials key" do
         | 
| 708 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_token")
         | 
| 709 | 
            +
                expect(@unsigned_parameters["oauth_token"]).to eq @token_credential_key
         | 
| 681 710 | 
             
              end
         | 
| 682 711 |  | 
| 683 | 
            -
              it  | 
| 684 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 685 | 
            -
                expect(@unsigned_parameters[ | 
| 712 | 
            +
              it "should have the correct signature method" do
         | 
| 713 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_signature_method")
         | 
| 714 | 
            +
                expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
         | 
| 686 715 | 
             
              end
         | 
| 687 716 |  | 
| 688 | 
            -
              it  | 
| 717 | 
            +
              it "should have a valid timestamp" do
         | 
| 689 718 | 
             
                # Verify that we have a timestamp, it's in the correct format and within
         | 
| 690 719 | 
             
                # a reasonable range of the current time.
         | 
| 691 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 692 | 
            -
                expect(@unsigned_parameters[ | 
| 693 | 
            -
                expect(@unsigned_parameters[ | 
| 694 | 
            -
                expect(@unsigned_parameters[ | 
| 720 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_timestamp")
         | 
| 721 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
         | 
| 722 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
         | 
| 723 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
         | 
| 695 724 | 
             
              end
         | 
| 696 725 |  | 
| 697 | 
            -
              it  | 
| 726 | 
            +
              it "should have a valid nonce" do
         | 
| 698 727 | 
             
                # Verify that we have a nonce and that it has sufficient length for
         | 
| 699 728 | 
             
                # uniqueness.
         | 
| 700 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 701 | 
            -
                expect(@unsigned_parameters[ | 
| 729 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_nonce")
         | 
| 730 | 
            +
                expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
         | 
| 702 731 | 
             
              end
         | 
| 703 732 |  | 
| 704 | 
            -
              it  | 
| 705 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 706 | 
            -
                expect(@unsigned_parameters[ | 
| 733 | 
            +
              it "should have the correct OAuth version" do
         | 
| 734 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_version")
         | 
| 735 | 
            +
                expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
         | 
| 707 736 | 
             
              end
         | 
| 708 737 | 
             
            end
         | 
| 709 738 |  | 
| 710 | 
            -
            describe Signet::OAuth1,  | 
| 711 | 
            -
             | 
| 739 | 
            +
            describe Signet::OAuth1, "when generating token credential parameters " \
         | 
| 740 | 
            +
                                     "with Signet::OAuth1::Credential objects" do
         | 
| 712 741 | 
             
              before do
         | 
| 713 742 | 
             
                @client_credential = Signet::OAuth1::Credential.new(
         | 
| 714 | 
            -
                   | 
| 743 | 
            +
                  "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
         | 
| 715 744 | 
             
                )
         | 
| 716 745 | 
             
                @temporary_credential = Signet::OAuth1::Credential.new(
         | 
| 717 | 
            -
                   | 
| 746 | 
            +
                  "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
         | 
| 718 747 | 
             
                )
         | 
| 719 | 
            -
                @verifier =  | 
| 720 | 
            -
                @signature_method =  | 
| 748 | 
            +
                @verifier = "473f82d3"
         | 
| 749 | 
            +
                @signature_method = "HMAC-SHA1"
         | 
| 721 750 | 
             
                @unsigned_parameters =
         | 
| 722 751 | 
             
                  Signet::OAuth1.unsigned_token_credential_parameters(
         | 
| 723 | 
            -
                    : | 
| 724 | 
            -
                    : | 
| 725 | 
            -
                    : | 
| 726 | 
            -
                    : | 
| 727 | 
            -
                  ). | 
| 752 | 
            +
                    client_credential:    @client_credential,
         | 
| 753 | 
            +
                    temporary_credential: @temporary_credential,
         | 
| 754 | 
            +
                    signature_method:     @signature_method,
         | 
| 755 | 
            +
                    verifier:             @verifier
         | 
| 756 | 
            +
                  ).each_with_object({}) { |(k, v), h| h[k] = v; }
         | 
| 728 757 | 
             
              end
         | 
| 729 758 |  | 
| 730 | 
            -
              it  | 
| 731 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 732 | 
            -
                expect(@unsigned_parameters[ | 
| 759 | 
            +
              it "should have the correct client credential key" do
         | 
| 760 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_consumer_key")
         | 
| 761 | 
            +
                expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential.key
         | 
| 733 762 | 
             
              end
         | 
| 734 763 |  | 
| 735 | 
            -
              it  | 
| 736 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 737 | 
            -
                expect(@unsigned_parameters[ | 
| 764 | 
            +
              it "should have the correct temporary credentials key" do
         | 
| 765 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_token")
         | 
| 766 | 
            +
                expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential.key
         | 
| 738 767 | 
             
              end
         | 
| 739 768 |  | 
| 740 | 
            -
              it  | 
| 741 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 742 | 
            -
                expect(@unsigned_parameters[ | 
| 769 | 
            +
              it "should have the correct signature method" do
         | 
| 770 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_signature_method")
         | 
| 771 | 
            +
                expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
         | 
| 743 772 | 
             
              end
         | 
| 744 773 |  | 
| 745 | 
            -
              it  | 
| 774 | 
            +
              it "should have a valid timestamp" do
         | 
| 746 775 | 
             
                # Verify that we have a timestamp, it's in the correct format and within
         | 
| 747 776 | 
             
                # a reasonable range of the current time.
         | 
| 748 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 749 | 
            -
                expect(@unsigned_parameters[ | 
| 750 | 
            -
                expect(@unsigned_parameters[ | 
| 751 | 
            -
                expect(@unsigned_parameters[ | 
| 777 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_timestamp")
         | 
| 778 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
         | 
| 779 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
         | 
| 780 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
         | 
| 752 781 | 
             
              end
         | 
| 753 782 |  | 
| 754 | 
            -
              it  | 
| 783 | 
            +
              it "should have a valid nonce" do
         | 
| 755 784 | 
             
                # Verify that we have a nonce and that it has sufficient length for
         | 
| 756 785 | 
             
                # uniqueness.
         | 
| 757 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 758 | 
            -
                expect(@unsigned_parameters[ | 
| 786 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_nonce")
         | 
| 787 | 
            +
                expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
         | 
| 759 788 | 
             
              end
         | 
| 760 789 |  | 
| 761 | 
            -
              it  | 
| 762 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 763 | 
            -
                expect(@unsigned_parameters[ | 
| 790 | 
            +
              it "should have the correct OAuth version" do
         | 
| 791 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_version")
         | 
| 792 | 
            +
                expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
         | 
| 764 793 | 
             
              end
         | 
| 765 794 | 
             
            end
         | 
| 766 795 |  | 
| 767 | 
            -
            describe Signet::OAuth1,  | 
| 768 | 
            -
             | 
| 796 | 
            +
            describe Signet::OAuth1, "when generating token credential parameters " \
         | 
| 797 | 
            +
                                     "with a Signet::OAuth1::Client object" do
         | 
| 769 798 | 
             
              before do
         | 
| 770 799 | 
             
                @client = Signet::OAuth1::Client.new
         | 
| 771 800 | 
             
                @client.client_credential = Signet::OAuth1::Credential.new(
         | 
| 772 | 
            -
                   | 
| 801 | 
            +
                  "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
         | 
| 773 802 | 
             
                )
         | 
| 774 803 | 
             
                @client.temporary_credential = Signet::OAuth1::Credential.new(
         | 
| 775 | 
            -
                   | 
| 804 | 
            +
                  "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
         | 
| 776 805 | 
             
                )
         | 
| 777 | 
            -
                @verifier =  | 
| 778 | 
            -
                @signature_method =  | 
| 806 | 
            +
                @verifier = "473f82d3"
         | 
| 807 | 
            +
                @signature_method = "HMAC-SHA1"
         | 
| 779 808 | 
             
                @unsigned_parameters =
         | 
| 780 809 | 
             
                  Signet::OAuth1.unsigned_token_credential_parameters(
         | 
| 781 | 
            -
                    : | 
| 782 | 
            -
                    : | 
| 783 | 
            -
                    : | 
| 784 | 
            -
                  ). | 
| 810 | 
            +
                    client:           @client,
         | 
| 811 | 
            +
                    signature_method: @signature_method,
         | 
| 812 | 
            +
                    verifier:         @verifier
         | 
| 813 | 
            +
                  ).each_with_object({}) { |(k, v), h| h[k] = v; }
         | 
| 785 814 | 
             
              end
         | 
| 786 815 |  | 
| 787 | 
            -
              it  | 
| 788 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 789 | 
            -
                expect(@unsigned_parameters[ | 
| 816 | 
            +
              it "should have the correct client credential key" do
         | 
| 817 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_consumer_key")
         | 
| 818 | 
            +
                expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client.client_credential_key
         | 
| 790 819 | 
             
              end
         | 
| 791 820 |  | 
| 792 | 
            -
              it  | 
| 793 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 794 | 
            -
                expect(@unsigned_parameters[ | 
| 821 | 
            +
              it "should have the correct temporary credentials key" do
         | 
| 822 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_token")
         | 
| 823 | 
            +
                expect(@unsigned_parameters["oauth_token"]).to eq @client.temporary_credential_key
         | 
| 795 824 | 
             
              end
         | 
| 796 825 |  | 
| 797 | 
            -
              it  | 
| 798 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 799 | 
            -
                expect(@unsigned_parameters[ | 
| 826 | 
            +
              it "should have the correct signature method" do
         | 
| 827 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_signature_method")
         | 
| 828 | 
            +
                expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
         | 
| 800 829 | 
             
              end
         | 
| 801 830 |  | 
| 802 | 
            -
              it  | 
| 831 | 
            +
              it "should have a valid timestamp" do
         | 
| 803 832 | 
             
                # Verify that we have a timestamp, it's in the correct format and within
         | 
| 804 833 | 
             
                # a reasonable range of the current time.
         | 
| 805 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 806 | 
            -
                expect(@unsigned_parameters[ | 
| 807 | 
            -
                expect(@unsigned_parameters[ | 
| 808 | 
            -
                expect(@unsigned_parameters[ | 
| 834 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_timestamp")
         | 
| 835 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
         | 
| 836 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
         | 
| 837 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
         | 
| 809 838 | 
             
              end
         | 
| 810 839 |  | 
| 811 | 
            -
              it  | 
| 840 | 
            +
              it "should have a valid nonce" do
         | 
| 812 841 | 
             
                # Verify that we have a nonce and that it has sufficient length for
         | 
| 813 842 | 
             
                # uniqueness.
         | 
| 814 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 815 | 
            -
                expect(@unsigned_parameters[ | 
| 843 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_nonce")
         | 
| 844 | 
            +
                expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
         | 
| 816 845 | 
             
              end
         | 
| 817 846 |  | 
| 818 | 
            -
              it  | 
| 819 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 820 | 
            -
                expect(@unsigned_parameters[ | 
| 847 | 
            +
              it "should have the correct OAuth version" do
         | 
| 848 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_version")
         | 
| 849 | 
            +
                expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
         | 
| 821 850 | 
             
              end
         | 
| 822 851 | 
             
            end
         | 
| 823 852 |  | 
| 824 | 
            -
            describe Signet::OAuth1,  | 
| 825 | 
            -
             | 
| 853 | 
            +
            describe Signet::OAuth1, "when generating token credential parameters " \
         | 
| 854 | 
            +
                                     "with Signet::OAuth1::Credential objects" do
         | 
| 826 855 | 
             
              before do
         | 
| 827 856 | 
             
                @client_credential = Signet::OAuth1::Credential.new(
         | 
| 828 | 
            -
                   | 
| 857 | 
            +
                  "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
         | 
| 829 858 | 
             
                )
         | 
| 830 859 | 
             
                @temporary_credential = Signet::OAuth1::Credential.new(
         | 
| 831 | 
            -
                   | 
| 860 | 
            +
                  "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
         | 
| 832 861 | 
             
                )
         | 
| 833 | 
            -
                @verifier =  | 
| 834 | 
            -
                @signature_method =  | 
| 862 | 
            +
                @verifier = "473f82d3"
         | 
| 863 | 
            +
                @signature_method = "HMAC-SHA1"
         | 
| 835 864 | 
             
                @unsigned_parameters =
         | 
| 836 865 | 
             
                  Signet::OAuth1.unsigned_token_credential_parameters(
         | 
| 837 | 
            -
                    : | 
| 838 | 
            -
                    : | 
| 839 | 
            -
                    : | 
| 840 | 
            -
                    : | 
| 841 | 
            -
                  ). | 
| 866 | 
            +
                    client_credential:    @client_credential,
         | 
| 867 | 
            +
                    temporary_credential: @temporary_credential,
         | 
| 868 | 
            +
                    signature_method:     @signature_method,
         | 
| 869 | 
            +
                    verifier:             @verifier
         | 
| 870 | 
            +
                  ).each_with_object({}) { |(k, v), h| h[k] = v; }
         | 
| 842 871 | 
             
              end
         | 
| 843 872 |  | 
| 844 | 
            -
              it  | 
| 845 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 846 | 
            -
                expect(@unsigned_parameters[ | 
| 873 | 
            +
              it "should have the correct client credential key" do
         | 
| 874 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_consumer_key")
         | 
| 875 | 
            +
                expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential.key
         | 
| 847 876 | 
             
              end
         | 
| 848 877 |  | 
| 849 | 
            -
              it  | 
| 850 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 851 | 
            -
                expect(@unsigned_parameters[ | 
| 878 | 
            +
              it "should have the correct temporary credentials key" do
         | 
| 879 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_token")
         | 
| 880 | 
            +
                expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential.key
         | 
| 852 881 | 
             
              end
         | 
| 853 882 |  | 
| 854 | 
            -
              it  | 
| 855 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 856 | 
            -
                expect(@unsigned_parameters[ | 
| 883 | 
            +
              it "should have the correct signature method" do
         | 
| 884 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_signature_method")
         | 
| 885 | 
            +
                expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
         | 
| 857 886 | 
             
              end
         | 
| 858 887 |  | 
| 859 | 
            -
              it  | 
| 888 | 
            +
              it "should have a valid timestamp" do
         | 
| 860 889 | 
             
                # Verify that we have a timestamp, it's in the correct format and within
         | 
| 861 890 | 
             
                # a reasonable range of the current time.
         | 
| 862 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 863 | 
            -
                expect(@unsigned_parameters[ | 
| 864 | 
            -
                expect(@unsigned_parameters[ | 
| 865 | 
            -
                expect(@unsigned_parameters[ | 
| 891 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_timestamp")
         | 
| 892 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
         | 
| 893 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
         | 
| 894 | 
            +
                expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
         | 
| 866 895 | 
             
              end
         | 
| 867 896 |  | 
| 868 | 
            -
              it  | 
| 897 | 
            +
              it "should have a valid nonce" do
         | 
| 869 898 | 
             
                # Verify that we have a nonce and that it has sufficient length for
         | 
| 870 899 | 
             
                # uniqueness.
         | 
| 871 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 872 | 
            -
                expect(@unsigned_parameters[ | 
| 900 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_nonce")
         | 
| 901 | 
            +
                expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
         | 
| 873 902 | 
             
              end
         | 
| 874 903 |  | 
| 875 | 
            -
              it  | 
| 876 | 
            -
                expect(@unsigned_parameters).to have_key( | 
| 877 | 
            -
                expect(@unsigned_parameters[ | 
| 904 | 
            +
              it "should have the correct OAuth version" do
         | 
| 905 | 
            +
                expect(@unsigned_parameters).to have_key("oauth_version")
         | 
| 906 | 
            +
                expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
         | 
| 878 907 | 
             
              end
         | 
| 879 908 | 
             
            end
         | 
| 880 909 |  | 
| 881 | 
            -
            describe Signet::OAuth1,  | 
| 882 | 
            -
              it  | 
| 910 | 
            +
            describe Signet::OAuth1, "extracting credential keys from options" do
         | 
| 911 | 
            +
              it "should raise an error for bogus credentials" do
         | 
| 883 912 | 
             
                expect(lambda do
         | 
| 884 913 | 
             
                  Signet::OAuth1.extract_credential_key_option(
         | 
| 885 | 
            -
                    :client,  | 
| 914 | 
            +
                    :client, client_credential_key: true
         | 
| 886 915 | 
             
                  )
         | 
| 887 916 | 
             
                end).to raise_error(TypeError)
         | 
| 888 917 | 
             
              end
         | 
| 889 918 |  | 
| 890 | 
            -
              it  | 
| 919 | 
            +
              it "should raise an error for bogus credentials" do
         | 
| 891 920 | 
             
                expect(lambda do
         | 
| 892 921 | 
             
                  Signet::OAuth1.extract_credential_key_option(
         | 
| 893 | 
            -
                    :client,  | 
| 922 | 
            +
                    :client, client_credential: 42
         | 
| 894 923 | 
             
                  )
         | 
| 895 924 | 
             
                end).to raise_error(TypeError)
         | 
| 896 925 | 
             
              end
         | 
| 897 926 |  | 
| 898 | 
            -
              it  | 
| 927 | 
            +
              it "should raise an error for bogus credentials" do
         | 
| 899 928 | 
             
                expect(lambda do
         | 
| 900 929 | 
             
                  Signet::OAuth1.extract_credential_key_option(
         | 
| 901 | 
            -
                    :client,  | 
| 930 | 
            +
                    :client, client: 42
         | 
| 902 931 | 
             
                  )
         | 
| 903 932 | 
             
                end).to raise_error(TypeError)
         | 
| 904 933 | 
             
              end
         | 
| 905 934 |  | 
| 906 | 
            -
              it  | 
| 935 | 
            +
              it "should return nil for missing credential key" do
         | 
| 907 936 | 
             
                expect(Signet::OAuth1.extract_credential_key_option(:client, {})).to eq nil
         | 
| 908 937 | 
             
              end
         | 
| 909 938 |  | 
| 910 | 
            -
              it  | 
| 939 | 
            +
              it "should find the correct credential key" do
         | 
| 911 940 | 
             
                expect(Signet::OAuth1.extract_credential_key_option(
         | 
| 912 | 
            -
             | 
| 913 | 
            -
             | 
| 941 | 
            +
                         :client, client_credential_key: "dpf43f3p2l4k3l03"
         | 
| 942 | 
            +
                       )).to eq "dpf43f3p2l4k3l03"
         | 
| 914 943 | 
             
              end
         | 
| 915 944 |  | 
| 916 | 
            -
              it  | 
| 945 | 
            +
              it "should find the correct credential key" do
         | 
| 917 946 | 
             
                expect(Signet::OAuth1.extract_credential_key_option(
         | 
| 918 | 
            -
             | 
| 919 | 
            -
             | 
| 920 | 
            -
             | 
| 921 | 
            -
             | 
| 947 | 
            +
                         :client, client_credential: Signet::OAuth1::Credential.new(
         | 
| 948 | 
            +
                           "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
         | 
| 949 | 
            +
                         )
         | 
| 950 | 
            +
                       )).to eq "dpf43f3p2l4k3l03"
         | 
| 922 951 | 
             
              end
         | 
| 923 952 |  | 
| 924 | 
            -
              it  | 
| 953 | 
            +
              it "should find the correct credential key" do
         | 
| 925 954 | 
             
                client = Signet::OAuth1::Client.new
         | 
| 926 955 | 
             
                client.client_credential = Signet::OAuth1::Credential.new(
         | 
| 927 | 
            -
                   | 
| 956 | 
            +
                  "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
         | 
| 928 957 | 
             
                )
         | 
| 929 958 | 
             
                expect(Signet::OAuth1.extract_credential_key_option(
         | 
| 930 | 
            -
             | 
| 931 | 
            -
             | 
| 959 | 
            +
                         :client, client: client
         | 
| 960 | 
            +
                       )).to eq "dpf43f3p2l4k3l03"
         | 
| 932 961 | 
             
              end
         | 
| 933 962 |  | 
| 934 | 
            -
              it  | 
| 963 | 
            +
              it "should find the correct credential key" do
         | 
| 935 964 | 
             
                client = Signet::OAuth1::Client.new
         | 
| 936 965 | 
             
                client.temporary_credential = Signet::OAuth1::Credential.new(
         | 
| 937 | 
            -
                   | 
| 966 | 
            +
                  "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
         | 
| 938 967 | 
             
                )
         | 
| 939 968 | 
             
                expect(Signet::OAuth1.extract_credential_key_option(
         | 
| 940 | 
            -
             | 
| 941 | 
            -
             | 
| 969 | 
            +
                         :temporary, client: client
         | 
| 970 | 
            +
                       )).to eq "hh5s93j4hdidpola"
         | 
| 942 971 | 
             
              end
         | 
| 943 972 | 
             
            end
         | 
| 944 973 |  | 
| 945 | 
            -
            describe Signet::OAuth1,  | 
| 946 | 
            -
              it  | 
| 974 | 
            +
            describe Signet::OAuth1, "extracting credential secrets from options" do
         | 
| 975 | 
            +
              it "should raise an error for bogus credentials" do
         | 
| 947 976 | 
             
                expect(lambda do
         | 
| 948 977 | 
             
                  Signet::OAuth1.extract_credential_secret_option(
         | 
| 949 | 
            -
                    :client,  | 
| 978 | 
            +
                    :client, client_credential_secret: true
         | 
| 950 979 | 
             
                  )
         | 
| 951 980 | 
             
                end).to raise_error(TypeError)
         | 
| 952 981 | 
             
              end
         | 
| 953 982 |  | 
| 954 | 
            -
              it  | 
| 983 | 
            +
              it "should raise an error for bogus credentials" do
         | 
| 955 984 | 
             
                expect(lambda do
         | 
| 956 985 | 
             
                  Signet::OAuth1.extract_credential_secret_option(
         | 
| 957 | 
            -
                    :client,  | 
| 986 | 
            +
                    :client, client_credential: 42
         | 
| 958 987 | 
             
                  )
         | 
| 959 988 | 
             
                end).to raise_error(TypeError)
         | 
| 960 989 | 
             
              end
         | 
| 961 990 |  | 
| 962 | 
            -
              it  | 
| 991 | 
            +
              it "should raise an error for bogus credentials" do
         | 
| 963 992 | 
             
                expect(lambda do
         | 
| 964 993 | 
             
                  Signet::OAuth1.extract_credential_secret_option(
         | 
| 965 | 
            -
                    :client,  | 
| 994 | 
            +
                    :client, client: 42
         | 
| 966 995 | 
             
                  )
         | 
| 967 996 | 
             
                end).to raise_error(TypeError)
         | 
| 968 997 | 
             
              end
         | 
| 969 998 |  | 
| 970 | 
            -
              it  | 
| 999 | 
            +
              it "should raise an error for missing credential secret" do
         | 
| 971 1000 | 
             
                expect(Signet::OAuth1.extract_credential_secret_option(:client, {})).to eq nil
         | 
| 972 1001 | 
             
              end
         | 
| 973 1002 |  | 
| 974 | 
            -
              it  | 
| 1003 | 
            +
              it "should find the correct credential secret" do
         | 
| 975 1004 | 
             
                expect(Signet::OAuth1.extract_credential_secret_option(
         | 
| 976 | 
            -
             | 
| 977 | 
            -
             | 
| 1005 | 
            +
                         :client, client_credential_secret: "kd94hf93k423kf44"
         | 
| 1006 | 
            +
                       )).to eq "kd94hf93k423kf44"
         | 
| 978 1007 | 
             
              end
         | 
| 979 1008 |  | 
| 980 | 
            -
              it  | 
| 1009 | 
            +
              it "should find the correct credential secret" do
         | 
| 981 1010 | 
             
                expect(Signet::OAuth1.extract_credential_secret_option(
         | 
| 982 | 
            -
             | 
| 983 | 
            -
             | 
| 984 | 
            -
             | 
| 985 | 
            -
             | 
| 1011 | 
            +
                         :client, client_credential: Signet::OAuth1::Credential.new(
         | 
| 1012 | 
            +
                           "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
         | 
| 1013 | 
            +
                         )
         | 
| 1014 | 
            +
                       )).to eq "kd94hf93k423kf44"
         | 
| 986 1015 | 
             
              end
         | 
| 987 1016 |  | 
| 988 | 
            -
              it  | 
| 1017 | 
            +
              it "should find the correct credential secret" do
         | 
| 989 1018 | 
             
                client = Signet::OAuth1::Client.new
         | 
| 990 1019 | 
             
                client.client_credential = Signet::OAuth1::Credential.new(
         | 
| 991 | 
            -
                   | 
| 1020 | 
            +
                  "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
         | 
| 992 1021 | 
             
                )
         | 
| 993 1022 | 
             
                expect(Signet::OAuth1.extract_credential_secret_option(
         | 
| 994 | 
            -
             | 
| 995 | 
            -
             | 
| 1023 | 
            +
                         :client, client: client
         | 
| 1024 | 
            +
                       )).to eq "kd94hf93k423kf44"
         | 
| 996 1025 | 
             
              end
         | 
| 997 1026 |  | 
| 998 | 
            -
              it  | 
| 1027 | 
            +
              it "should find the correct credential secret" do
         | 
| 999 1028 | 
             
                client = Signet::OAuth1::Client.new
         | 
| 1000 1029 | 
             
                client.temporary_credential = Signet::OAuth1::Credential.new(
         | 
| 1001 | 
            -
                   | 
| 1030 | 
            +
                  "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
         | 
| 1002 1031 | 
             
                )
         | 
| 1003 1032 | 
             
                expect(Signet::OAuth1.extract_credential_secret_option(
         | 
| 1004 | 
            -
             | 
| 1005 | 
            -
             | 
| 1033 | 
            +
                         :temporary, client: client
         | 
| 1034 | 
            +
                       )).to eq "hdhd0244k9j7ao03"
         | 
| 1006 1035 | 
             
              end
         | 
| 1007 1036 | 
             
            end
         |