fix(init): correct quoting of database and user (#6928)

* fix(init): correct quoting

* quote username in logstore migration

---------

Co-authored-by: Silvan <silvan.reusser@gmail.com>
This commit is contained in:
Tim Zook 2023-12-03 02:30:08 -06:00 committed by GitHub
parent e3d1ca4d58
commit 302b4b90d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 24 additions and 24 deletions

View File

@ -1,2 +1,2 @@
-- replace %[1]s with the name of the user -- replace %[1]s with the name of the user
CREATE USER IF NOT EXISTS %[1]s CREATE USER IF NOT EXISTS "%[1]s"

View File

@ -1,2 +1,2 @@
-- replace %[1]s with the name of the database -- replace %[1]s with the name of the database
CREATE DATABASE IF NOT EXISTS %[1]s CREATE DATABASE IF NOT EXISTS "%[1]s"

View File

@ -1,4 +1,4 @@
-- replace the first %[1]s with the database -- replace the first %[1]s with the database
-- replace the second \%[2]s with the user -- replace the second \%[2]s with the user
GRANT ALL ON DATABASE %[1]s TO %[2]s; GRANT ALL ON DATABASE "%[1]s" TO "%[2]s";
GRANT SYSTEM VIEWACTIVITY TO %[2]s; GRANT SYSTEM VIEWACTIVITY TO "%[2]s";

View File

@ -1,3 +1,3 @@
CREATE SCHEMA IF NOT EXISTS eventstore; CREATE SCHEMA IF NOT EXISTS eventstore;
GRANT ALL ON ALL TABLES IN SCHEMA eventstore TO %[1]s; GRANT ALL ON ALL TABLES IN SCHEMA eventstore TO "%[1]s";

View File

@ -1,3 +1,3 @@
CREATE SCHEMA IF NOT EXISTS projections; CREATE SCHEMA IF NOT EXISTS projections;
GRANT ALL ON ALL TABLES IN SCHEMA projections TO %[1]s; GRANT ALL ON ALL TABLES IN SCHEMA projections TO "%[1]s";

View File

@ -1,3 +1,3 @@
CREATE SCHEMA IF NOT EXISTS system; CREATE SCHEMA IF NOT EXISTS system;
GRANT ALL ON ALL TABLES IN SCHEMA system TO %[1]s; GRANT ALL ON ALL TABLES IN SCHEMA system TO "%[1]s";

View File

@ -1 +1 @@
CREATE USER %[1]s CREATE USER "%[1]s"

View File

@ -1 +1 @@
CREATE DATABASE %[1]s CREATE DATABASE "%[1]s"

View File

@ -1,3 +1,3 @@
-- replace the first %[1]s with the database -- replace the first %[1]s with the database
-- replace the second \%[2]s with the user -- replace the second \%[2]s with the user
GRANT ALL ON DATABASE %[1]s TO %[2]s; GRANT ALL ON DATABASE "%[1]s" TO "%[2]s";

View File

@ -1,3 +1,3 @@
CREATE SCHEMA IF NOT EXISTS eventstore; CREATE SCHEMA IF NOT EXISTS eventstore;
GRANT ALL ON ALL TABLES IN SCHEMA eventstore TO %[1]s; GRANT ALL ON ALL TABLES IN SCHEMA eventstore TO "%[1]s";

View File

@ -1,3 +1,3 @@
CREATE SCHEMA IF NOT EXISTS projections; CREATE SCHEMA IF NOT EXISTS projections;
GRANT ALL ON ALL TABLES IN SCHEMA projections TO %[1]s; GRANT ALL ON ALL TABLES IN SCHEMA projections TO "%[1]s";

View File

@ -1,3 +1,3 @@
CREATE SCHEMA IF NOT EXISTS system; CREATE SCHEMA IF NOT EXISTS system;
GRANT ALL ON ALL TABLES IN SCHEMA system TO %[1]s; GRANT ALL ON ALL TABLES IN SCHEMA system TO "%[1]s";

View File

@ -26,7 +26,7 @@ func Test_verifyDB(t *testing.T) {
name: "doesn't exists, create fails", name: "doesn't exists, create fails",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("-- replace zitadel with the name of the database\nCREATE DATABASE IF NOT EXISTS zitadel", sql.ErrTxDone), expectExec("-- replace zitadel with the name of the database\nCREATE DATABASE IF NOT EXISTS \"zitadel\"", sql.ErrTxDone),
), ),
database: "zitadel", database: "zitadel",
}, },
@ -36,7 +36,7 @@ func Test_verifyDB(t *testing.T) {
name: "doesn't exists, create successful", name: "doesn't exists, create successful",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("-- replace zitadel with the name of the database\nCREATE DATABASE IF NOT EXISTS zitadel", nil), expectExec("-- replace zitadel with the name of the database\nCREATE DATABASE IF NOT EXISTS \"zitadel\"", nil),
), ),
database: "zitadel", database: "zitadel",
}, },
@ -46,7 +46,7 @@ func Test_verifyDB(t *testing.T) {
name: "already exists", name: "already exists",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("-- replace zitadel with the name of the database\nCREATE DATABASE IF NOT EXISTS zitadel", nil), expectExec("-- replace zitadel with the name of the database\nCREATE DATABASE IF NOT EXISTS \"zitadel\"", nil),
), ),
database: "zitadel", database: "zitadel",
}, },

