|
@@ -37,6 +37,7 @@
|
|
|
protocol => mqtt,
|
|
protocol => mqtt,
|
|
|
cert_subject => <<"cert_subject_data">>,
|
|
cert_subject => <<"cert_subject_data">>,
|
|
|
cert_common_name => <<"cert_common_name_data">>,
|
|
cert_common_name => <<"cert_common_name_data">>,
|
|
|
|
|
+ cert_pem => <<"fake_raw_cert_to_be_base64_encoded">>,
|
|
|
client_attrs => #{<<"group">> => <<"g1">>}
|
|
client_attrs => #{<<"group">> => <<"g1">>}
|
|
|
}).
|
|
}).
|
|
|
|
|
|
|
@@ -222,7 +223,8 @@ t_no_value_for_placeholder(_Config) ->
|
|
|
{ok, RawBody, Req1} = cowboy_req:read_body(Req0),
|
|
{ok, RawBody, Req1} = cowboy_req:read_body(Req0),
|
|
|
#{
|
|
#{
|
|
|
<<"cert_subject">> := <<"">>,
|
|
<<"cert_subject">> := <<"">>,
|
|
|
- <<"cert_common_name">> := <<"">>
|
|
|
|
|
|
|
+ <<"cert_common_name">> := <<"">>,
|
|
|
|
|
+ <<"cert_pem">> := <<"">>
|
|
|
} = emqx_utils_json:decode(RawBody, [return_maps]),
|
|
} = emqx_utils_json:decode(RawBody, [return_maps]),
|
|
|
Req = cowboy_req:reply(
|
|
Req = cowboy_req:reply(
|
|
|
200,
|
|
200,
|
|
@@ -238,7 +240,8 @@ t_no_value_for_placeholder(_Config) ->
|
|
|
<<"headers">> => #{<<"content-type">> => <<"application/json">>},
|
|
<<"headers">> => #{<<"content-type">> => <<"application/json">>},
|
|
|
<<"body">> => #{
|
|
<<"body">> => #{
|
|
|
<<"cert_subject">> => ?PH_CERT_SUBJECT,
|
|
<<"cert_subject">> => ?PH_CERT_SUBJECT,
|
|
|
- <<"cert_common_name">> => ?PH_CERT_CN_NAME
|
|
|
|
|
|
|
+ <<"cert_common_name">> => ?PH_CERT_CN_NAME,
|
|
|
|
|
+ <<"cert_pem">> => ?PH_CERT_PEM
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -251,7 +254,7 @@ t_no_value_for_placeholder(_Config) ->
|
|
|
|
|
|
|
|
ok = emqx_authn_http_test_server:set_handler(Handler),
|
|
ok = emqx_authn_http_test_server:set_handler(Handler),
|
|
|
|
|
|
|
|
- Credentials = maps:without([cert_subject, cert_common_name], ?CREDENTIALS),
|
|
|
|
|
|
|
+ Credentials = maps:without([cert_subject, cert_common_name, cert_pem], ?CREDENTIALS),
|
|
|
|
|
|
|
|
?assertMatch({ok, _}, emqx_access_control:authenticate(Credentials)),
|
|
?assertMatch({ok, _}, emqx_access_control:authenticate(Credentials)),
|
|
|
|
|
|
|
@@ -656,8 +659,10 @@ samples() ->
|
|
|
<<"peerhost">> := <<"127.0.0.1">>,
|
|
<<"peerhost">> := <<"127.0.0.1">>,
|
|
|
<<"cert_subject">> := <<"cert_subject_data">>,
|
|
<<"cert_subject">> := <<"cert_subject_data">>,
|
|
|
<<"cert_common_name">> := <<"cert_common_name_data">>,
|
|
<<"cert_common_name">> := <<"cert_common_name_data">>,
|
|
|
|
|
+ <<"cert_pem">> := CertPem,
|
|
|
<<"the_group">> := <<"g1">>
|
|
<<"the_group">> := <<"g1">>
|
|
|
} = emqx_utils_json:decode(RawBody, [return_maps]),
|
|
} = emqx_utils_json:decode(RawBody, [return_maps]),
|
|
|
|
|
+ <<"fake_raw_cert_to_be_base64_encoded">> = base64:decode(CertPem),
|
|
|
Req = cowboy_req:reply(
|
|
Req = cowboy_req:reply(
|
|
|
200,
|
|
200,
|
|
|
#{<<"content-type">> => <<"application/json">>},
|
|
#{<<"content-type">> => <<"application/json">>},
|
|
@@ -676,6 +681,7 @@ samples() ->
|
|
|
<<"peerhost">> => ?PH_PEERHOST,
|
|
<<"peerhost">> => ?PH_PEERHOST,
|
|
|
<<"cert_subject">> => ?PH_CERT_SUBJECT,
|
|
<<"cert_subject">> => ?PH_CERT_SUBJECT,
|
|
|
<<"cert_common_name">> => ?PH_CERT_CN_NAME,
|
|
<<"cert_common_name">> => ?PH_CERT_CN_NAME,
|
|
|
|
|
+ <<"cert_pem">> => ?PH_CERT_PEM,
|
|
|
<<"the_group">> => <<"${client_attrs.group}">>
|
|
<<"the_group">> => <<"${client_attrs.group}">>
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|