|
| 1 | +require "docusign_esign" |
| 2 | +require "docusign_esign/client/api_client" |
| 3 | + |
| 4 | +RSpec.describe DocuSign_eSign::ApiClient do |
| 5 | + describe "#build_request_url" do |
| 6 | + context "when the oauth option is set" do |
| 7 | + it "replaces unsafe characters with safe characters" do |
| 8 | + client = described_class.new |
| 9 | + client.oauth_base_path = "oauth.com" |
| 10 | + |
| 11 | + url = client.build_request_url("/path^{}%<> #anchor", { oauth: true }) |
| 12 | + |
| 13 | + expect(url).to eq("https://oauth.com/path%5E%7B%7D%25%3C%3E%20#anchor") |
| 14 | + end |
| 15 | + |
| 16 | + it "replaces multiple forward slashes with a single forward slash" do |
| 17 | + client = described_class.new |
| 18 | + client.oauth_base_path = "oauth.com" |
| 19 | + |
| 20 | + url = client.build_request_url("//path", { oauth: true }) |
| 21 | + |
| 22 | + expect(url).to eq("https://oauth.com/path") |
| 23 | + end |
| 24 | + end |
| 25 | + |
| 26 | + context "when the oauth option is not set" do |
| 27 | + it "replaces unsafe characters with safe characters" do |
| 28 | + config = instance_double("Configuration", base_url: "http://domain.com") |
| 29 | + client = described_class.new(config) |
| 30 | + |
| 31 | + url = client.build_request_url("/path^{}%<> #anchor", { oauth: false }) |
| 32 | + |
| 33 | + expect(url).to eq("http://domain.com/path%5E%7B%7D%25%3C%3E%20#anchor") |
| 34 | + end |
| 35 | + |
| 36 | + it "replaces multiple forward slashes with a single forward slash" do |
| 37 | + config = instance_double("Configuration", base_url: "http://domain.com") |
| 38 | + client = described_class.new(config) |
| 39 | + |
| 40 | + url = client.build_request_url("//path", { oauth: false }) |
| 41 | + |
| 42 | + expect(url).to eq("http://domain.com/path") |
| 43 | + end |
| 44 | + end |
| 45 | + end |
| 46 | +end |
0 commit comments