Skip to content

Commit

Permalink
chore: make elvis happy
Browse files Browse the repository at this point in the history
  • Loading branch information
HJianBo committed Jul 25, 2022
1 parent 78449d7 commit 1c8defe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
17 changes: 13 additions & 4 deletions apps/emqx_authn/test/emqx_authn_mysql_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ user_seeds() ->
<<"query">> =>
<<
"SELECT password_hash, salt, is_superuser_int as is_superuser\n"
" FROM users where cert_subject = ${cert_subject} AND cert_common_name = ${cert_common_name} LIMIT 1"
" FROM users where cert_subject = ${cert_subject} AND \n"
" cert_common_name = ${cert_common_name} LIMIT 1"
>>,
<<"password_hash_algorithm">> => #{
<<"name">> => <<"sha256">>,
Expand Down Expand Up @@ -468,10 +469,18 @@ init_seeds() ->
" is_superuser_int TINYINT)"
),

Fields = [username, password_hash, salt, is_superuser_str, is_superuser_int],
Fields = [
username,
password_hash,
salt,
cert_subject,
cert_common_name,
is_superuser_str,
is_superuser_int
],
InsertQuery =
"INSERT INTO users(username, password_hash, salt, "
" is_superuser_str, is_superuser_int) VALUES(?, ?, ?, ?, ?)",
"INSERT INTO users(username, password_hash, salt, cert_subject, cert_common_name,"
" is_superuser_str, is_superuser_int) VALUES(?, ?, ?, ?, ?, ?, ?)",

lists:foreach(
fun(#{data := Values}) ->
Expand Down
18 changes: 14 additions & 4 deletions apps/emqx_authn/test/emqx_authn_pgsql_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ user_seeds() ->
<<"query">> =>
<<
"SELECT password_hash, salt, is_superuser_int as is_superuser\n"
" FROM users where cert_subject = ${cert_subject} AND cert_common_name = ${cert_common_name} LIMIT 1"
" FROM users where cert_subject = ${cert_subject} AND \n"
" cert_common_name = ${cert_common_name} LIMIT 1"
>>,
<<"password_hash_algorithm">> => #{
<<"name">> => <<"sha256">>,
Expand Down Expand Up @@ -518,12 +519,21 @@ init_seeds() ->
).

create_user(Values) ->
Fields = [username, password_hash, salt, is_superuser_str, is_superuser_int, is_superuser_bool],
Fields = [
username,
password_hash,
salt,
cert_subject,
cert_common_name,
is_superuser_str,
is_superuser_int,
is_superuser_bool
],

InsertQuery =
"INSERT INTO users(username, password_hash, salt,"
"INSERT INTO users(username, password_hash, salt, cert_subject, cert_common_name, "
"is_superuser_str, is_superuser_int, is_superuser_bool) "
"VALUES($1, $2, $3, $4, $5, $6)",
"VALUES($1, $2, $3, $4, $5, $6, $7, $8)",

Params = [maps:get(F, Values, null) || F <- Fields],
{ok, 1} = q(InsertQuery, Params),
Expand Down

0 comments on commit 1c8defe

Please sign in to comment.