ldap_integration_tests.erl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. %%%-------------------------------------------------------------------
  2. %%% @author dmoore
  3. %%% @copyright (C) 2013, <COMPANY>
  4. %%% @doc
  5. %%%
  6. %%% @end
  7. %%% Created : 19. Oct 2013 7:45 PM
  8. %%%-------------------------------------------------------------------
  9. -module(ldap_integration_tests).
  10. -author("dmoore").
  11. -include("couch_db.hrl").
  12. -include_lib("eunit/include/eunit.hrl").
  13. -define(TEST_USER, "test.npm").
  14. -define(TEST_USER_PASSWORD, "T32!11pm").
  15. integration_test_() -> io:format("Testing...", []), run([fun () ->
  16. {ok, LdapConnection} = ldap_auth_gateway:connect(),
  17. io:format("Connect OK"),
  18. {ok, UserDN} = ldap_auth_gateway:authenticate(LdapConnection, ?TEST_USER, ?TEST_USER_PASSWORD),
  19. io:format("UserDN=~p\n", [UserDN]),
  20. Groups = ldap_auth_gateway:get_group_memberships(LdapConnection, UserDN),
  21. io:format("Groups=~p\n", [Groups]),
  22. eldap:close(LdapConnection)
  23. end]).
  24. run(Tests) ->
  25. {
  26. setup,
  27. fun () ->
  28. meck:new(couch_config, [non_strict]),
  29. meck:expect(couch_config, get, fun test_config:get_config/3)
  30. end,
  31. fun (_) -> meck:unload(couch_config) end,
  32. fun (_) -> Tests end
  33. }.