Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: Accept PASSWORD REQUIRE CURRENT DEFAULT #53306

Merged
merged 4 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/executor/test/passwordtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"password_management_test.go",
],
flaky = True,
shard_count = 8,
shard_count = 9,
deps = [
"//pkg/domain",
"//pkg/errno",
Expand Down
40 changes: 40 additions & 0 deletions pkg/executor/test/passwordtest/password_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,46 @@ func TestPasswordExpiredAndTacking(t *testing.T) {
require.Error(t, tk.Session().Auth(&auth.UserIdentity{Username: user, Hostname: host}, sha1Password("!@#HASHhs123"), nil, nil))
}

// TestPasswordMySQLCompatibility is to test compatibility with the output of what MySQL outputs on SHOW CREATE USER.
func TestPasswordMySQLCompatibility(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

// MySQL 8.0.37
//
// This is using mysql_native_password as that's common with this version, however it is not the default.
//
// CREATE USER 'test80037'@'%' IDENTIFIED WITH 'mysql_native_password' BY 'secret';
// SHOW CREATE USER 'test80037'@'%';
tk.MustExec(
"CREATE USER `test80037`@`%` " +
"IDENTIFIED WITH 'mysql_native_password' AS '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7' " +
"REQUIRE NONE " +
"PASSWORD EXPIRE DEFAULT " +
"ACCOUNT UNLOCK " +
"PASSWORD HISTORY DEFAULT " +
"PASSWORD REUSE INTERVAL DEFAULT " +
"PASSWORD REQUIRE CURRENT DEFAULT",
)

// MySQL 8.4.0
//
// NOT using mysql_native_password here as that is disabled by default in this version.
//
// CREATE USER 'test80400'@'%';
// SHOW CREATE USER 'test80400'@'%';
tk.MustExec(
"CREATE USER `test80400`@`%` " +
"IDENTIFIED WITH 'caching_sha2_password' " +
"REQUIRE NONE " +
"PASSWORD EXPIRE DEFAULT " +
"ACCOUNT UNLOCK " +
"PASSWORD HISTORY DEFAULT " +
"PASSWORD REUSE INTERVAL DEFAULT " +
"PASSWORD REQUIRE CURRENT DEFAULT",
)
}

func loginFailedAncCheck(t *testing.T, store kv.Storage, user, host, password string, failedLoginCount int64, autoAccountLocked string) {
tk := testkit.NewTestKit(t, store)
require.Error(t, tk.Session().Auth(&auth.UserIdentity{Username: user, Hostname: host}, sha1Password(password), nil, nil))
Expand Down
1 change: 1 addition & 0 deletions pkg/parser/ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,7 @@ const (
PasswordLockTimeUnbounded
UserCommentType
UserAttributeType
PasswordRequireCurrentDefault

UserResourceGroupName
)
Expand Down
Loading