예제 #1
0
def test_bearer_header_with_http_args():
    client = Client("A")
    client.client_secret = "boarding pass"

    request_args = {"access_token": "Sesame"}

    cis = ResourceRequest()

    bh = BearerHeader(client)
    http_args = bh.construct(cis, request_args, http_args={"foo": "bar"})

    print cis
    print http_args
    assert _eq(http_args.keys(), ["foo", "headers"])
    assert http_args["headers"] == {"Authorization": "Bearer Sesame"}

    # -----------------

    request_args = {"access_token": "Sesame"}

    bh = BearerHeader(client)
    http_args = bh.construct(cis, request_args,
                             http_args={"headers": {"x-foo": "bar"}})

    print cis
    print http_args
    assert _eq(http_args.keys(), ["headers"])
    assert _eq(http_args["headers"].keys(), ["Authorization", "x-foo"])
    assert http_args["headers"]["Authorization"] == "Bearer Sesame"
예제 #2
0
    def test_construct_with_resource_request(self, client):
        bh = BearerHeader(client)
        cis = ResourceRequest(access_token="Sesame")

        http_args = bh.construct(cis)

        assert "access_token" not in cis
        assert http_args == {"headers": {"Authorization": "Bearer Sesame"}}
예제 #3
0
    def test_construct_with_http_args(self, client):
        request_args = {"access_token": "Sesame"}
        bh = BearerHeader(client)
        http_args = bh.construct(request_args=request_args,
                                 http_args={"foo": "bar"})

        assert _eq(http_args.keys(), ["foo", "headers"])
        assert http_args["headers"] == {"Authorization": "Bearer Sesame"}
예제 #4
0
    def test_construct_with_resource_request(self, client):
        bh = BearerHeader(client)
        cis = ResourceRequest(access_token="Sesame")

        http_args = bh.construct(cis)

        assert "access_token" not in cis
        assert http_args == {"headers": {"Authorization": "Bearer Sesame"}}
예제 #5
0
    def test_construct_with_http_args(self, client):
        request_args = {"access_token": "Sesame"}
        bh = BearerHeader(client)
        http_args = bh.construct(request_args=request_args,
                                 http_args={"foo": "bar"})

        assert _eq(http_args.keys(), ["foo", "headers"])
        assert http_args["headers"] == {"Authorization": "Bearer Sesame"}
예제 #6
0
def test_bearer_header_2():
    client = Client("A")
    client.client_secret = "boarding pass"

    bh = BearerHeader(client)
    cis = ResourceRequest(access_token="Sesame")

    http_args = bh.construct(cis)

    print cis
    assert "access_token" not in cis
    print http_args
    assert http_args == {"headers": {"Authorization": "Bearer Sesame"}}
예제 #7
0
def test_bearer_header_2():
    client = Client("A")
    client.client_secret = "boarding pass"

    bh = BearerHeader(client)
    cis = ResourceRequest(access_token="Sesame")

    http_args = bh.construct(cis)

    print cis
    assert "access_token" not in cis
    print http_args
    assert http_args == {"headers": {"Authorization": "Bearer Sesame"}}
예제 #8
0
def test_bearer_header_with_http_args():
    client = Client("A")
    client.client_secret = "boarding pass"

    request_args = {"access_token": "Sesame"}

    cis = ResourceRequest()

    bh = BearerHeader(client)
    http_args = bh.construct(cis, request_args, http_args={"foo": "bar"})

    print cis
    print http_args
    assert _eq(http_args.keys(), ["foo", "headers"])
    assert http_args["headers"] == {"Authorization": "Bearer Sesame"}

    # -----------------

    request_args = {"access_token": "Sesame"}

    bh = BearerHeader(client)
    http_args = bh.construct(cis,
                             request_args,
                             http_args={"headers": {
                                 "x-foo": "bar"
                             }})

    print cis
    print http_args
    assert _eq(http_args.keys(), ["headers"])
    assert _eq(http_args["headers"].keys(), ["Authorization", "x-foo"])
    assert http_args["headers"]["Authorization"] == "Bearer Sesame"
예제 #9
0
    def test_construct_with_token(self, client):
        resp1 = AuthorizationResponse(code="auth_grant", state="state")
        client.parse_response(AuthorizationResponse, resp1.to_urlencoded(),
                              "urlencoded")
        resp2 = AccessTokenResponse(access_token="token1",
                                    token_type="Bearer", expires_in=0,
                                    state="state")
        client.parse_response(AccessTokenResponse, resp2.to_urlencoded(),
                              "urlencoded")

        http_args = BearerHeader(client).construct(ResourceRequest(),
                                                   state="state")
        assert http_args == {"headers": {"Authorization": "Bearer token1"}}
예제 #10
0
파일: clrp.py 프로젝트: simudream/oictest
def get_claims(client):
    resp = {}
    for src in client.userinfo["_claim_names"].values():
        spec = client.userinfo["_claim_sources"][src]
        ht_args = BearerHeader(client).construct(**spec)

        try:
            part = client.http_request(spec["endpoint"], "GET", **ht_args)
        except Exception:
            raise
        resp.update(json.loads(part.content))

    return resp
예제 #11
0
def test_bearer_header_3():
    client = Client("A")
    client.client_secret = "boarding pass"

    resp1 = AuthorizationResponse(code="auth_grant", state="state")
    client.parse_response(AuthorizationResponse, resp1.to_urlencoded(),
                          "urlencoded")
    resp2 = AccessTokenResponse(access_token="token1",
                                token_type="Bearer", expires_in=0,
                                state="state")
    client.parse_response(AccessTokenResponse, resp2.to_urlencoded(),
                          "urlencoded")

    cis = ResourceRequest()

    http_args = BearerHeader(client).construct(cis, state="state")

    print cis
    assert "access_token" not in cis
    print http_args
    assert http_args == {"headers": {"Authorization": "Bearer token1"}}
예제 #12
0
    def test_construct(self, client):
        request_args = {"access_token": "Sesame"}
        bh = BearerHeader(client)
        http_args = bh.construct(request_args=request_args)

        assert http_args == {"headers": {"Authorization": "Bearer Sesame"}}
예제 #13
0
    def test_construct(self, client):
        request_args = {"access_token": "Sesame"}
        bh = BearerHeader(client)
        http_args = bh.construct(request_args=request_args)

        assert http_args == {"headers": {"Authorization": "Bearer Sesame"}}