Sha256: 464473f73fc364dc0361d3549c11fa7ed75399ad6bf55ffbe2d72ea884139bb0

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe SK::SDK::Oauth, "in general" do

  before :each do
    #setup test oAuth-data to work with
    @set = oauth_settings
  end

  it "should create a new instance" do
    lambda{ SK::SDK::Oauth.new(@set)}.should_not raise_error
  end

  it "should get salesking url" do
    a = SK::SDK::Oauth.new(@set)
    a.sub_domain = 'alki'
    a.sk_url.should == "http://alki.horsts-lokal.local"
  end

  it "should get salesking api url" do
    a = SK::SDK::Oauth.new(@set)
    a.sub_domain = 'alki'
    a.sk_api_url.should == "http://alki.horsts-lokal.local/api"
  end

  it "should get auth_dialog url" do
    a = SK::SDK::Oauth.new(@set)
    a.sub_domain = 'alki'
    a.auth_dialog.should include "http://alki.horsts-lokal.local/oauth/authorize?"
    a.auth_dialog.should include @set['id']
    a.auth_dialog.should include CGI::escape @set['redirect_url']
    a.auth_dialog.should include CGI::escape @set['scope']
  end

  it "should get sk_canvas_url" do
    a = SK::SDK::Oauth.new(@set)
    a.sub_domain = 'alki'
    a.sk_canvas_url.should == "http://alki.horsts-lokal.local/app/canvas-page"
  end

  it "has token_url" do
    a = SK::SDK::Oauth.new(@set)
    a.sub_domain = 'alki'
    a.token_url.should == "http://alki.horsts-lokal.local/oauth/token"
  end

  it "has token_params" do
    a = SK::SDK::Oauth.new(@set)
    res = a.token_params('123')
    res[:code].should == '123'
    res[:client_id].should == @set['id']
    res[:grant_type].should == 'authorization_code'
    res[:redirect_uri].should == CGI::escape(@set['redirect_url'])
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sk_sdk-0.4.3 spec/sk_sdk/oauth_spec.rb
sk_sdk-0.4.2 spec/sk_sdk/oauth_spec.rb
sk_sdk-0.4.1 spec/sk_sdk/oauth_spec.rb