Esempio n. 1
0
def test_grant_access_token():
    resp = AuthorizationResponse(code="code", state="state")
    grant = Grant()
    grant.add_code(resp)

    atr = AccessTokenResponse(access_token="2YotnFZFEjr1zCsicMWpAA",
                              token_type="example",
                              refresh_token="tGzv3JOkF0XG5Qx2TlKWIA",
                              example_parameter="example_value",
                              scope=["inner", "outer"])

    grant.add_token(atr)
    assert len(grant.tokens) == 1
    token = grant.tokens[0]
    assert token.is_valid() is True

    assert str(grant) != ""
Esempio n. 2
0
    def test_construct_with_state(self, client):
        resp = AuthorizationResponse(code="code", state="state")
        grant = Grant()
        grant.add_code(resp)
        atr = AccessTokenResponse(access_token="2YotnFZFEjr1zCsicMWpAA",
                                  token_type="example",
                                  refresh_token="tGzv3JOkF0XG5Qx2TlKWIA",
                                  example_parameter="example_value",
                                  scope=["inner", "outer"])
        grant.add_token(atr)
        client.grant["state"] = grant

        cis = ResourceRequest()
        http_args = BearerBody(client).construct(cis, {}, state="state",
                                                 scope="inner")
        assert cis["access_token"] == "2YotnFZFEjr1zCsicMWpAA"
        assert http_args is None
Esempio n. 3
0
    def test_construct_with_state(self, client):
        resp = AuthorizationResponse(code="code", state="state")
        grant = Grant()
        grant.add_code(resp)
        atr = AccessTokenResponse(access_token="2YotnFZFEjr1zCsicMWpAA",
                                  token_type="example",
                                  refresh_token="tGzv3JOkF0XG5Qx2TlKWIA",
                                  example_parameter="example_value",
                                  scope=["inner", "outer"])
        grant.add_token(atr)
        client.grant["state"] = grant

        cis = ResourceRequest()
        http_args = BearerBody(client).construct(cis, {}, state="state",
                                                 scope="inner")
        assert cis["access_token"] == "2YotnFZFEjr1zCsicMWpAA"
        assert http_args is None
Esempio n. 4
0
 def test_add_code(self):
     grant = Grant()
     grant.add_code(AR)
     assert grant.code == "code"