Example #1
0
 def test_reseller_prefix_init(self):
     app = FakeApp()
     ath = auth.filter_factory({})(app)
     self.assertEquals(ath.reseller_prefix, 'AUTH_')
     ath = auth.filter_factory({'reseller_prefix': 'TEST'})(app)
     self.assertEquals(ath.reseller_prefix, 'TEST_')
     ath = auth.filter_factory({'reseller_prefix': 'TEST_'})(app)
     self.assertEquals(ath.reseller_prefix, 'TEST_')
Example #2
0
 def test_reseller_prefix_init(self):
     app = FakeApp()
     ath = auth.filter_factory({})(app)
     self.assertEquals(ath.reseller_prefix, 'AUTH_')
     ath = auth.filter_factory({'reseller_prefix': 'TEST'})(app)
     self.assertEquals(ath.reseller_prefix, 'TEST_')
     ath = auth.filter_factory({'reseller_prefix': 'TEST_'})(app)
     self.assertEquals(ath.reseller_prefix, 'TEST_')
Example #3
0
 def test_no_ext_authentication_url(self):
     app = FakeApp()
     try:
         # Use original auth.filter_factory and NOT monkey patched version
         unpatch_filter_factory()
         auth.filter_factory({})(app)
     except RuntimeError as e:
         # Restore monkey patched version
         patch_filter_factory()
         self.assertTrue(e.args[0].startswith("Missing filter parameter "
                                              "ext_authentication_url"))
Example #4
0
 def test_no_ext_authentication_url(self):
     app = FakeApp()
     try:
         # Use original auth.filter_factory and NOT monkey patched version
         unpatch_filter_factory()
         auth.filter_factory({})(app)
     except RuntimeError as e:
         # Restore monkey patched version
         patch_filter_factory()
         self.assertTrue(e.args[0].startswith("Missing filter parameter "
                                              "ext_authentication_url"))
Example #5
0
 def test_override_asked_for_and_allowed(self):
     self.test_auth = \
         auth.filter_factory({'allow_overrides': 'true'})(FakeApp())
     req = self._make_request('/v1/AUTH_account',
                              environ={'swift.authorize_override': True})
     resp = req.get_response(self.test_auth)
     self.assertEquals(resp.status_int, 404)
     self.assertTrue('swift.authorize' not in req.environ)
Example #6
0
 def test_override_asked_for_and_allowed(self):
     self.test_auth = \
         auth.filter_factory({'allow_overrides': 'true'})(FakeApp())
     req = self._make_request('/v1/AUTH_account',
                              environ={'swift.authorize_override': True})
     resp = req.get_response(self.test_auth)
     self.assertEquals(resp.status_int, 404)
     self.assertTrue('swift.authorize' not in req.environ)
Example #7
0
 def test_auth_prefix_init(self):
     app = FakeApp()
     ath = auth.filter_factory({})(app)
     self.assertEquals(ath.auth_prefix, '/auth/')
     ath = auth.filter_factory({'auth_prefix': ''})(app)
     self.assertEquals(ath.auth_prefix, '/auth/')
     ath = auth.filter_factory({'auth_prefix': '/'})(app)
     self.assertEquals(ath.auth_prefix, '/auth/')
     ath = auth.filter_factory({'auth_prefix': '/test/'})(app)
     self.assertEquals(ath.auth_prefix, '/test/')
     ath = auth.filter_factory({'auth_prefix': '/test'})(app)
     self.assertEquals(ath.auth_prefix, '/test/')
     ath = auth.filter_factory({'auth_prefix': 'test/'})(app)
     self.assertEquals(ath.auth_prefix, '/test/')
     ath = auth.filter_factory({'auth_prefix': 'test'})(app)
     self.assertEquals(ath.auth_prefix, '/test/')
Example #8
0
 def test_auth_prefix_init(self):
     app = FakeApp()
     ath = auth.filter_factory({})(app)
     self.assertEquals(ath.auth_prefix, '/auth/')
     ath = auth.filter_factory({'auth_prefix': ''})(app)
     self.assertEquals(ath.auth_prefix, '/auth/')
     ath = auth.filter_factory({'auth_prefix': '/'})(app)
     self.assertEquals(ath.auth_prefix, '/auth/')
     ath = auth.filter_factory({'auth_prefix': '/test/'})(app)
     self.assertEquals(ath.auth_prefix, '/test/')
     ath = auth.filter_factory({'auth_prefix': '/test'})(app)
     self.assertEquals(ath.auth_prefix, '/test/')
     ath = auth.filter_factory({'auth_prefix': 'test/'})(app)
     self.assertEquals(ath.auth_prefix, '/test/')
     ath = auth.filter_factory({'auth_prefix': 'test'})(app)
     self.assertEquals(ath.auth_prefix, '/test/')
Example #9
0
 def test_passive_handle_get_token_kinit_realm_and_memcache(self):
     req = self._make_request('/auth/v1.0',
                              headers={'X-Auth-User': '******',
                                       'X-Auth-Key': 'password'})
     req.environ['swift.cache'] = None
     _auth_passive = \
         auth.filter_factory({'auth_method': 'passive',
                             'realm_name': 'EXAMPLE.COM'})(FakeApp())
     _mock_run_kinit = Mock(return_value=0)
     _mock_get_groups = Mock(return_value="user,auth_test")
     with patch('swiftkerbauth.kerbauth.run_kinit', _mock_run_kinit):
         with patch('swiftkerbauth.kerbauth.get_groups_from_username',
                    _mock_get_groups):
                 try:
                     _auth_passive.handle_get_token(req)
                 except Exception as e:
                     self.assertTrue(e.args[0].startswith("Memcache "
                                                          "required"))
                 else:
                     self.fail("Expected Exception - Memcache required")
     _mock_run_kinit.assert_called_once_with('*****@*****.**', 'password')
     _mock_get_groups.assert_called_once_with('user')
Example #10
0
 def test_passive_handle_get_token_kinit_realm_and_memcache(self):
     req = self._make_request('/auth/v1.0',
                              headers={
                                  'X-Auth-User': '******',
                                  'X-Auth-Key': 'password'
                              })
     req.environ['swift.cache'] = None
     _auth_passive = \
         auth.filter_factory({'auth_method': 'passive',
                             'realm_name': 'EXAMPLE.COM'})(FakeApp())
     _mock_run_kinit = Mock(return_value=0)
     _mock_get_groups = Mock(return_value="user,auth_test")
     with patch('swiftkerbauth.kerbauth.run_kinit', _mock_run_kinit):
         with patch('swiftkerbauth.kerbauth.get_groups_from_username',
                    _mock_get_groups):
             try:
                 _auth_passive.handle_get_token(req)
             except Exception as e:
                 self.assertTrue(e.args[0].startswith("Memcache "
                                                      "required"))
             else:
                 self.fail("Expected Exception - Memcache required")
     _mock_run_kinit.assert_called_once_with('*****@*****.**', 'password')
     _mock_get_groups.assert_called_once_with('user')
Example #11
0
 def setUp(self):
     self.test_auth = \
         auth.filter_factory({'auth_method': 'active'})(FakeApp())
     self.test_auth_passive = \
         auth.filter_factory({'auth_method': 'passive'})(FakeApp())
Example #12
0
 def setUp(self):
     self.test_auth = \
         auth.filter_factory({'auth_method': 'active'})(FakeApp())
     self.test_auth_passive = \
         auth.filter_factory({'auth_method': 'passive'})(FakeApp())
Example #13
0
 def setUp(self):
     self.test_auth = auth.filter_factory({})(FakeApp())