View File

@ -21,7 +21,7 @@ func Test_verifyGrant(t *testing.T) {
name: "doesn't exists, create fails", name: "doesn't exists, create fails",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("GRANT ALL ON DATABASE zitadel TO zitadel-user", sql.ErrTxDone), expectExec("GRANT ALL ON DATABASE \"zitadel\" TO \"zitadel-user\"", sql.ErrTxDone),
), ),
database: "zitadel", database: "zitadel",
username: "zitadel-user", username: "zitadel-user",
@ -32,7 +32,7 @@ func Test_verifyGrant(t *testing.T) {
name: "correct", name: "correct",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("GRANT ALL ON DATABASE zitadel TO zitadel-user", nil), expectExec("GRANT ALL ON DATABASE \"zitadel\" TO \"zitadel-user\"", nil),
), ),
database: "zitadel", database: "zitadel",
username: "zitadel-user", username: "zitadel-user",
@ -43,7 +43,7 @@ func Test_verifyGrant(t *testing.T) {
name: "already exists", name: "already exists",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("GRANT ALL ON DATABASE zitadel TO zitadel-user", nil), expectExec("GRANT ALL ON DATABASE \"zitadel\" TO \"zitadel-user\"", nil),
), ),
database: "zitadel", database: "zitadel",
username: "zitadel-user", username: "zitadel-user",

View File

@ -27,7 +27,7 @@ func Test_verifyUser(t *testing.T) {
name: "doesn't exists, create fails", name: "doesn't exists, create fails",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("-- replace zitadel-user with the name of the user\nCREATE USER IF NOT EXISTS zitadel-user", sql.ErrTxDone), expectExec("-- replace zitadel-user with the name of the user\nCREATE USER IF NOT EXISTS \"zitadel-user\"", sql.ErrTxDone),
), ),
username: "zitadel-user", username: "zitadel-user",
password: "", password: "",
@ -38,7 +38,7 @@ func Test_verifyUser(t *testing.T) {
name: "correct without password", name: "correct without password",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("-- replace zitadel-user with the name of the user\nCREATE USER IF NOT EXISTS zitadel-user", nil), expectExec("-- replace zitadel-user with the name of the user\nCREATE USER IF NOT EXISTS \"zitadel-user\"", nil),
), ),
username: "zitadel-user", username: "zitadel-user",
password: "", password: "",
@ -49,7 +49,7 @@ func Test_verifyUser(t *testing.T) {
name: "correct with password", name: "correct with password",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("-- replace zitadel-user with the name of the user\nCREATE USER IF NOT EXISTS zitadel-user WITH PASSWORD 'password'", nil), expectExec("-- replace zitadel-user with the name of the user\nCREATE USER IF NOT EXISTS \"zitadel-user\" WITH PASSWORD 'password'", nil),
), ),
username: "zitadel-user", username: "zitadel-user",
password: "password", password: "password",
@ -60,7 +60,7 @@ func Test_verifyUser(t *testing.T) {
name: "already exists", name: "already exists",
args: args{ args: args{
db: prepareDB(t, db: prepareDB(t,
expectExec("-- replace zitadel-user with the name of the user\nCREATE USER IF NOT EXISTS zitadel-user WITH PASSWORD 'password'", nil), expectExec("-- replace zitadel-user with the name of the user\nCREATE USER IF NOT EXISTS \"zitadel-user\" WITH PASSWORD 'password'", nil),
), ),
username: "zitadel-user", username: "zitadel-user",
password: "", password: "",

View File

@ -1,3 +1,3 @@
CREATE SCHEMA IF NOT EXISTS logstore; CREATE SCHEMA IF NOT EXISTS logstore;
GRANT ALL ON ALL TABLES IN SCHEMA logstore TO %[1]s; GRANT ALL ON ALL TABLES IN SCHEMA logstore TO "%[1]s";