vigetlabs-garb 0.2.1 → 0.2.2
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.
| @@ -26,12 +26,19 @@ module Garb | |
| 26 26 | 
             
                def send_request      
         | 
| 27 27 | 
             
                  http = Net::HTTP.new(uri.host, uri.port)
         | 
| 28 28 | 
             
                  http.use_ssl = true
         | 
| 29 | 
            -
                  http.verify_mode = OpenSSL::SSL:: | 
| 29 | 
            +
                  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
         | 
| 30 | 
            +
                  http.cert_store = cert_store
         | 
| 30 31 | 
             
                  http.request(build_request) do |response|
         | 
| 31 32 | 
             
                    raise AuthError unless response.is_a?(Net::HTTPOK)
         | 
| 32 33 | 
             
                  end
         | 
| 33 34 | 
             
                end
         | 
| 34 | 
            -
             | 
| 35 | 
            +
             | 
| 36 | 
            +
                def cert_store
         | 
| 37 | 
            +
                  store = OpenSSL::X509::Store.new
         | 
| 38 | 
            +
                  store.set_default_paths
         | 
| 39 | 
            +
                  store
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 35 42 | 
             
                def build_request
         | 
| 36 43 | 
             
                  post = Net::HTTP::Post.new(uri.path)
         | 
| 37 44 | 
             
                  post.set_form_data(parameters)
         | 
    
        data/lib/garb/version.rb
    CHANGED
    
    
| @@ -20,38 +20,46 @@ module Garb | |
| 20 20 | 
             
                    request = AuthenticationRequest.new('user@example.com', 'fuzzybunnies')
         | 
| 21 21 | 
             
                    assert_equal expected, request.parameters
         | 
| 22 22 | 
             
                  end
         | 
| 23 | 
            -
             | 
| 23 | 
            +
             | 
| 24 24 | 
             
                  should "have a URI" do
         | 
| 25 25 | 
             
                    assert_equal URI.parse('https://www.google.com/accounts/ClientLogin'), @request.uri
         | 
| 26 26 | 
             
                  end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                  
         | 
| 27 | 
            +
             | 
| 29 28 | 
             
                  should "be able to send a request to the GAAPI service" do        
         | 
| 30 29 | 
             
                    @request.expects(:build_request).returns('post')
         | 
| 30 | 
            +
                    @request.stubs(:cert_store).returns('cert_store')
         | 
| 31 | 
            +
             | 
| 31 32 | 
             
                    response = mock {|m| m.expects(:is_a?).with(Net::HTTPOK).returns(true) }
         | 
| 32 | 
            -
             | 
| 33 | 
            +
             | 
| 33 34 | 
             
                    http = mock do |m|
         | 
| 34 35 | 
             
                      m.expects(:use_ssl=).with(true)
         | 
| 35 | 
            -
                      m.expects(:verify_mode=).with(OpenSSL::SSL:: | 
| 36 | 
            +
                      m.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
         | 
| 37 | 
            +
                      m.expects(:cert_store=).with('cert_store')
         | 
| 36 38 | 
             
                      m.expects(:request).with('post').yields(response)
         | 
| 37 39 | 
             
                    end
         | 
| 38 40 |  | 
| 39 41 | 
             
                    Net::HTTP.expects(:new).with('www.google.com', 443).returns(http)
         | 
| 40 | 
            -
             | 
| 42 | 
            +
             | 
| 41 43 | 
             
                    @request.send_request
         | 
| 42 44 | 
             
                  end
         | 
| 43 45 |  | 
| 44 46 | 
             
                  should "be able to build a request for the GAAPI service" do
         | 
| 45 47 | 
             
                    params = "param"
         | 
| 46 48 | 
             
                    @request.expects(:parameters).with().returns(params)
         | 
| 47 | 
            -
             | 
| 49 | 
            +
             | 
| 48 50 | 
             
                    post = mock
         | 
| 49 51 | 
             
                    post.expects(:set_form_data).with(params)
         | 
| 50 | 
            -
             | 
| 52 | 
            +
             | 
| 51 53 | 
             
                    Net::HTTP::Post.expects(:new).with('/accounts/ClientLogin').returns(post)
         | 
| 52 | 
            -
             | 
| 54 | 
            +
             | 
| 53 55 | 
             
                    @request.build_request
         | 
| 54 56 | 
             
                  end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  should "have a cert store" do
         | 
| 59 | 
            +
                    cert_store = mock(:set_default_paths)
         | 
| 60 | 
            +
                    OpenSSL::X509::Store.expects(:new).returns(cert_store)
         | 
| 61 | 
            +
                    assert_equal cert_store, @request.cert_store
         | 
| 62 | 
            +
                  end
         | 
| 55 63 |  | 
| 56 64 | 
             
                  should "be able to retrieve an auth_token from the body" do
         | 
| 57 65 | 
             
                    response_data =
         | 
| @@ -66,6 +74,7 @@ module Garb | |
| 66 74 |  | 
| 67 75 | 
             
                  should "raise an exception when requesting an auth_token when the authorization fails" do
         | 
| 68 76 | 
             
                    @request.stubs(:build_request)
         | 
| 77 | 
            +
                    @request.stubs(:cert_store)
         | 
| 69 78 | 
             
                    response = mock do |m|
         | 
| 70 79 | 
             
                      m.expects(:is_a?).with(Net::HTTPOK).returns(false)
         | 
| 71 80 | 
             
                    end
         | 
| @@ -73,6 +82,7 @@ module Garb | |
| 73 82 | 
             
                    http = stub do |s|
         | 
| 74 83 | 
             
                      s.stubs(:use_ssl=)
         | 
| 75 84 | 
             
                      s.stubs(:verify_mode=)
         | 
| 85 | 
            +
                      s.stubs(:cert_store=)
         | 
| 76 86 | 
             
                      s.stubs(:request).yields(response)
         | 
| 77 87 | 
             
                    end
         | 
| 78 88 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: vigetlabs-garb
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Tony Pitale
         | 
| @@ -11,7 +11,7 @@ autorequire: | |
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 13 |  | 
| 14 | 
            -
            date: 2009- | 
| 14 | 
            +
            date: 2009-05-11 00:00:00 -07:00
         | 
| 15 15 | 
             
            default_executable: 
         | 
| 16 16 | 
             
            dependencies: 
         | 
| 17 17 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -94,7 +94,7 @@ requirements: [] | |
| 94 94 | 
             
            rubyforge_project: 
         | 
| 95 95 | 
             
            rubygems_version: 1.2.0
         | 
| 96 96 | 
             
            signing_key: 
         | 
| 97 | 
            -
            specification_version:  | 
| 97 | 
            +
            specification_version: 2
         | 
| 98 98 | 
             
            summary: Google Analytics API Ruby Wrapper
         | 
| 99 99 | 
             
            test_files: 
         | 
| 100 100 | 
             
            - test/fixtures
         |