Sha256: a47d35f68b57b08ea4afc77965ad505e49e95838383996717a6506df366d3c06

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'
require 'uri'
require 'doorkeeper/oauth/helpers/uri_checker'

module Doorkeeper::OAuth::Helpers
  describe URIChecker do
    describe ".valid?" do
      it "is valid for valid uris" do
        uri = "http://app.co"
        URIChecker.valid?(uri).should be_true
      end

      it "is valid if include path param" do
        uri = "http://app.co/path"
        URIChecker.valid?(uri).should be_true
      end

      it "is valid if include query param" do
        uri = "http://app.co/?query=1"
        URIChecker.valid?(uri).should be_true
      end

      it "is invalid if uri includes fragment" do
        uri = "http://app.co/test#fragment"
        URIChecker.valid?(uri).should be_false
      end

      it "is invalid if scheme is missing" do
        uri = "app.co"
        URIChecker.valid?(uri).should be_false
      end

      it "is invalid if is a relative uri" do
        uri = "/abc/123"
        URIChecker.valid?(uri).should be_false
      end

      it "is invalid if is not a url" do
        uri = "http://"
        URIChecker.valid?(uri).should be_false
      end
    end

    describe ".matches?" do
      it "is true if both url matches" do
        uri = client_uri = 'http://app.co/aaa'
        URIChecker.matches?(uri, client_uri).should be_true
      end

      it "ignores query parameter on comparsion" do
        uri = 'http://app.co/?query=hello'
        client_uri = 'http://app.co'
        URIChecker.matches?(uri, client_uri).should be_true
      end
    end

    describe ".valid_for_authorization?" do
      it "is true if valid and matches" do
        uri = client_uri = 'http://app.co/aaa'
        URIChecker.valid_for_authorization?(uri, client_uri).should be_true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
couchkeeper-0.6.7 spec/lib/oauth/helpers/uri_checker_spec.rb