def test_header(self):
        parser = self.parser
        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_default')
        self.assertEqual(hdr.header, 'REMOTE_USER')
        self.assertEqual(hdr.value, None)

        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_other')
        self.assertEqual(hdr.header, 'GSSAPI')
        self.assertEqual(hdr.value, None)

        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_value')
        self.assertEqual(hdr.header, 'GSSAPI')
        self.assertEqual(hdr.value, {'admin'})

        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_values')
        self.assertEqual(hdr.header, 'GSSAPI')
        self.assertEqual(hdr.value, {'admin', 'user'})
Exemple #2
0
    def test_header(self):
        parser = self.parser
        gssapi = 'GSSAPI'
        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_default')
        self.assertEqual(hdr.header, 'REMOTE_USER')
        self.assertEqual(hdr.value, None)
        self.assertHeaderMatch(hdr, 'REMOTE_USER', None, 0)

        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_other')
        self.assertEqual(hdr.header, 'GSSAPI')
        self.assertEqual(hdr.value, None)
        self.assertHeaderMatch(hdr, gssapi, None, 0)

        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_value')
        self.assertEqual(hdr.header, 'GSSAPI')
        self.assertEqual(hdr.value, {'admin'})
        self.assertHeaderMatch(hdr, gssapi, 'admin', 0)
        self.assertHeaderMismatch(hdr, gssapi, 'invalid_rule', 0)

        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_values')
        self.assertEqual(hdr.header, 'GSSAPI')
        self.assertEqual(hdr.value, {'admin', 'user'})

        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_commaspace')
        self.assertEqual(hdr.value, {'admin', 'user', 'space user'})

        hdr = authenticators.SimpleHeaderAuth(parser, 'auth:header_comma')
        self.assertEqual(hdr.value, {'admin', 'user', 'other user'})