-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate DB models for credentials (#1143)
- Loading branch information
Showing
102 changed files
with
4,893 additions
and
2,949 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
api_sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,21 @@ | ||
import requests | ||
from contextlib import contextmanager | ||
|
||
try: | ||
# in-IDE | ||
import api_sdk.openapi_client as sdk | ||
except ImportError: | ||
import openapi_client as sdk | ||
|
||
@contextmanager | ||
def api_admin_session(url): | ||
session = requests.Session() | ||
session.verify = False | ||
response = session.post( | ||
f"{url}/@warpgate/api/auth/login", | ||
json={ | ||
"username": "admin", | ||
"password": "123", | ||
}, | ||
) | ||
assert response.status_code // 100 == 2 | ||
yield session | ||
|
||
|
||
def assert_response(response, code): | ||
if response.status_code != code: | ||
print(response.text) | ||
assert response.status_code == code | ||
|
||
|
||
def api_list_users(url, session): | ||
response = session.get( | ||
f"{url}/@warpgate/admin/api/users", | ||
) | ||
assert_response(response, 200) | ||
return response.json() | ||
|
||
|
||
def api_create_target(url, session, config): | ||
response = session.post( | ||
f"{url}/@warpgate/admin/api/targets", | ||
json=config, | ||
) | ||
assert_response(response, 201) | ||
return response.json() | ||
|
||
|
||
def api_create_role(url, session, config): | ||
response = session.post( | ||
f"{url}/@warpgate/admin/api/roles", | ||
json=config, | ||
) | ||
assert_response(response, 201) | ||
return response.json() | ||
|
||
|
||
def api_create_user(url, session, config): | ||
response = session.post( | ||
f"{url}/@warpgate/admin/api/users", | ||
json=config, | ||
) | ||
assert_response(response, 201) | ||
return response.json() | ||
|
||
|
||
def api_add_role_to_target(url, session, target_id, role_id): | ||
response = session.post( | ||
f"{url}/@warpgate/admin/api/targets/{target_id}/roles/{role_id}", | ||
) | ||
assert_response(response, 201) | ||
|
||
|
||
def api_add_role_to_user(url, session, user_id, role_id): | ||
response = session.post( | ||
f"{url}/@warpgate/admin/api/users/{user_id}/roles/{role_id}", | ||
) | ||
assert_response(response, 201) | ||
|
||
|
||
def api_create_ticket(url, session, username, target_name): | ||
response = session.post( | ||
f"{url}/@warpgate/api/auth/login", | ||
json={ | ||
"username": "admin", | ||
"password": "123", | ||
}, | ||
) | ||
assert response.status_code // 100 == 2 | ||
response = session.post( | ||
f"{url}/@warpgate/admin/api/tickets", | ||
json={ | ||
"username": username, | ||
"target_name": target_name, | ||
@contextmanager | ||
def admin_client(host): | ||
config = sdk.Configuration( | ||
host=f"{host}/@warpgate/admin/api", | ||
api_key={ | ||
"TokenSecurityScheme": "token-value", | ||
}, | ||
) | ||
assert response.status_code == 201 | ||
return response.json()["secret"] | ||
config.verify_ssl = False | ||
with sdk.ApiClient(config) as api_client: | ||
yield sdk.DefaultApi(api_client) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.