Sha256: 3d7e727658a4cadedba84b982a5c0a15d849c953a8f5da25e7e4f4a3bffe0e6c
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
require File.expand_path('../../spec_helper', __FILE__) require 'github_client' describe GithubClient do subject do GithubClient.new('https://github.com', '2945e6425da3d5d17ffc', '0a8f686f2835a70a79dbcece2ec63bc5079f40a8') end describe "#webserver_authorization_url" do it "returns the authorization url" do auth_url = subject.webserver_authorization_url( :scope => 'repo, user', :state => '1kd84ur7q0c9rbtnd', :redirect_uri => 'https://localhost/callback' ) parsed_url = Addressable::URI.parse(auth_url) expect(parsed_url.path).to eq '/login/oauth/authorize' expect(parsed_url.query_values).to eq({ "client_id" => '2945e6425da3d5d17ffc', "redirect_uri" => 'https://localhost/callback', "response_type" => 'code', "scope" => 'repo, user', "state" => '1kd84ur7q0c9rbtnd' }) expect(parsed_url.scheme).to eq 'https' expect(parsed_url.host).to eq 'github.com' end end describe "#exchange_auth_code_for_token" do it "makes a request to google oauth2 server" do stub_request(:post, "https://github.com/login/oauth/access_token").with( :body => { :grant_type => 'authorization_code', :code => 'IZuJJVnL49Cc', :redirect_uri => 'https://localhost/callback', :client_id => '2945e6425da3d5d17ffc', :client_secret => '0a8f686f2835a70a79dbcece2ec63bc5079f40a8' }, :headers => { 'Accept' => "application/json", 'User-Agent' => "OAuth2 Ruby Gem #{OAuth2::Version}", 'Content-Type' => "application/x-www-form-urlencoded" } ) response = subject.exchange_auth_code_for_token( :params => { :code => 'IZuJJVnL49Cc', :redirect_uri => 'https://localhost/callback' } ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oauth2-client-1.1.3 | spec/examples/github_client_spec.rb |