summaryrefslogtreecommitdiff
path: root/lib/eldap/test/eldap_basic_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/eldap/test/eldap_basic_SUITE.erl')
-rw-r--r--lib/eldap/test/eldap_basic_SUITE.erl113
1 files changed, 108 insertions, 5 deletions
diff --git a/lib/eldap/test/eldap_basic_SUITE.erl b/lib/eldap/test/eldap_basic_SUITE.erl
index b871eda19c..683e1d5393 100644
--- a/lib/eldap/test/eldap_basic_SUITE.erl
+++ b/lib/eldap/test/eldap_basic_SUITE.erl
@@ -20,7 +20,63 @@
-module(eldap_basic_SUITE).
--compile(export_all).
+-export([
+ add_already_exists/1,
+ add_referral/1,
+ add_when_bound/1,
+ add_when_not_bound/1,
+ app/1,
+ appup/1,
+ bind/1,
+ client_side_add_timeout/1,
+ client_side_bind_timeout/1,
+ client_side_search_timeout/1,
+ client_side_start_tls_timeout/1,
+ close_after_tcp_error/1,
+ close_ret_val/1,
+ decode/1,
+ delete/1,
+ delete_referral/1,
+ elementary_search/1,
+ encode/1,
+ modify/1,
+ modify_dn_delete_old/1,
+ modify_dn_keep_old/1,
+ modify_referral/1,
+ more_add/1,
+ open_ret_val_error/1,
+ open_ret_val_success/1,
+ search_filter_and/1,
+ search_filter_and_not/1,
+ search_filter_equalityMatch/1,
+ search_filter_equalityMatch_objectClass_exists/1,
+ search_filter_final/1,
+ search_filter_initial/1,
+ search_filter_or/1,
+ search_filter_or_sizelimit_ok/1,
+ search_filter_or_sizelimit_exceeded/1,
+ search_filter_substring_any/1,
+ search_non_existant/1,
+ search_referral/1,
+ search_two_hits/1,
+ ssl_connection/1,
+ start_tls_on_ssl_should_fail/1,
+ start_tls_twice_should_fail/1,
+ tcp_connection/1,
+ tcp_connection_option/1
+ ]).
+
+-export([
+ all/0,
+ end_per_group/2,
+ end_per_suite/1,
+ end_per_testcase/2,
+ groups/0,
+ init_per_group/2,
+ init_per_suite/1,
+ init_per_testcase/2,
+ suite/0
+ ]).
%%-include_lib("common_test/include/ct.hrl").
-include_lib("common_test/include/ct.hrl").
@@ -65,6 +121,7 @@ groups() ->
more_add,
add_referral,
search_filter_equalityMatch,
+ search_filter_equalityMatch_objectClass_exists,
search_filter_substring_any,
search_filter_initial,
search_filter_final,
@@ -73,6 +130,8 @@ groups() ->
search_filter_and_not,
search_two_hits,
search_referral,
+ search_filter_or_sizelimit_ok,
+ search_filter_or_sizelimit_exceeded,
modify,
modify_referral,
delete,
@@ -208,8 +267,8 @@ init_per_testcase(ssl_connection, Config) ->
ct:log("ssl server waiting for connections...",[]),
{ok, S} = ssl:transport_accept(SSL_LSock),
ct:log("ssl:transport_accept/1 ok",[]),
- ok = ssl:ssl_accept(S),
- ct:log("ssl:ssl_accept/1 ok",[]),
+ {ok,_} = ssl:handshake(S),
+ ct:log("ssl:handshake/1 ok",[]),
L()
end)();
Other ->
@@ -516,6 +575,17 @@ search_filter_equalityMatch(Config) ->
scope=eldap:singleLevel()}).
%%%----------------------------------------------------------------
+search_filter_equalityMatch_objectClass_exists(Config) ->
+ BasePath = proplists:get_value(eldap_path, Config),
+ ExpectedDN = "cn=Jonas Jonsson," ++ BasePath,
+ {ok, #eldap_search_result{entries=[#eldap_entry{object_name=ExpectedDN}]}} =
+ eldap:search(proplists:get_value(handle, Config),
+ #eldap_search{base = BasePath,
+ filter = eldap:'and'([eldap:equalityMatch("sn", "Jonsson"),
+ eldap:present("objectclass")]),
+ scope=eldap:singleLevel()}).
+
+%%%----------------------------------------------------------------
search_filter_substring_any(Config) ->
BasePath = proplists:get_value(eldap_path, Config),
ExpectedDN = "cn=Jonas Jonsson," ++ BasePath,
@@ -574,6 +644,39 @@ search_filter_or(Config) ->
ExpectedDNs = lists:sort([DN || #eldap_entry{object_name=DN} <- Es]).
%%%----------------------------------------------------------------
+search_filter_or_sizelimit_ok(Config) ->
+ H = proplists:get_value(handle, Config),
+ BasePath = proplists:get_value(eldap_path, Config),
+ ExpectedDNs = lists:sort(["cn=Foo Bar," ++ BasePath,
+ "ou=Team," ++ BasePath]),
+ {ok, #eldap_search_result{entries=Es}} =
+ eldap:search(H,
+ #eldap_search{base = BasePath,
+ filter = eldap:'or'([eldap:substrings("sn", [{any, "a"}]),
+ eldap:equalityMatch("ou","Team")]),
+ size_limit = 2,
+ scope=eldap:singleLevel()}),
+ ExpectedDNs = lists:sort([DN || #eldap_entry{object_name=DN} <- Es]).
+
+%%%----------------------------------------------------------------
+search_filter_or_sizelimit_exceeded(Config) ->
+ H = proplists:get_value(handle, Config),
+ BasePath = proplists:get_value(eldap_path, Config),
+ %% The quesry without the {size_limit,1} option would return two answers:
+ ExpectedDNs = ["cn=Foo Bar," ++ BasePath,
+ "ou=Team," ++ BasePath],
+ %% Expect exact one of the two answers, but we don't know which:
+ {ok, #eldap_search_result{entries=[E]}} =
+ eldap:search(H,
+ #eldap_search{base = BasePath,
+ filter = eldap:'or'([eldap:substrings("sn", [{any, "a"}]),
+ eldap:equalityMatch("ou","Team")]),
+ size_limit = 1,
+ scope=eldap:singleLevel()}),
+ #eldap_entry{object_name=DN} = E,
+ true = lists:member(DN, ExpectedDNs).
+
+%%%----------------------------------------------------------------
search_filter_and_not(Config) ->
H = proplists:get_value(handle, Config),
BasePath = proplists:get_value(eldap_path, Config),
@@ -847,9 +950,9 @@ find_first_server(UseSSL, [{config,Key}|Ss]) ->
find_first_server(UseSSL, Ss)
end;
find_first_server(UseSSL, [{Host,Port}|Ss]) ->
- case eldap:open([Host],[{port,Port},{ssl,UseSSL}]) of
+ case eldap:open([Host],[{port,Port},{ssl,UseSSL},{timeout,10000}]) of
{ok,H} when UseSSL==false, Ss=/=[] ->
- case eldap:start_tls(H,[]) of
+ case eldap:start_tls(H, [], 10000) of
ok ->
ct:log("find_first_server ~p UseSSL=~p -> ok",[{Host,Port},UseSSL]),
eldap:close(H),