comment out WIP tests and update report naming

This commit is contained in:
burnettk 2022-07-09 11:11:05 -04:00
parent d19a8acd63
commit 15866e2297
4 changed files with 116 additions and 116 deletions

View File

@ -482,7 +482,7 @@ paths:
schema:
type: integer
get:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_report
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_report_show
summary: Returns a report of process instances for a given process model
tags:
- Process Instances

View File

@ -395,7 +395,7 @@ def process_instance_delete(
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def process_instance_report(
def process_instance_report_show(
process_group_id: str, process_model_id: str, page: int = 1, per_page: int = 100
) -> flask.wrappers.Response:
"""Process_instance_list."""

View File

@ -1,112 +1,112 @@
"""Test_authentication."""
from keycloak.authorization import Authorization # type: ignore
from keycloak.keycloak_openid import KeycloakOpenID # type: ignore
from keycloak.uma_permissions import AuthStatus # type: ignore
from spiffworkflow_backend.services.authentication_service import AuthenticationService
server_url = "http://localhost:8080/"
client_id = "bank-api"
realm_name = "stackoverflow-demo"
client_secret_key = "seciKpRanUReL0ksZaFm5nfjhMUKHVAO" # noqa: S105
user = "bob"
password = "LetMeIn" # noqa: S105
resource = "View Account Resource"
scope = "account:view"
def test_get_keycloak_openid_client() -> None:
"""Test_get_keycloak_openid_client."""
keycloak_openid_client = AuthenticationService.get_keycloak_openid(
server_url, client_id, realm_name, client_secret_key
)
assert isinstance(keycloak_openid_client, KeycloakOpenID)
assert isinstance(keycloak_openid_client.authorization, Authorization)
def test_get_keycloak_token() -> None:
"""Test_get_keycloak_token."""
keycloak_openid = AuthenticationService.get_keycloak_openid(
server_url, client_id, realm_name, client_secret_key
)
token = keycloak_openid.token(user, password)
assert isinstance(token, dict)
assert isinstance(token["access_token"], str)
assert isinstance(token["refresh_token"], str)
assert token["expires_in"] == 300
assert token["refresh_expires_in"] == 1800
assert token["token_type"] == "Bearer"
def test_get_permission_by_token() -> None:
"""Test_get_permission_by_token."""
keycloak_openid = AuthenticationService.get_keycloak_openid(
server_url, client_id, realm_name, client_secret_key
)
keycloak_openid.load_authorization_config(
"tests/spiffworkflow_backend/integration/bank-api-authz-config.json"
)
token = keycloak_openid.token(user, password)
permissions = AuthenticationService.get_permission_by_token(keycloak_openid, token)
# TODO: permissions comes back as None. Is this right?
print(f"test_get_permission_by_token: {permissions}")
def test_get_uma_permissions_by_token() -> None:
"""Test_get_uma_permissions_by_token."""
keycloak_openid = AuthenticationService.get_keycloak_openid(
server_url, client_id, realm_name, client_secret_key
)
token = keycloak_openid.token(user, password)
uma_permissions = AuthenticationService.get_uma_permissions_by_token(
keycloak_openid, token
)
assert isinstance(uma_permissions, list)
assert len(uma_permissions) == 2
for permission in uma_permissions:
assert "rsname" in permission
if permission["rsname"] == "View Account Resource":
assert "scopes" in permission
assert isinstance(permission["scopes"], list)
assert len(permission["scopes"]) == 1
assert permission["scopes"][0] == "account:view"
def test_get_uma_permissions_by_token_for_resource_and_scope() -> None:
"""Test_get_uma_permissions_by_token_for_resource_and_scope."""
keycloak_openid = AuthenticationService.get_keycloak_openid(
server_url, client_id, realm_name, client_secret_key
)
token = keycloak_openid.token(user, password)
permissions = (
AuthenticationService.get_uma_permissions_by_token_for_resource_and_scope(
keycloak_openid, token, resource, scope
)
)
assert isinstance(permissions, list)
assert len(permissions) == 1
assert isinstance(permissions[0], dict)
permission = permissions[0]
assert "rsname" in permission
assert permission["rsname"] == resource
assert "scopes" in permission
assert isinstance(permission["scopes"], list)
assert len(permission["scopes"]) == 1
assert permission["scopes"][0] == scope
def test_get_auth_status_for_resource_and_scope_by_token() -> None:
"""Test_get_auth_status_for_resource_and_scope_by_token."""
keycloak_openid = AuthenticationService.get_keycloak_openid(
server_url, client_id, realm_name, client_secret_key
)
token = keycloak_openid.token(user, password)
auth_status = AuthenticationService.get_auth_status_for_resource_and_scope_by_token(
keycloak_openid, token, resource, scope
)
assert isinstance(auth_status, AuthStatus)
assert auth_status.is_logged_in is True
assert auth_status.is_authorized is True
# """Test_authentication."""
# from keycloak.authorization import Authorization # type: ignore
# from keycloak.keycloak_openid import KeycloakOpenID # type: ignore
# from keycloak.uma_permissions import AuthStatus # type: ignore
#
# from spiffworkflow_backend.services.authentication_service import AuthenticationService
#
# server_url = "http://localhost:8080/"
# client_id = "bank-api"
# realm_name = "stackoverflow-demo"
# client_secret_key = "seciKpRanUReL0ksZaFm5nfjhMUKHVAO" # noqa: S105
#
# user = "bob"
# password = "LetMeIn" # noqa: S105
#
# resource = "View Account Resource"
# scope = "account:view"
#
#
# def test_get_keycloak_openid_client() -> None:
# """Test_get_keycloak_openid_client."""
# keycloak_openid_client = AuthenticationService.get_keycloak_openid(
# server_url, client_id, realm_name, client_secret_key
# )
# assert isinstance(keycloak_openid_client, KeycloakOpenID)
# assert isinstance(keycloak_openid_client.authorization, Authorization)
#
#
# def test_get_keycloak_token() -> None:
# """Test_get_keycloak_token."""
# keycloak_openid = AuthenticationService.get_keycloak_openid(
# server_url, client_id, realm_name, client_secret_key
# )
# token = keycloak_openid.token(user, password)
# assert isinstance(token, dict)
# assert isinstance(token["access_token"], str)
# assert isinstance(token["refresh_token"], str)
# assert token["expires_in"] == 300
# assert token["refresh_expires_in"] == 1800
# assert token["token_type"] == "Bearer"
#
#
# def test_get_permission_by_token() -> None:
# """Test_get_permission_by_token."""
# keycloak_openid = AuthenticationService.get_keycloak_openid(
# server_url, client_id, realm_name, client_secret_key
# )
# keycloak_openid.load_authorization_config(
# "tests/spiffworkflow_backend/integration/bank-api-authz-config.json"
# )
# token = keycloak_openid.token(user, password)
#
# permissions = AuthenticationService.get_permission_by_token(keycloak_openid, token)
# # TODO: permissions comes back as None. Is this right?
# print(f"test_get_permission_by_token: {permissions}")
#
#
# def test_get_uma_permissions_by_token() -> None:
# """Test_get_uma_permissions_by_token."""
# keycloak_openid = AuthenticationService.get_keycloak_openid(
# server_url, client_id, realm_name, client_secret_key
# )
# token = keycloak_openid.token(user, password)
# uma_permissions = AuthenticationService.get_uma_permissions_by_token(
# keycloak_openid, token
# )
# assert isinstance(uma_permissions, list)
# assert len(uma_permissions) == 2
# for permission in uma_permissions:
# assert "rsname" in permission
# if permission["rsname"] == "View Account Resource":
# assert "scopes" in permission
# assert isinstance(permission["scopes"], list)
# assert len(permission["scopes"]) == 1
# assert permission["scopes"][0] == "account:view"
#
#
# def test_get_uma_permissions_by_token_for_resource_and_scope() -> None:
# """Test_get_uma_permissions_by_token_for_resource_and_scope."""
# keycloak_openid = AuthenticationService.get_keycloak_openid(
# server_url, client_id, realm_name, client_secret_key
# )
# token = keycloak_openid.token(user, password)
# permissions = (
# AuthenticationService.get_uma_permissions_by_token_for_resource_and_scope(
# keycloak_openid, token, resource, scope
# )
# )
# assert isinstance(permissions, list)
# assert len(permissions) == 1
# assert isinstance(permissions[0], dict)
# permission = permissions[0]
# assert "rsname" in permission
# assert permission["rsname"] == resource
# assert "scopes" in permission
# assert isinstance(permission["scopes"], list)
# assert len(permission["scopes"]) == 1
# assert permission["scopes"][0] == scope
#
#
# def test_get_auth_status_for_resource_and_scope_by_token() -> None:
# """Test_get_auth_status_for_resource_and_scope_by_token."""
# keycloak_openid = AuthenticationService.get_keycloak_openid(
# server_url, client_id, realm_name, client_secret_key
# )
# token = keycloak_openid.token(user, password)
# auth_status = AuthenticationService.get_auth_status_for_resource_and_scope_by_token(
# keycloak_openid, token, resource, scope
# )
# assert isinstance(auth_status, AuthStatus)
# assert auth_status.is_logged_in is True
# assert auth_status.is_authorized is True

View File

@ -843,10 +843,10 @@ def test_process_instance_list_filter(
assert json.loads(results[i]["bpmn_json"])["i"] in (1, 2, 3)
def test_process_instance_report_with_default_list(
def test_process_instance_report_show_with_default_list(
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_instance_report_with_default_list."""
"""Test_process_instance_report_show_with_default_list."""
test_process_group_id = "runs_without_input"
process_model_dir_name = "sample"
user = find_or_create_user()