File 1444-test-crl-add-extra-lookup-insert-delete-test.patch of Package erlang
From 97a8677ca664e923d6ca838bbab86b350523b935 Mon Sep 17 00:00:00 2001
From: Thales Macedo Garitezi <thalesmg@gmail.com>
Date: Thu, 11 Aug 2022 17:29:37 -0300
Subject: [PATCH 4/4] test(crl): add extra lookup/insert/delete test
---
lib/ssl/test/ssl_crl_SUITE.erl | 37 ++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/lib/ssl/test/ssl_crl_SUITE.erl b/lib/ssl/test/ssl_crl_SUITE.erl
index 97abcb3592..997f7f11e9 100644
--- a/lib/ssl/test/ssl_crl_SUITE.erl
+++ b/lib/ssl/test/ssl_crl_SUITE.erl
@@ -83,7 +84,7 @@ groups() ->
{group, crl_hash_dir}]},
{v2_crl, [], basic_tests()},
{v1_crl, [], basic_tests()},
- {idp_crl, [], basic_tests()},
+ {idp_crl, [], basic_tests() ++ idp_crl_tests()},
{crl_hash_dir, [], basic_tests() ++ crl_hash_dir_tests()}].
basic_tests() ->
@@ -94,6 +95,9 @@ basic_tests() ->
basic_tests() ->
[crl_verify_valid, crl_verify_revoked, crl_verify_no_crl].
+idp_crl_tests() ->
+ [delete_crl_with_path].
+
crl_hash_dir_tests() ->
[crl_hash_dir_collision, crl_hash_dir_expired].
@@ -558,6 +562,35 @@ crl_verify_error(Hostname, ServerNode, ServerOpts, ClientNode, ClientOpts, Expec
end,
ssl_test_lib:check_result(Client, {error, {tls_alert, ExpectedAlert}}).
+delete_crl_with_path(Config) ->
+ PrivDir = proplists:get_value(cert_dir, Config),
+
+ CertFilepath = filename:join([PrivDir, "server", "cert.pem"]),
+ {ok, PemCert} = file:read_file(CertFilepath),
+ [{_, DerCert, _}] = public_key:pem_decode(PemCert),
+ OTPCert = public_key:pkix_decode_cert(DerCert, otp),
+ [DP | _] = public_key:pkix_dist_points(OTPCert),
+
+ CRLFilepath = filename:join([PrivDir, "otpCA", "crl.pem"]),
+ {ok, PemBin} = file:read_file(CRLFilepath),
+ PemEntries = public_key:pem_decode(PemBin),
+ CRLs = [CRL || {'CertificateList', CRL, not_encrypted}
+ <- PemEntries],
+
+ {status, _, _, StatusInfo} = sys:get_status(whereis(ssl_manager)),
+ [_, _,_, _, Prop] = StatusInfo,
+ State = ssl_test_lib:state(Prop),
+ case element(5, State) of
+ [_, _, _, {CRLCache, _}] ->
+ URI = "http://localhost/otpCA/crl.pem",
+ not_available = ssl_crl_cache:lookup(DP, issuer, {{CRLCache, unused}, unused}),
+ ok = ssl_crl_cache:insert(URI, {der, CRLs}),
+ CRLs = ssl_crl_cache:lookup(DP, issuer, {{CRLCache, unused}, unused}),
+ ok = ssl_crl_cache:delete(URI),
+ not_available = ssl_crl_cache:lookup(DP, issuer, {{CRLCache, unused}, unused}),
+ ok
+ end.
+
%%--------------------------------------------------------------------
%% Internal functions ------------------------------------------------
%%--------------------------------------------------------------------
--
2.35.3