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