Permalink
Browse files

fix call elli_request:get_header

  • Loading branch information...
1 parent 3ad8ef0 commit ded21f489603924afe999fecf8c04b152ed92979 @martinrehfeld martinrehfeld committed Apr 24, 2012
Showing with 17 additions and 17 deletions.
  1. +1 −1 src/elli_basicauth.erl
  2. +16 −16 test/elli_basicauth_tests.erl
View
@@ -75,7 +75,7 @@ credentials(Req) ->
authorization_header(Req) ->
- elli:get_header(<<"Authorization">>, Req).
+ elli_request:get_header(<<"Authorization">>, Req).
credentials_from_header(AuthorizationHeader) ->
@@ -11,8 +11,8 @@
%%
no_credentials_test() ->
- meck:new(elli),
- meck:expect(elli, get_header,
+ meck:new(elli_request),
+ meck:expect(elli_request, get_header,
fun (<<"Authorization">>, mock_request) ->
undefined
end),
@@ -24,13 +24,13 @@ no_credentials_test() ->
[{<<"WWW-Authenticate">>,
<<"Basic realm=\"Secure Area\"">>}],
<<"Unauthorized">>}, Result),
- ?assert(meck:validate(elli)),
- meck:unload(elli).
+ ?assert(meck:validate(elli_request)),
+ meck:unload(elli_request).
valid_credentials_test() ->
- meck:new(elli),
- meck:expect(elli, get_header,
+ meck:new(elli_request),
+ meck:expect(elli_request, get_header,
fun (<<"Authorization">>, mock_request) ->
?VALID_CREDENTIALS
end),
@@ -39,13 +39,13 @@ valid_credentials_test() ->
basicauth_config()),
?assertEqual(ignore, Result),
- ?assert(meck:validate(elli)),
- meck:unload(elli).
+ ?assert(meck:validate(elli_request)),
+ meck:unload(elli_request).
invalid_credentials_test() ->
- meck:new(elli),
- meck:expect(elli, get_header,
+ meck:new(elli_request),
+ meck:expect(elli_request, get_header,
fun (<<"Authorization">>, mock_request) ->
?INVALID_CREDENTIALS
end),
@@ -54,18 +54,18 @@ invalid_credentials_test() ->
basicauth_config())),
?assertEqual({403, [], <<"Forbidden">>}, Result),
- ?assert(meck:validate(elli)),
- meck:unload(elli).
+ ?assert(meck:validate(elli_request)),
+ meck:unload(elli_request).
%%
%% HELPERS
%%
basicauth_config() ->
- [{auth_fun, fun test_predicate/3}].
+ [{auth_fun, fun auth_fun/3}].
-test_predicate(_Req, undefined, undefined) -> unauthorized;
-test_predicate(_Req, ?USER, ?PASSWORD) -> ok;
-test_predicate(_Req, _User, _Password) -> forbidden.
+auth_fun(_Req, undefined, undefined) -> unauthorized;
+auth_fun(_Req, ?USER, ?PASSWORD) -> ok;
+auth_fun(_Req, _User, _Password) -> forbidden.

0 comments on commit ded21f4

Please sign in to comment.