示例#1
0
 def test_load_tarball_bad_group(self):
     bundle = build_tar_gz({
         'at_root': 'a\nb',
         'ldap/group-a': 'a\n!!!!!',
     })
     with self.assertRaises(importer.BundleBadFormatError):
         importer.load_tarball(content=bundle,
                               systems=['ldap'],
                               groups=['ldap/group-a', 'ldap/group-b'],
                               domain='example.com')
示例#2
0
 def test_load_tarball_bad_group(self):
   bundle = build_tar_gz({
     'at_root': 'a\nb',
     'ldap/group-a': 'a\n!!!!!',
   })
   with self.assertRaises(importer.BundleBadFormatError):
     importer.load_tarball(
       content=bundle,
       systems=['ldap'],
       groups=['ldap/group-a', 'ldap/group-b'],
       domain='example.com')
示例#3
0
    def test_load_tarball(self):
        bundle = build_tar_gz({
            'at_root': 'a\nb',
            'ldap/ bad name': 'a\nb',
            'ldap/group-a': 'a\nb',
            'ldap/group-b': 'a\nb',
            'ldap/group-c': 'a\nb',
            'ldap/deeper/group-a': 'a\nb',
            'not-ldap/group-a': 'a\nb',
        })
        result = importer.load_tarball(content=bundle,
                                       systems=['ldap'],
                                       groups=['ldap/group-a', 'ldap/group-b'],
                                       domain='example.com')

        expected = {
            'ldap': {
                'ldap/group-a': [
                    auth.Identity.from_bytes('user:[email protected]'),
                    auth.Identity.from_bytes('user:[email protected]')
                ],
                'ldap/group-b': [
                    auth.Identity.from_bytes('user:[email protected]'),
                    auth.Identity.from_bytes('user:[email protected]')
                ],
            }
        }
        self.assertEqual(expected, result)
示例#4
0
  def test_load_tarball(self):
    bundle = build_tar_gz({
      'at_root': 'a\nb',
      'ldap/ bad name': 'a\nb',
      'ldap/group-a': 'a\nb',
      'ldap/group-b': 'a\nb',
      'ldap/group-c': 'a\nb',
      'ldap/deeper/group-a': 'a\nb',
      'not-ldap/group-a': 'a\nb',
    })
    result = importer.load_tarball(
        content=bundle,
        systems=['ldap'],
        groups=['ldap/group-a', 'ldap/group-b'],
        domain='example.com')

    expected = {
      'ldap': {
        'ldap/group-a': [
          auth.Identity.from_bytes('user:[email protected]'),
          auth.Identity.from_bytes('user:[email protected]')
        ],
        'ldap/group-b': [
          auth.Identity.from_bytes('user:[email protected]'),
          auth.Identity.from_bytes('user:[email protected]')
        ],
      }
    }
    self.assertEqual(expected, result)