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

Support for roles in grants #259

Merged
merged 21 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
skip grant tests
only supported by EE/DC
current pipeline is OSS only
  • Loading branch information
bcmeireles committed Jan 23, 2025
commit a54544738ad7e134a2a5fc164b1170faef1a4924
1 change: 1 addition & 0 deletions tests/functional/adapter/grants/base_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from tests.utils.util import BUCKET


@pytest.mark.skip(reason="Dremio only supports grants in EE/DC editions.")
class BaseGrantsDremio(BaseGrants):
# This is overridden to change insert privilege to alter
def privilege_grantee_name_overrides(self):
Expand Down
7 changes: 5 additions & 2 deletions tests/functional/adapter/grants/test_incremental_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

from dbt.tests.util import (
run_dbt_and_capture,
get_manifest,
Expand All @@ -27,6 +29,7 @@
)


@pytest.mark.skip(reason="Dremio only supports grants in EE/DC editions.")
class TestIncrementalGrantsDremio(BaseGrantsDremio, BaseIncrementalGrants):
# Define this here to use our modified version of relation_from_name
def get_grants_on_relation(self, project, relation_name):
Expand All @@ -53,7 +56,7 @@ def test_incremental_grants(self, project, get_test_users):
model_id = "model.test.my_incremental_model"
model = manifest.nodes[model_id]
assert model.config.materialized == "incremental"
expected = {select_privilege_name: [test_users[0]]}
expected = {select_privilege_name: ["user:" + test_users[0]]}
self.assert_expected_grants_match_actual(
project, "my_incremental_model", expected
)
Expand All @@ -80,7 +83,7 @@ def test_incremental_grants(self, project, get_test_users):
manifest = get_manifest(project.project_root)
model = manifest.nodes[model_id]
assert model.config.materialized == "incremental"
expected = {select_privilege_name: [test_users[1]]}
expected = {select_privilege_name: ["user:" + test_users[1]]}
self.assert_expected_grants_match_actual(
project, "my_incremental_model", expected
)
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/adapter/grants/test_invalid_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

from dbt.tests.adapter.grants.test_invalid_grants import BaseInvalidGrants
from tests.functional.adapter.grants.base_grants import BaseGrantsDremio
from tests.utils.util import relation_from_name
from dbt.tests.util import get_connection


@pytest.mark.skip(reason="Dremio only supports grants in EE/DC editions.")
class TestInvalidGrantsDremio(BaseGrantsDremio, BaseInvalidGrants):
def grantee_does_not_exist_error(self):
return "Grant on catalog entity failed. User invalid_user does not exist."
Expand Down
14 changes: 9 additions & 5 deletions tests/functional/adapter/grants/test_model_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

from dbt.tests.adapter.grants.test_model_grants import (
BaseModelGrants,
user2_model_schema_yml,
Expand All @@ -30,6 +32,7 @@
from tests.utils.util import relation_from_name


@pytest.mark.skip(reason="Dremio only supports grants in EE/DC editions.")
class TestViewGrantsDremio(BaseGrantsDremio, BaseModelGrants):

# Overridden to only include view materialization
Expand Down Expand Up @@ -59,6 +62,7 @@ def test_view_table_grants(self, project, get_test_users):
self.assert_expected_grants_match_actual(project, "my_model", expected)


@pytest.mark.skip(reason="Dremio only supports grants in EE/DC editions.")
class TestTableGrantsDremio(BaseGrantsDremio, BaseModelGrants):
# Need to override this to make sure it uses our modified version of relation_from_name
# This isn't needed for views, as dbt-core's version defaults to database/schema path
Expand Down Expand Up @@ -87,7 +91,7 @@ def test_view_table_grants(self, project, get_test_users):
model_id = "model.test.my_model"
model = manifest.nodes[model_id]
assert model.config.materialized == "table"
expected = {select_privilege_name: [test_users[0]]}
expected = {select_privilege_name: ["user:" + test_users[0]]}
self.assert_expected_grants_match_actual(project, "my_model", expected)

# Table materialization, change select grant user
Expand All @@ -98,7 +102,7 @@ def test_view_table_grants(self, project, get_test_users):
manifest = get_manifest(project.project_root)
model = manifest.nodes[model_id]
assert model.config.materialized == "table"
expected = {select_privilege_name: [test_users[1]]}
expected = {select_privilege_name: ["user:" + test_users[1]]}
self.assert_expected_grants_match_actual(project, "my_model", expected)

# Table materialization, multiple grantees
Expand All @@ -111,7 +115,7 @@ def test_view_table_grants(self, project, get_test_users):
manifest = get_manifest(project.project_root)
model = manifest.nodes[model_id]
assert model.config.materialized == "table"
expected = {select_privilege_name: [test_users[0], test_users[1]]}
expected = {select_privilege_name: ["user:" + test_users[0], "user:" + test_users[1]]}
self.assert_expected_grants_match_actual(project, "my_model", expected)

# Table materialization, multiple privileges
Expand All @@ -125,7 +129,7 @@ def test_view_table_grants(self, project, get_test_users):
model = manifest.nodes[model_id]
assert model.config.materialized == "table"
expected = {
select_privilege_name: [test_users[0]],
insert_privilege_name: [test_users[1]],
select_privilege_name: ["user:" + test_users[0]],
insert_privilege_name: ["user:" + test_users[1]],
}
self.assert_expected_grants_match_actual(project, "my_model", expected)
3 changes: 3 additions & 0 deletions tests/functional/adapter/grants/test_seed_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

from dbt.tests.adapter.grants.test_seed_grants import BaseSeedGrants
from tests.functional.adapter.grants.base_grants import BaseGrantsDremio
from tests.utils.util import relation_from_name
from dbt.tests.util import get_connection


@pytest.mark.skip(reason="Dremio only supports grants in EE/DC editions.")
class TestSeedGrantsDremio(BaseGrantsDremio, BaseSeedGrants):

# Grants are reapplied if dbt run is ran twice without changes
Expand Down
1 change: 1 addition & 0 deletions tests/functional/adapter/grants/test_snapshot_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
""".strip()


@pytest.mark.skip(reason="Dremio only supports grants in EE/DC editions.")
class TestSnapshotGrantsDremio(BaseGrantsDremio, BaseSnapshotGrants):
# Override this to use our modified snapshot model
@pytest.fixture(scope="class")
Expand Down
Loading