Skip to content

Commit

Permalink
Merge 5dfa7fc into 2139bf8
Browse files Browse the repository at this point in the history
  • Loading branch information
Gastove authored Jul 27, 2018
2 parents 2139bf8 + 5dfa7fc commit d0a2e77
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pgbedrock/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '0.3.1'
__version__ = '0.3.2'
LOG_FORMAT = '%(levelname)s:%(filename)s:%(funcName)s:%(lineno)s - %(message)s'
4 changes: 2 additions & 2 deletions pgbedrock/privileges.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
Q_REVOKE_NONDEFAULT = 'REVOKE {} ON {} {} FROM "{}";'
Q_GRANT_DEFAULT = """
SET ROLE "{}";
ALTER DEFAULT PRIVILEGES IN SCHEMA {} GRANT {} ON {} TO "{}";
ALTER DEFAULT PRIVILEGES IN SCHEMA "{}" GRANT {} ON {} TO "{}";
RESET ROLE;
"""
Q_REVOKE_DEFAULT = """
SET ROLE "{}";
ALTER DEFAULT PRIVILEGES IN SCHEMA {} REVOKE {} ON {} FROM "{}";
ALTER DEFAULT PRIVILEGES IN SCHEMA "{}" REVOKE {} ON {} FROM "{}";
RESET ROLE;
"""

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_version():

required = [
'click==6.7',
'psycopg2==2.7.3',
'psycopg2==2.7.5',
'PyYAML==3.12',
'Jinja2==2.9.6',
'cerberus==1.1',
Expand Down
42 changes: 40 additions & 2 deletions tests/test_core_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_configure_schema_role_has_dash(tmpdir, capsys, db_config, cursor, base_
spec = copy.copy(base_spec)
spec += dedent("""
{}:
has_personal_schema: yes
has_personal_schema: true
""".format(role))

spec_path = tmpdir.join('spec.yml')
Expand All @@ -198,7 +198,45 @@ def test_configure_schema_role_has_dash(tmpdir, capsys, db_config, cursor, base_
privileges=True,
live=False,
verbose=False
)
)
)
core_configure.configure(**params)
out, err = capsys.readouterr()
assert own.Q_CREATE_SCHEMA.format(role, role) in out


def test_configure_schema_role_has_dash_and_default_privs(
tmpdir,
capsys,
db_config,
cursor,
base_spec
):
spec = copy.deepcopy(base_spec)
spec += dedent("""
dash-user:
has_personal_schema: true
otheruser:
privileges:
schemas:
read:
- dash-user
""")

spec_path = tmpdir.join('spec.yml')
spec_path.write(spec)

params = copy.deepcopy(db_config)
params.update(
dict(spec_path=spec_path.strpath,
prompt=False,
attributes=True,
memberships=True,
ownerships=True,
privileges=True,
live=False,
verbose=False
)
)
core_configure.configure(**params)
out, err = capsys.readouterr()
Expand Down

0 comments on commit d0a2e77

Please sign in to comment.