def database_forwards(self, app_label: str, schema_editor: SchemaEditor, from_state: ProjectState, to_state: ProjectState) -> None: enable_row_level_security( app_label, self.model_name, apps=to_state.apps, superuser=self.superuser, )
def test_enable_rls_with_superuser_policy(self): enable_row_level_security('tests', 'RelatedModel', apps, superuser=True)
def test_enable_fails_when_rls_already_enabled(self): with self.assertRaises(ProgrammingError): enable_row_level_security('tests', 'RestrictedModel', apps)
def test_enable_fails_if_no_fk_to_tenant(self): with self.assertRaises(Exception) as exc: enable_row_level_security('tests', 'DistinctModel', apps) self.assertEqual( 'Unable to find any FK chains back to tenant model.', exc.message)
def test_disable_rls(self): disable_row_level_security('tests', 'RestrictedModel', apps) enable_row_level_security('tests', 'RestrictedModel', apps)
def test_enable_rls(self): enable_row_level_security('tests', 'RelatedModel', apps) disable_row_level_security('tests', 'RelatedModel', apps)