-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
119 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.o | ||
ebin | ||
priv/canola-port | ||
_build |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: erlang | ||
|
||
otp_release: | ||
- 20.1 | ||
|
||
script: ./rebar3 as test do eunit, dialyzer, xref |
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,13 +1,22 @@ | ||
.PHONY: all compile clean | ||
|
||
all: compile | ||
.PHONY: compile rel cover test dialyzer | ||
REBAR=./rebar3 | ||
|
||
compile: | ||
./rebar compile | ||
$(REBAR) compile | ||
|
||
clean: | ||
./rebar clean | ||
$(REBAR) clean | ||
|
||
cover: test | ||
$(REBAR) cover | ||
|
||
test: compile | ||
$(REBAR) as test do eunit | ||
|
||
dialyzer: | ||
$(REBAR) dialyzer | ||
|
||
DIALYZER_APPS = kernel stdlib erts sasl eunit syntax_tools compiler crypto | ||
xref: | ||
$(REBAR) xref | ||
|
||
include tools.mk | ||
check: test dialyzer xref |
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,3 +1,19 @@ | ||
{port_specs, [{"priv/canola-port", ["c_src/canola-port.c"]}]}. | ||
|
||
{port_env, [{"LDFLAGS", "$LDFLAGS -lpam"}]}. | ||
|
||
{plugins, [pc]}. | ||
|
||
{provider_hooks, | ||
[ | ||
{pre, | ||
[ | ||
{compile, {pc, compile}}, | ||
{clean, {pc, clean}} | ||
] | ||
} | ||
] | ||
}. | ||
|
||
{xref_checks,[undefined_function_calls,undefined_functions,locals_not_used, | ||
deprecated_function_calls, deprecated_functions]}. |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
[]. |
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
%% ------------------------------------------------------------------- | ||
%% | ||
%% Copyright (c) 2017 Basho Technologies, Inc. | ||
%% | ||
%% This file is provided to you under the Apache License, | ||
%% Version 2.0 (the "License"); you may not use this file | ||
%% except in compliance with the License. You may obtain | ||
%% a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, | ||
%% software distributed under the License is distributed on an | ||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
%% KIND, either express or implied. See the License for the | ||
%% specific language governing permissions and limitations | ||
%% under the License. | ||
%% | ||
%% ------------------------------------------------------------------- | ||
|
||
-module(canola_tests). | ||
|
||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
%% | ||
%% If there's a known account in PAM on your local system for testing, | ||
%% define this to the service, username, and password for a live test. | ||
%% DO NOT commit a dependency on your local configuration! | ||
%% | ||
% -define(TEST_LOCAL_USER, {<<"cups">>, <<"guest">>, <<"">>}). | ||
|
||
auth_test_() -> | ||
{timeout, 30, fun() -> | ||
BogusPW = <<"ReallyHopeThisIsntYourPassword">>, | ||
FakeSvc = <<"ThereShouldntBeAServiceWithThisName">>, | ||
RealSvc = <<"login">>, | ||
FakeUsr = <<"NoSuchUserWeHope">>, | ||
UsrName = case os:getenv("USER") of | ||
false -> | ||
os:getenv("LOGNAME"); | ||
Name -> | ||
Name | ||
end, | ||
P = canola:open_debug(), | ||
?assert(erlang:is_list(UsrName)), | ||
RealUsr = erlang:list_to_binary(UsrName), | ||
|
||
Ret1 = canola:auth(RealSvc, RealUsr, BogusPW, P), | ||
% ?debugVal(Ret1), | ||
?assertEqual(error, Ret1), | ||
|
||
Ret2 = canola:auth(FakeSvc, RealUsr, BogusPW, P), | ||
% ?debugVal(Ret2), | ||
?assertEqual(error, Ret2), | ||
|
||
Ret3 = canola:auth(RealSvc, <<"root">>, <<"password">>, P), | ||
% ?debugVal(Ret3), | ||
?assertEqual(error, Ret3), | ||
|
||
Ret4 = canola:auth(RealSvc, FakeUsr, BogusPW, P), | ||
% ?debugVal(Ret4), | ||
?assertEqual(error, Ret4), | ||
|
||
?assertError(badarg, canola:auth(RealSvc, UsrName, BogusPW, P)), | ||
canola:close(P) | ||
end}. | ||
|
||
-ifdef(TEST_LOCAL_USER). | ||
|
||
user_test() -> | ||
P = canola:open_debug(), | ||
{Service, Username, Password} = ?TEST_LOCAL_USER, | ||
?assertEqual(ok, canola:auth(Service, Username, Password, P)), | ||
canola:close(P). | ||
|
||
-endif. % TEST_USER_NAME_PASS |