Ejemplo n.º 1
0
    def test_authenticated_as(self, srv):
        form = create_return_form_env("user", "hemligt", "QUERY")

        authn = UsernamePasswordMako(srv, "login.mako", tl, PASSWD,
                                     "authorization_endpoint")
        response, success = authn.verify(parse_qs(form))

        headers = dict(response.headers)
        user, timestamp = authn.authenticated_as(headers["Set-Cookie"])
        assert user == {"uid": "user"}
Ejemplo n.º 2
0
    def test_authenticated_as(self, srv):
        form = create_return_form_env("user", "hemligt", "QUERY")

        authn = UsernamePasswordMako(srv, "login.mako", tl, PASSWD,
                                     "authorization_endpoint")
        response, success = authn.verify(compact(parse_qs(form)))

        headers = dict(response.headers)
        user, timestamp = authn.authenticated_as(headers["Set-Cookie"])
        assert user == {"uid": "user"}
Ejemplo n.º 3
0
    def test_not_authenticated(self, srv):
        form = create_return_form_env("user", "hemligt", "QUERY")

        authn = UsernamePasswordMako(srv, "login.mako", tl, PASSWD,
                                     "authorization_endpoint")
        response, state = authn.verify(parse_qs(form))

        headers = dict(response.headers)
        kaka = headers["Set-Cookie"]

        kaka = kaka.replace("1", "x")
        assert authn.authenticated_as(kaka) == (None, 0)
Ejemplo n.º 4
0
    def test_not_authenticated(self, srv):
        form = create_return_form_env("user", "hemligt", "QUERY")

        authn = UsernamePasswordMako(srv, "login.mako", tl, PASSWD,
                                     "authorization_endpoint")
        response, state = authn.verify(compact(parse_qs(form)))

        headers = dict(response.headers)
        kaka = headers["Set-Cookie"]

        kaka = kaka.replace("1", "x")
        assert authn.authenticated_as(kaka) == (None, 0)
Ejemplo n.º 5
0
def test_5():
    form = create_return_form_env("user", "hemligt", "QUERY")
    srv = SRV()
    srv.symkey = rndstr(16)
    srv.seed = rndstr()
    srv.iv = os.urandom(16)
    srv.cookie_name = "xyzxyz"

    authn = UsernamePasswordMako(srv, "login.mako", tl, PASSWD,
                                 "authorization_endpoint")
    response = authn.verify(parse_qs(form))

    kaka = ""
    for param, val in response.headers:
        if param == "Set-Cookie":
            kaka = val
            break

    kaka = kaka.replace("1", "x")
    try:
        _ = authn.authenticated_as(kaka)
        assert False
    except Exception:
        assert True
Ejemplo n.º 6
0
 def test_authenticated_as_no_cookie(self):
     authn = UsernamePasswordMako(None, "login.mako", tl, PASSWD,
                                  "authorization_endpoint")
     res = authn.authenticated_as()
     assert res == (None, 0)
Ejemplo n.º 7
0
def test_1():
    authn = UsernamePasswordMako(None, "login.mako", tl, PASSWD,
                                 "authorization_endpoint")
    assert authn.authenticated_as() is None
Ejemplo n.º 8
0
 def test_authenticated_as_no_cookie(self):
     authn = UsernamePasswordMako(None, "login.mako", tl, PASSWD,
                                  "authorization_endpoint")
     res = authn.authenticated_as()
     assert res == (None, 0)