示例#1
0
 def test_get_secured_columns(self, mock_model):
     mock_model.return_value.get_collection.return_value = {
         'fields': {
             'secure column': 'any spec'
         }
     }
     authority = Authority('secure catalog', 'any col')
     secure_columns = authority.get_secured_columns()
     self.assertEqual(
         secure_columns, {
             'secure column': {
                 'gob_type': gob_secure_types.SecureString,
                 'spec': 'any spec'
             }
         })
示例#2
0
 def test_get_secured_json_columns(self, mock_model):
     mock_model.return_value.get_collection.return_value = {
         'fields': {
             'secure column': {
                 'type': 'GOB.JSON',
                 'attributes': {
                     'attr1': {
                         'type': 'GOB.SecureString'
                     },
                     'attr2': {
                         'type': 'GOB.String'
                     }
                 }
             }
         }
     }
     authority = Authority('secure catalog', 'any col')
     secure_columns = authority.get_secured_columns()
     expect = {
         'secure column': {
             'gob_type': gob_types.JSON,
             'spec': {
                 'type': 'GOB.JSON',
                 'gob_type': gob_types.JSON,
                 'attributes': {
                     'attr1': {
                         'type': 'GOB.SecureString',
                         'gob_type': gob_secure_types.SecureString
                     },
                     'attr2': {
                         'type': 'GOB.String',
                         'gob_type': gob_types.String
                     }
                 },
             }
         }
     }
     print(secure_columns)
     self.assertEqual(secure_columns, expect)
示例#3
0
    def test_handle_secured_columns(self):
        authority = Authority('secure catalog', 'any col')
        authority.get_secured_columns = lambda: {'col': 'any info'}
        authority.exposed_value = lambda value, info: 'exposed value'

        row = {}
        authority._handle_secured_columns({}, row)
        self.assertEqual(row, {})

        row = {'col': 'any value', 'any other col': 'any value'}
        authority._handle_secured_columns({}, row)
        self.assertEqual(row, {
            'col': 'exposed value',
            'any other col': 'any value'
        })

        row = {'mapped col': 'any value', 'any other col': 'any value'}
        mapping = {'col': 'mapped col'}
        authority._handle_secured_columns(mapping, row)
        self.assertEqual(row, {
            'mapped col': 'exposed value',
            'any other col': 'any value'
        })