-
Notifications
You must be signed in to change notification settings - Fork 965
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make use of RSpec DSL consistent across specs
- Loading branch information
Zachary Herr
committed
Aug 27, 2018
1 parent
30d9036
commit 350d153
Showing
15 changed files
with
46 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) | ||
require 'spec_helper' | ||
|
||
RSpec.describe Net::HTTPHeader::DigestAuthenticator do | ||
def setup_digest(response) | ||
|
@@ -19,33 +19,33 @@ def cookie_header | |
|
||
context 'Net::HTTPHeader#digest_auth' do | ||
let(:headers) { | ||
(Class.new do | ||
(Class.new do | ||
include Net::HTTPHeader | ||
def initialize | ||
@header = {} | ||
@path = '/' | ||
@method = 'GET' | ||
end | ||
end).new | ||
} | ||
} | ||
|
||
let(:response){ | ||
(Class.new do | ||
(Class.new do | ||
include Net::HTTPHeader | ||
def initialize | ||
@header = {} | ||
self['WWW-Authenticate'] = | ||
self['WWW-Authenticate'] = | ||
'Digest realm="[email protected]", qop="auth,auth-int", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"' | ||
end | ||
end).new | ||
} | ||
|
||
it 'should set the authorization header' do | ||
it 'should set the authorization header' do | ||
expect(headers['authorization']).to be_nil | ||
headers.digest_auth('user','pass', response) | ||
expect(headers['authorization']).to_not be_empty | ||
end | ||
end | ||
end | ||
end | ||
|
||
context "with a cookie value in the response header" do | ||
before do | ||
|
@@ -228,18 +228,18 @@ def initialize | |
expect(authorization_header).to include(%(response="#{request_digest}")) | ||
end | ||
end | ||
|
||
context "with algorithm specified" do | ||
before do | ||
@digest = setup_digest({ | ||
'www-authenticate' => 'Digest realm="[email protected]", nonce="NONCE", qop="auth", algorithm=MD5' | ||
}) | ||
end | ||
|
||
it "should recognise algorithm was specified" do | ||
expect( @digest.send :algorithm_present? ).to be(true) | ||
end | ||
|
||
it "should set the algorithm header" do | ||
expect(authorization_header).to include('algorithm="MD5"') | ||
end | ||
|
@@ -251,20 +251,20 @@ def initialize | |
'www-authenticate' => 'Digest realm="[email protected]", nonce="NONCE", qop="auth", algorithm=MD5-sess' | ||
}) | ||
end | ||
|
||
it "should recognise algorithm was specified" do | ||
expect( @digest.send :algorithm_present? ).to be(true) | ||
end | ||
|
||
it "should set the algorithm header" do | ||
expect(authorization_header).to include('algorithm="MD5-sess"') | ||
end | ||
|
||
it "should set response using md5-sess algorithm" do | ||
request_digest = "md5(md5(md5(Mufasa:[email protected]:Circle Of Life):NONCE:md5(deadbeef)):NONCE:00000001:md5(deadbeef):auth:md5(GET:/dir/index.html))" | ||
expect(authorization_header).to include(%(response="#{request_digest}")) | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters