Sha256: 699cbfe8b53cdbd8b83f55a8948c54fab2a992101a8fd540c2fb9325d02a794c

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

require 'test_helper'

class Docusigner::OauthTest < Test::Unit::TestCase

  should "be able to fetch an OAuth token with username/password/integrator key" do
    stub_request(:post, "https://demo.docusign.net/restapi/v2/oauth2/token.json")
      .with(:body => {"client_id"=>"mykey", "grant_type"=>"password", "password"=>"mypassword", "scope"=>"api", "username"=>"myname"})
      .to_return(:body => {
        "access_token" => "myoauthtoken",
        "scope" => "api",
        "token_type" => "bearer"
      }.to_json)
    token = Docusigner::Oauth2.token("myname", "mypassword", "mykey")
    assert_requested(:post, "https://demo.docusign.net/restapi/v2/oauth2/token.json")
    assert_equal("myoauthtoken", token)
  end

  should "be able to revoke an OAuth token" do
    stub_request(:post, "https://demo.docusign.net/restapi/v2/oauth2/revoke.json")
      .with(:headers => {"Authorization" => "Bearer mytoken"})
      .to_return(:body => "")
    Docusigner::Oauth2.revoke("mytoken")
    assert_requested(:post, "https://demo.docusign.net/restapi/v2/oauth2/revoke.json")
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
docusigner-0.0.9 test/unit/oauth_test.rb
docusigner-0.0.8 test/unit/oauth_test.rb
docusigner-0.0.6 test/unit/oauth_test.rb
docusigner-0.0.5 test/unit/oauth_test.rb
docusigner-0.0.4 test/unit/oauth_test.rb
docusigner-0.0.3 test/unit/oauth_test.rb
docusigner-0.0.2 test/unit/oauth_test.rb
docusigner-0.0.1 test/unit/oauth_test.rb