def test_create_api_invalid_semver(api: TestClient, auth_header: dict): """Assert that walkoff_version, app_version, name all have correct sematic versioning""" inputs = [ { "create": """ walkoff_version: 1.0 app_version: 1.0.0 name: test_app description: An invalid App API with bad semantic versioning in walkoff_version actions: - name: test_action """, }, { "create": """ walkoff_version: 1.0.0 app_version: 1.0 name: test_app2 description: An invalid App API with bad semantic versioning in app_version actions: - name: test_action """, }, ] assert_crud_resource(api, auth_header, apps_api_url, inputs, yaml.full_load, valid=False)
def test_create_app_developer(api: TestClient, auth_header: dict): """ Assert that a app_developer user can be created """ inputs = [{ "create": f""" username: app_dev password: app_dev roles: [ {str(DefaultRoleUUID.APP_DEV.value)} ] active: {True} """ }] assert_crud_resource(api, auth_header, base_users_url, inputs, yaml.full_load)
def test_create_workflow_operator(api: TestClient, auth_header: dict): """ Assert that a workflow_operator user can be created """ inputs = [{ "create": f""" username: workflow_op password: workflow_op roles: [ {str(DefaultRoleUUID.WF_OP.value)} ] active: {True} """ }] assert_crud_resource(api, auth_header, base_users_url, inputs, yaml.full_load)
def test_create_api_minimum(api: TestClient, auth_header: dict): """Assert that a minimum valid API is accepted""" inputs = [{ "create": """ walkoff_version: 1.0.0 app_version: 1.0.0 name: test_app description: A minimum valid App API actions: - name: test_action """ }] assert_crud_resource(api, auth_header, apps_api_url, inputs, yaml.full_load)
def test_create_api_invalid_contact(api: TestClient, auth_header: dict): """Assert that various invalid contact info are rejected""" inputs = [{ "create": """ walkoff_version: 1.0.0 app_version: 1.0.0 name: test_app contact_info: not an object description: An invalid App API with non-object contact info actions: - name: test_action """, }, { "create": """ walkoff_version: 1.0.0 app_version: 1.0.0 name: test_app3 contact_info: name: name email: not a valid email description: An invalid App API with invalid email in contact actions: - name: test_action """, }, { "create": """ walkoff_version: 1.0.0 app_version: 1.0.0 name: test_app4 contact_info: name: name url: http://not a valid url description: An invalid App API with invalid URL in contact actions: - name: test_action """, }] assert_crud_resource(api, auth_header, apps_api_url, inputs, yaml.full_load, valid=False)
def test_create_api_empty(api: TestClient, auth_header: dict): """Assert that an API without actions is rejected""" inputs = [{ "create": """ walkoff_version: 1.0.0 app_version: 1.0.0 name: test_app description: An invalid App API with missing actions """ }] assert_crud_resource(api, auth_header, apps_api_url, inputs, yaml.full_load, valid=False)
def test_create_new_admin(api: TestClient, auth_header: dict): """ Assert that a new admin can be created """ inputs = [{ "create": f""" username: new_admin password: new_admin active: {True} roles: [ {str(DefaultRoleUUID.ADMIN.value)} ] """ }] assert_crud_resource(api, auth_header, base_users_url, inputs, yaml.full_load) p = api.get(base_users_url, headers=auth_header) p_response = p.json() assert p.status_code == 200 assert len(p_response) == 3
def test_create_internal_user(api: TestClient, auth_header: dict): """ Assert that a new internal user CANNOT be created """ inputs = [{ "create": f""" username: internal_user2 password: internal_user2 roles: [ {str(DefaultRoleUUID.INTERNAL_USER.value)} ] active: {True} """ }] assert_crud_resource(api, auth_header, base_users_url, inputs, yaml.full_load, valid=False)
def test_create_super_admin(api: TestClient, auth_header: dict): """ Assert that a new super_admin user CANNOT be created """ inputs = [{ "create": f""" username: super_admin2 password: super_admin2 roles: [ {str(DefaultRoleUUID.SUPER_ADMIN.value)} ] active: {True} """ }] assert_crud_resource(api, auth_header, base_users_url, inputs, yaml.full_load, valid=False)
def test_create_new_user_with_new_role(api: TestClient, auth_header: dict): with open('testing/util/role.json') as fp: role_json = json.load(fp) role_id = role_json["id_"] api.post("/walkoff/api/roles/", headers=auth_header, data=json.dumps(role_json)) inputs = [{ "create": f""" username: new_test password: 123 roles: [ {role_id} ] active: {True} """ }] assert_crud_resource(api, auth_header, base_users_url, inputs, yaml.full_load)
def test_create_api_valid_contact(api: TestClient, auth_header: dict): """Assert that valid contact info is accepted""" inputs = [ { "create": """ walkoff_version: 1.0.0 app_version: 1.0.0 name: test_app contact_info: name: name url: http://example.com email: [email protected] description: A valid App API with contact info actions: - name: test_action """, }, ] assert_crud_resource(api, auth_header, apps_api_url, inputs, yaml.full_load)