mirror of
https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
synced 2024-12-27 16:08:55 +00:00
code styling
This commit is contained in:
parent
17978c2e2e
commit
9a5cf9ff81
28
test/main.py
28
test/main.py
@ -33,6 +33,12 @@ jwt_encode_key = jwk.construct(INSTANCE_KEY_RSA.export_key().decode('utf-8'), al
|
||||
jwt_decode_key = jwk.construct(INSTANCE_KEY_PUB.export_key().decode('utf-8'), algorithm=ALGORITHMS.RS256)
|
||||
|
||||
|
||||
def __bearer_token(origin_ref: str) -> str:
|
||||
token = jwt.encode({"origin_ref": origin_ref}, key=jwt_encode_key, algorithm=ALGORITHMS.RS256)
|
||||
token = f'Bearer {token}'
|
||||
return token
|
||||
|
||||
|
||||
def test_index():
|
||||
response = client.get('/')
|
||||
assert response.status_code == 200
|
||||
@ -175,9 +181,7 @@ def test_leasing_v1_lessor():
|
||||
'scope_ref_list': [LEASE_REF]
|
||||
}
|
||||
|
||||
bearer_token = jwt.encode({"origin_ref": ORIGIN_REF}, key=jwt_encode_key, algorithm=ALGORITHMS.RS256)
|
||||
bearer_token = f'Bearer {bearer_token}'
|
||||
response = client.post('/leasing/v1/lessor', json=payload, headers={'authorization': bearer_token})
|
||||
response = client.post('/leasing/v1/lessor', json=payload, headers={'authorization': __bearer_token(ORIGIN_REF)})
|
||||
assert response.status_code == 200
|
||||
|
||||
lease_result_list = response.json()['lease_result_list']
|
||||
@ -186,9 +190,7 @@ def test_leasing_v1_lessor():
|
||||
|
||||
|
||||
def test_leasing_v1_lessor_lease():
|
||||
bearer_token = jwt.encode({"origin_ref": ORIGIN_REF}, key=jwt_encode_key, algorithm=ALGORITHMS.RS256)
|
||||
bearer_token = f'Bearer {bearer_token}'
|
||||
response = client.get('/leasing/v1/lessor/leases', headers={'authorization': bearer_token})
|
||||
response = client.get('/leasing/v1/lessor/leases', headers={'authorization': __bearer_token(ORIGIN_REF)})
|
||||
assert response.status_code == 200
|
||||
|
||||
active_lease_list = response.json()['active_lease_list']
|
||||
@ -197,18 +199,14 @@ def test_leasing_v1_lessor_lease():
|
||||
|
||||
|
||||
def test_leasing_v1_lease_renew():
|
||||
bearer_token = jwt.encode({"origin_ref": ORIGIN_REF}, key=jwt_encode_key, algorithm=ALGORITHMS.RS256)
|
||||
bearer_token = f'Bearer {bearer_token}'
|
||||
response = client.put(f'/leasing/v1/lease/{LEASE_REF}', headers={'authorization': bearer_token})
|
||||
response = client.put(f'/leasing/v1/lease/{LEASE_REF}', headers={'authorization': __bearer_token(ORIGIN_REF)})
|
||||
assert response.status_code == 200
|
||||
|
||||
assert response.json()['lease_ref'] == LEASE_REF
|
||||
|
||||
|
||||
def test_leasing_v1_lease_delete():
|
||||
bearer_token = jwt.encode({"origin_ref": ORIGIN_REF}, key=jwt_encode_key, algorithm=ALGORITHMS.RS256)
|
||||
bearer_token = f'Bearer {bearer_token}'
|
||||
response = client.delete(f'/leasing/v1/lease/{LEASE_REF}', headers={'authorization': bearer_token})
|
||||
response = client.delete(f'/leasing/v1/lease/{LEASE_REF}', headers={'authorization': __bearer_token(ORIGIN_REF)})
|
||||
assert response.status_code == 200
|
||||
|
||||
assert response.json()['lease_ref'] == LEASE_REF
|
||||
@ -216,10 +214,8 @@ def test_leasing_v1_lease_delete():
|
||||
|
||||
def test_leasing_v1_lessor_lease_remove():
|
||||
test_leasing_v1_lessor()
|
||||
|
||||
bearer_token = jwt.encode({"origin_ref": ORIGIN_REF}, key=jwt_encode_key, algorithm=ALGORITHMS.RS256)
|
||||
bearer_token = f'Bearer {bearer_token}'
|
||||
response = client.delete('/leasing/v1/lessor/leases', headers={'authorization': bearer_token})
|
||||
|
||||
response = client.delete('/leasing/v1/lessor/leases', headers={'authorization': __bearer_token(ORIGIN_REF)})
|
||||
assert response.status_code == 200
|
||||
|
||||
released_lease_list = response.json()['released_lease_list']
|
||||
|
Loading…
Reference in New Issue
Block a user