Skip to content

Commit

Permalink
Add tests for realm case sensitivity in AuthStore
Browse files Browse the repository at this point in the history
As per RFC 1945 (section 11) and RFC 2617, the realm value is case sensitive.
This commit adds tests for realm case sensitivity in
Mechanize::HTTP::AuthStore.
  • Loading branch information
chris-reeves committed Jan 5, 2016
1 parent 870015d commit dec1461
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/test_mechanize_http_auth_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ def test_add_auth_realm
assert_equal expected, @store.auth_accounts
end

def test_add_auth_realm_case
@store.add_auth @uri, 'user1', 'pass', 'realm'
@store.add_auth @uri, 'user2', 'pass', 'Realm'

expected = {
@uri => {
'realm' => ['user1', 'pass', nil],
'Realm' => ['user2', 'pass', nil],
}
}

assert_equal expected, @store.auth_accounts
end

def test_add_auth_string
@store.add_auth "#{@uri}/path", 'user', 'pass'

Expand Down Expand Up @@ -143,6 +157,14 @@ def test_credentials_for_realm
assert_equal ['user1', 'pass', nil], @store.credentials_for(@uri, 'other')
end

def test_credentials_for_realm_case
@store.add_auth @uri, 'user1', 'pass', 'realm'
@store.add_auth @uri, 'user2', 'pass', 'Realm'

assert_equal ['user1', 'pass', nil], @store.credentials_for(@uri, 'realm')
assert_equal ['user2', 'pass', nil], @store.credentials_for(@uri, 'Realm')
end

def test_credentials_for_path
@store.add_auth @uri, 'user', 'pass', 'realm'

Expand Down Expand Up @@ -183,6 +205,21 @@ def test_remove_auth_realm
assert_equal expected, @store.auth_accounts
end

def test_remove_auth_realm_case
@store.add_auth @uri, 'user1', 'pass', 'realm'
@store.add_auth @uri, 'user2', 'pass', 'Realm'

@store.remove_auth @uri, 'Realm'

expected = {
@uri => {
'realm' => ['user1', 'pass', nil]
}
}

assert_equal expected, @store.auth_accounts
end

def test_remove_auth_string
@store.add_auth @uri, 'user1', 'pass'

Expand Down

0 comments on commit dec1461

Please sign in to comment.