Beispiel #1
0
 def test_basic_auth_invalid(self):
     eb = EnvironBuilder(headers={"Authorization": "Basic notbase64"})
     m = BasicAuthMethod(eb.get_request())
     m.check() |should_be.equal_to| True
     InvalidAuthException |should_be.thrown_by| (lambda: m.get_user(t.FakeAuthBackend()))
Beispiel #2
0
 def test_basic_auth_miss(self):
     eb = EnvironBuilder(headers={"Authorization": "Notbasic"})
     m = BasicAuthMethod(eb.get_request())
     m.check() |should_be.equal_to| False
Beispiel #3
0
 def test_basic_auth_valid(self):
     eb = EnvironBuilder(headers={"Authorization": "Basic "+b64encode("usr:pwd")})
     m = BasicAuthMethod(eb.get_request())
     m.check() |should_be.equal_to| True
     m.get_user(t.FakeAuthBackend()) |should_be.equal_to| {"username": "******", "password": "******"}