auth_SUITE: Get certificate name from the certificate itself

... instead of hard-coding the value. This fixes the testsuite when the
generated certificate configuration changes.

[#153697697]
This commit is contained in:
Jean-Sébastien Pédron 2017-12-15 11:22:01 +01:00
parent 6372727eb5
commit a11e96caa0
1 changed files with 9 additions and 2 deletions

View File

@ -172,8 +172,15 @@ init_per_testcase(Testcase, Config) ->
rabbit_ct_helpers:testcase_started(Config, Testcase).
set_cert_user_on_default_vhost(Config) ->
Hostname = re:replace(os:cmd("hostname"), "\\s+", "", [global,{return,list}]),
User = "O=client,CN=" ++ Hostname,
CertsDir = ?config(rmq_certsdir, Config),
CertFile = filename:join([CertsDir, "client", "cert.pem"]),
{ok, CertBin} = file:read_file(CertFile),
[{'Certificate', Cert, not_encrypted}] = public_key:pem_decode(CertBin),
UserBin = rabbit_ct_broker_helpers:rpc(Config, 0,
rabbit_ssl,
peer_cert_auth_name,
[Cert]),
User = binary_to_list(UserBin),
ok = rabbit_ct_broker_helpers:add_user(Config, 0, User, ""),
ok = rabbit_ct_broker_helpers:set_full_permissions(Config, User, <<"/">>),
rabbit_ct_helpers:set_config(Config, [{temp_ssl_user, User}]).