def test_add_token(self): grant = Grant() grant.update(ATR) assert len(grant.tokens) == 1 token = grant.tokens[0] assert token.access_token == "2YotnFZFEjr1zCsicMWpAA" assert token.token_type == "example" assert token.refresh_token == "tGzv3JOkF0XG5Qx2TlKWIA"
def test_expiration_time(self): grant = Grant() assert grant.exp_in == 600 assert grant.grant_expiration_time == 0 grant = Grant(60) assert grant.exp_in == 60 grant = Grant(-1, AR) assert grant.grant_expiration_time != 0 assert not grant.is_valid()
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) != ""
def test_update_with_error_resp(self): err = ErrorResponse(error="invalid_request") grant = Grant() grant.update(err) assert len(grant.tokens) == 0
def test_set(self): grant = Grant.from_code(AR) assert grant.code == "code"
def test_update(self): grant = Grant() grant.update(AR) assert grant.code == "code"
def test_add_code(self): grant = Grant() grant.add_code(AR) assert grant.code == "code"
def test_from_code(self): grant = Grant.from_code(AR) assert grant.code == "code" assert grant.grant_expiration_time != 0