{
  "scenarios": [
    {
      "type": "alter",
      "name": "Alert default privileges for functions",
      "endpoint": "NODE-database.obj_id",
      "sql_endpoint": "NODE-database.sql_id",
      "msql_endpoint": "NODE-database.msql_id",
      "TEST_DB_NAME": "<TEST_DB_NAME>",
      "REPLACE_LOCALE": true,
      "data": {
        "deffuncacl": {
          "deleted": [
            {
              "grantor": "<OWNER>",
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "X",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "acltype": "defaultacls"
            }
          ]
        }
      },
      "expected_sql_file": "alter_default_db_privileges_function.sql",
      "expected_msql_file": "alter_default_db_privileges_function_msql.sql"
    },
    {
      "type": "alter",
      "name": "Alert default privileges for tables",
      "endpoint": "NODE-database.obj_id",
      "sql_endpoint": "NODE-database.sql_id",
      "msql_endpoint": "NODE-database.msql_id",
      "TEST_DB_NAME": "<TEST_DB_NAME>",
      "REPLACE_LOCALE": true,
      "data": {
        "deftblacl": {
          "deleted": [
            {
              "grantor": "<OWNER>",
              "grantee": "<OWNER>",
              "privileges": [
                {
                  "privilege_type": "D",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "acltype": "deftblacl"
            }
          ],
          "added": [
            {
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        }
      },
      "expected_msql_file": "alter_default_db_privileges_tables_msql.sql",
      "expected_sql_file": "alter_default_db_privileges_tables.sql"
    },
    {
      "type": "alter",
      "name": "Alert default privileges for sequences",
      "endpoint": "NODE-database.obj_id",
      "sql_endpoint": "NODE-database.sql_id",
      "msql_endpoint": "NODE-database.msql_id",
      "TEST_DB_NAME": "<TEST_DB_NAME>",
      "REPLACE_LOCALE": true,
      "data": {
        "defseqacl": {
          "deleted": [
            {
              "grantor": "<OWNER>",
              "grantee": "<OWNER>",
              "privileges": [
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "acltype": "defaultacls"
            }
          ],
          "added": [
            {
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "U",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftblacl": {
          "deleted": [
            {
              "grantor": "<OWNER>",
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "acltype": "defaultacls"
            }
          ]
        }
      },
      "expected_msql_file": "alter_default_db_privileges_sequences_msql.sql",
      "expected_sql_file": "alter_default_db_privileges_sequences.sql"
    },
    {
      "type": "alter",
      "name": "Alert default privileges for types",
      "endpoint": "NODE-database.obj_id",
      "sql_endpoint": "NODE-database.sql_id",
      "msql_endpoint": "NODE-database.msql_id",
      "TEST_DB_NAME": "<TEST_DB_NAME>",
      "REPLACE_LOCALE": true,
      "data": {
        "deftypeacl": {
          "deleted": [
            {
              "grantor": "<OWNER>",
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "U",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "acltype": "defaultacls"
            }
          ]
        }
      },
      "expected_msql_file": "alter_default_db_privileges_types_msql.sql",
      "expected_sql_file": "alter_default_db_privileges_types.sql"
    },
    {
      "type": "alter",
      "name": "Alert default privileges reset all",
      "endpoint": "NODE-database.obj_id",
      "sql_endpoint": "NODE-database.sql_id",
      "TEST_DB_NAME": "<TEST_DB_NAME>",
      "REPLACE_LOCALE": true,
      "data": {
        "deffuncacl": {
          "added": [
            {
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "X",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftypeacl": {
          "added": [
            {
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "U",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftblacl": {
          "added": [
            {
              "grantee": "<OWNER>",
              "privileges": [
                {
                  "privilege_type": "a",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "d",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "D",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "x",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "t",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ],
          "deleted": [
            {
              "grantor": "<OWNER>",
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "a",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "d",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "D",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "x",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "t",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "acltype": "defaultacls"
            }
          ]
        },
        "defseqacl": {
          "added": [
            {
              "grantee": "<OWNER>",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "U",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ],
          "deleted": [
            {
              "grantor": "<OWNER>",
              "grantee": "PUBLIC",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "U",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "acltype": "defaultacls"
            }
          ]
        }
      },
      "expected_sql_file": "alter_default_db_privileges_reset_all.sql"
    },
    {
      "type": "alter",
      "name": "Alert default privileges with new user add for function, table, sequence and type",
      "endpoint": "NODE-database.obj_id",
      "sql_endpoint": "NODE-database.sql_id",
      "msql_endpoint": "NODE-database.msql_id",
      "TEST_DB_NAME": "<TEST_DB_NAME>",
      "REPLACE_LOCALE": true,
      "data": {
        "deffuncacl": {
          "added": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "X",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftypeacl": {
          "added": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "U",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftblacl": {
          "added": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "a",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "d",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "defseqacl": {
          "added": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        }
      },
      "expected_msql_file": "alter_default_db_privileges_add_msql.sql",
      "expected_sql_file": "alter_default_db_privileges_add_all.sql",
      "pre_scenario_sql": "CREATE ROLE test_default_priv_user WITH NOLOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;"
    },
    {
      "type": "alter",
      "name": "Alert default privileges with new user for function, table, sequence and type",
      "endpoint": "NODE-database.obj_id",
      "sql_endpoint": "NODE-database.sql_id",
      "msql_endpoint": "NODE-database.msql_id",
      "TEST_DB_NAME": "<TEST_DB_NAME>",
      "REPLACE_LOCALE": true,
      "data": {
        "deffuncacl": {
          "changed": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "X",
                  "privilege": true,
                  "with_grant": true
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftypeacl": {
          "changed": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "U",
                  "privilege": true,
                  "with_grant": true
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftblacl": {
          "added": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "D",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ],
          "deleted": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ],
          "changed": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "d",
                  "privilege": true,
                  "with_grant": true
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "defseqacl": {
          "deleted": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                }
              ],
              "grantor": "<OWNER>"
            }
          ],
          "changed": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": true
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        }
      },
      "expected_msql_file": "alter_default_db_privileges_all_msql.sql",
      "expected_sql_file": "alter_default_db_privileges_all.sql"
    },
    {
      "type": "alter",
      "name": "Alert default privileges with new user reset all",
      "endpoint": "NODE-database.obj_id",
      "sql_endpoint": "NODE-database.sql_id",
      "msql_endpoint": "NODE-database.msql_id",
      "TEST_DB_NAME": "<TEST_DB_NAME>",
      "REPLACE_LOCALE": true,
      "data": {
        "deffuncacl": {
          "deleted": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "X",
                  "privilege": true,
                  "with_grant": true
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftypeacl": {
          "deleted": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "U",
                  "privilege": true,
                  "with_grant": true
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "deftblacl": {
          "deleted": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "D",
                  "privilege": true,
                  "with_grant": false
                },
                {
                  "privilege_type": "d",
                  "privilege": true,
                  "with_grant": true
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        },
        "defseqacl": {
          "deleted": [
            {
              "grantee": "test_default_priv_user",
              "privileges": [
                {
                  "privilege_type": "w",
                  "privilege": true,
                  "with_grant": true
                }
              ],
              "grantor": "<OWNER>"
            }
          ]
        }
      },
      "expected_sql_file": "alter_default_db_privileges_newuser_reset_all.sql",
      "post_scenario_sql": "DROP ROLE IF EXISTS test_default_priv_user;"
    }
  ]
}
