From 63c5ce1adb12ab0f98ea88f72dbb7dc40fdd2bba Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Tue, 14 Jan 2025 13:27:37 -0800 Subject: [PATCH] Allow `dolt sql` command line access to always log in as the root superuser account, even if the root account was assigned a password --- integration-tests/bats/sql-privs.bats | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/integration-tests/bats/sql-privs.bats b/integration-tests/bats/sql-privs.bats index 81d51b129d..16c7efb7b9 100644 --- a/integration-tests/bats/sql-privs.bats +++ b/integration-tests/bats/sql-privs.bats @@ -132,6 +132,19 @@ teardown() { [[ $output =~ "| root | % " ]] || false } +# Asserts that `dolt sql` can always be used to access the database as a superuser. For example, if the root +# user is assigned a password, `dolt sql` should still be able to log in as a superuser, since the user +# already has access to the host and data directory. +@test "sql-privs: superuser access is always available from dolt sql" { + # Create a root@% user with a password set + dolt sql -q "CREATE USER root@'%' identified by 'pass1'; grant all on *.* to root@'%' with grant option;" + + # Make sure dolt sql can still log in as root, even though root has a password set now + run dolt sql -q "select user();" + [ $status -eq 0 ] + [[ $output =~ "root@localhost" ]] || false +} + # Asserts that creating users via 'dolt sql' before starting a sql-server causes the privileges.db to be # initialized and prevents the root superuser from being created, since the customer has already started # manually managing user accounts.