mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-04 11:25:52 +08:00
72 lines
2.1 KiB
Python
72 lines
2.1 KiB
Python
import http
|
|
|
|
import requests
|
|
from wiremock.client import (
|
|
HttpMethods,
|
|
Mapping,
|
|
MappingRequest,
|
|
MappingResponse,
|
|
WireMockMatchers,
|
|
)
|
|
|
|
from fixtures.types import SigNoz
|
|
|
|
|
|
def test_apply_license(signoz: SigNoz, make_http_mocks, get_jwt_token) -> None:
|
|
make_http_mocks(
|
|
signoz.zeus,
|
|
[
|
|
Mapping(
|
|
request=MappingRequest(
|
|
method=HttpMethods.GET,
|
|
url="/v2/licenses/me",
|
|
headers={
|
|
"X-Signoz-Cloud-Api-Key": {
|
|
WireMockMatchers.EQUAL_TO: "secret-key"
|
|
}
|
|
},
|
|
),
|
|
response=MappingResponse(
|
|
status=200,
|
|
json_body={
|
|
"status": "success",
|
|
"data": {
|
|
"id": "0196360e-90cd-7a74-8313-1aa815ce2a67",
|
|
"key": "secret-key",
|
|
"valid_from": 1732146923,
|
|
"valid_until": -1,
|
|
"status": "VALID",
|
|
"state": "EVALUATING",
|
|
"plan": {
|
|
"name": "ENTERPRISE",
|
|
},
|
|
"platform": "CLOUD",
|
|
"features": [],
|
|
"event_queue": {},
|
|
},
|
|
},
|
|
),
|
|
persistent=False,
|
|
)
|
|
],
|
|
)
|
|
|
|
access_token = get_jwt_token("admin@integration.test", "password")
|
|
|
|
response = requests.post(
|
|
url=signoz.self.host_config.get("/api/v3/licenses"),
|
|
json={"key": "secret-key"},
|
|
headers={"Authorization": "Bearer " + access_token},
|
|
timeout=5,
|
|
)
|
|
|
|
assert response.status_code == http.HTTPStatus.ACCEPTED
|
|
|
|
response = requests.post(
|
|
url=signoz.zeus.host_config.get("/__admin/requests/count"),
|
|
json={"method": "GET", "url": "/v2/licenses/me"},
|
|
timeout=5,
|
|
)
|
|
|
|
assert response.json()["count"] >= 1
|