File 3402-eldap-size_limit-test-case-added.patch of Package erlang

From da0e870f9e7c74ce5fde42e1d1c77fe5936b6c8f Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Thu, 28 Jan 2021 19:08:54 +0100
Subject: [PATCH 2/2] eldap: size_limit test case added

---
 lib/eldap/test/eldap_basic_SUITE.erl | 37 ++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/lib/eldap/test/eldap_basic_SUITE.erl b/lib/eldap/test/eldap_basic_SUITE.erl
index a337fe1c21..787c53363b 100644
--- a/lib/eldap/test/eldap_basic_SUITE.erl
+++ b/lib/eldap/test/eldap_basic_SUITE.erl
@@ -52,6 +52,8 @@
          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,
@@ -126,6 +128,8 @@ groups() ->
 		      search_extensible_match_with_dn,
 		      search_extensible_match_without_dn,
 		      search_referral,
+                      search_filter_or_sizelimit_ok,
+                      search_filter_or_sizelimit_exceeded,
 		      modify,
 		      modify_referral,
 		      delete,
@@ -626,6 +630,39 @@ search_filter_or(Config) ->
 				   scope=eldap:singleLevel()}),
     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),
-- 
2.26.2

openSUSE Build Service is sponsored by