Beispiel #1
0
 def test_http_with_strings_in_target(self, mock_urlopen):
     check = policy.HttpCheck('http', '//example.com/%(name)s')
     target = {'a': 'some_string',
               'name': 'target',
               'b': 'test data'}
     self.assertEqual(check(target,
                            dict(user='******', roles=['a', 'b', 'c']),
                            self.enforcer),
                      True)
Beispiel #2
0
    def test_accept(self, mock_urlopen):
        check = policy.HttpCheck('http', '//example.com/%(name)s')
        self.assertEqual(check(dict(name='target', spam='spammer'),
                               dict(user='******', roles=['a', 'b', 'c']),
                               self.enforcer),
                         True)
        self.assertEqual(mock_urlopen.call_count, 1)

        args = mock_urlopen.call_args[0]

        self.assertEqual(args[0], 'http://example.com/target')
        self.assertEqual(self.decode_post_data(args[1]), dict(
            target=dict(name='target', spam='spammer'),
            credentials=dict(user='******', roles=['a', 'b', 'c']),
        ))