Skip to content

Commit

Permalink
Added tests for Credential Persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
n-studio committed Nov 5, 2012
1 parent ba884f5 commit 0eef70a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions spec/motion/http_spec.rb
Expand Up @@ -103,6 +103,7 @@ def test_http_method(method)

before do
@credentials = { username: 'mneorr', password: '123456xx!@crazy' }
@credential_persistence = 0
@payload = {
user: { name: 'marin', surname: 'usalj' },
twitter: '@mneorr',
Expand All @@ -124,6 +125,7 @@ def test_http_method(method)
files: @files,
payload: @payload,
credentials: @credentials,
credential_persistence: @credential_persistence,
headers: @headers,
cache_policy: @cache_policy,
leftover_option: @leftover_option,
Expand Down Expand Up @@ -316,6 +318,14 @@ def sample_data
new_query.instance_variable_get(:@cache_policy).should.equal NSURLRequestUseProtocolCachePolicy
end

it "should delete :credential_persistence or set NSURLCredentialPersistenceForSession" do
@query.instance_variable_get(:@credential_persistence).should.equal @credential_persistence
@options.should.not.has_key? :credential_persistence

new_query = BubbleWrap::HTTP::Query.new( @localhost_url, :get, {})
new_query.instance_variable_get(:@credential_persistence).should.equal NSURLCredentialPersistenceForSession
end

it "should set the rest of options{} to ivar @options" do
@query.options.size.should.equal 1
@query.options.values[0].should.equal @leftover_option
Expand Down Expand Up @@ -614,8 +624,8 @@ def query_received_data
@challenge.sender.credential.password.should.equal @credentials[:password]
end

it "always uses NSURLCredentialPersistenceForSession" do
@challenge.sender.credential.persistence.should.equal NSURLCredentialPersistenceForSession
it "should use Credential Persistence set in options" do
@challenge.sender.credential.persistence.should.equal @credential_persistence
end

end
Expand Down

0 comments on commit 0eef70a

Please sign in to comment.