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,
     )
Example #2
0
 def test_enable_rls_with_superuser_policy(self):
     enable_row_level_security('tests',
                               'RelatedModel',
                               apps,
                               superuser=True)
Example #3
0
 def test_enable_fails_when_rls_already_enabled(self):
     with self.assertRaises(ProgrammingError):
         enable_row_level_security('tests', 'RestrictedModel', apps)
Example #4
0
 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)
Example #5
0
 def test_disable_rls(self):
     disable_row_level_security('tests', 'RestrictedModel', apps)
     enable_row_level_security('tests', 'RestrictedModel', apps)
Example #6
0
 def test_enable_rls(self):
     enable_row_level_security('tests', 'RelatedModel', apps)
     disable_row_level_security('tests', 'RelatedModel', apps)