Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop ServiceAccountError
IKarbowiak2479d18e9e44
diff --git a/saleor/graphql/account/deprecated/mutations_service_account.py b/saleor/graphql/account/deprecated/mutations_service_account.pyindex c90d1f4d61..caace1f621 100644--- a/saleor/graphql/account/deprecated/mutations_service_account.py+++ b/saleor/graphql/account/deprecated/mutations_service_account.py@@ -7,7 +7,7 @@ from ....core.permissions import AppPermission, get_permissionsfrom ...account.utils import can_manage_app, get_out_of_scope_permissionsfrom ...core.enums import PermissionEnumfrom ...core.mutations import ModelDeleteMutation, ModelMutation-from ...core.types.common import ServiceAccountError+from ...core.types.common import AccountErrorfrom ...meta.deprecated.mutations import ClearMetaBaseMutation, UpdateMetaBaseMutationfrom ...utils import get_user_or_app_from_context, requestor_is_superuserfrom .types import ServiceAccount, ServiceAccountToken@@ -44,8 +44,8 @@ class ServiceAccountTokenCreate(ModelMutation):description = "Creates a new token."model = models.AppTokenpermissions = (AppPermission.MANAGE_APPS,)- error_type_class = ServiceAccountError- error_type_field = "service_account_errors"+ error_type_class = AccountError+ error_type_field = "account_errors"@classmethoddef get_type_for_model(cls):@@ -88,8 +88,8 @@ class ServiceAccountTokenDelete(ModelDeleteMutation):description = "Deletes an authentication token assigned to service account."model = models.AppTokenpermissions = (AppPermission.MANAGE_APPS,)- error_type_class = ServiceAccountError- error_type_field = "service_account_errors"+ error_type_class = AccountError+ error_type_field = "account_errors"@classmethoddef clean_instance(cls, info, instance):@@ -121,8 +121,8 @@ class ServiceAccountCreate(ModelMutation):description = "Creates a new service account."model = models.Apppermissions = (AppPermission.MANAGE_APPS,)- error_type_class = ServiceAccountError- error_type_field = "service_account_errors"+ error_type_class = AccountError+ error_type_field = "account_errors"@classmethoddef get_type_for_model(cls):@@ -152,9 +152,8 @@ class ServiceAccountCreate(ModelMutation):# add errorerror_msg = "You can't add permission that you don't have."code = AccountErrorCode.OUT_OF_SCOPE_PERMISSION.value- params = {"permissions": missing_permissions}raise ValidationError(- {"permissions": ValidationError(error_msg, code=code, params=params)}+ {"permissions": ValidationError(error_msg, code=code)})@classmethod@@ -184,8 +183,8 @@ class ServiceAccountUpdate(ModelMutation):description = "Updates an existing service account."model = models.Apppermissions = (AppPermission.MANAGE_APPS,)- error_type_class = ServiceAccountError- error_type_field = "service_account_errors"+ error_type_class = AccountError+ error_type_field = "account_errors"@classmethoddef clean_input(cls, info, instance, data):@@ -221,8 +220,8 @@ class ServiceAccountDelete(ModelDeleteMutation):description = "Deletes a service account."model = models.Apppermissions = (AppPermission.MANAGE_APPS,)- error_type_class = ServiceAccountError- error_type_field = "service_account_errors"+ error_type_class = AccountError+ error_type_field = "account_errors"@classmethoddef clean_instance(cls, info, instance):@@ -246,8 +245,8 @@ class ServiceAccountUpdatePrivateMeta(UpdateMetaBaseMutation):permissions = (AppPermission.MANAGE_APPS,)model = models.Apppublic = False- error_type_class = ServiceAccountError- error_type_field = "service_account_errors"+ error_type_class = AccountError+ error_type_field = "account_errors"class ServiceAccountClearPrivateMeta(ClearMetaBaseMutation):@@ -257,5 +256,5 @@ class ServiceAccountClearPrivateMeta(ClearMetaBaseMutation):model = models.Apppermissions = (AppPermission.MANAGE_APPS,)public = False- error_type_class = ServiceAccountError- error_type_field = "service_account_errors"+ error_type_class = AccountError+ error_type_field = "account_errors"diff --git a/saleor/graphql/core/types/common.py b/saleor/graphql/core/types/common.pyindex 34d7e5a439..fd09845d86 100644--- a/saleor/graphql/core/types/common.py+++ b/saleor/graphql/core/types/common.py@@ -70,15 +70,6 @@ class AccountError(Error):code = AccountErrorCode(description="The error code.", required=True)-# DEPRECATED: Will be removed in 2020-07-31 (issue: #5521).-class ServiceAccountError(AccountError):- permissions = graphene.List(- graphene.NonNull(PermissionEnum),- description="List of permissions which causes the error.",- required=False,- )--class AppError(Error):code = AppErrorCode(description="The error code.", required=True)permissions = graphene.List(diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex b37b94e848..bb6c77d781 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -4097,7 +4097,7 @@ type ServiceAccount implements Node & ObjectWithMetadata {type ServiceAccountClearPrivateMeta {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")- serviceAccountErrors: [ServiceAccountError!]!+ accountErrors: [AccountError!]!serviceAccount: ServiceAccount}@@ -4115,23 +4115,16 @@ type ServiceAccountCountableEdge {type ServiceAccountCreate {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")authToken: String- serviceAccountErrors: [ServiceAccountError!]!+ accountErrors: [AccountError!]!serviceAccount: ServiceAccount}type ServiceAccountDelete {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")- serviceAccountErrors: [ServiceAccountError!]!+ accountErrors: [AccountError!]!serviceAccount: ServiceAccount}-type ServiceAccountError {- field: String- message: String- code: AccountErrorCode!- permissions: [PermissionEnum!]-}-input ServiceAccountFilterInput {search: StringisActive: Boolean@@ -4162,13 +4155,13 @@ type ServiceAccountToken implements Node {type ServiceAccountTokenCreate {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")authToken: String- serviceAccountErrors: [ServiceAccountError!]!+ accountErrors: [AccountError!]!serviceAccountToken: ServiceAccountToken}type ServiceAccountTokenDelete {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")- serviceAccountErrors: [ServiceAccountError!]!+ accountErrors: [AccountError!]!serviceAccountToken: ServiceAccountToken}@@ -4179,13 +4172,13 @@ input ServiceAccountTokenInput {type ServiceAccountUpdate {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")- serviceAccountErrors: [ServiceAccountError!]!+ accountErrors: [AccountError!]!serviceAccount: ServiceAccount}type ServiceAccountUpdatePrivateMeta {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")- serviceAccountErrors: [ServiceAccountError!]!+ accountErrors: [AccountError!]!serviceAccount: ServiceAccount}diff --git a/tests/api/test_account_depreceated_service_account.py b/tests/api/test_account_depreceated_service_account.pyindex 2cc8486420..694804e39d 100644--- a/tests/api/test_account_depreceated_service_account.py+++ b/tests/api/test_account_depreceated_service_account.py@@ -34,11 +34,10 @@ SERVICE_ACCOUNT_CREATE_MUTATION = """authToken}}- serviceAccountErrors{+ accountErrors{fieldmessagecode- permissions}}}@@ -125,13 +124,12 @@ def test_service_account_create_mutation_out_of_scope_permissions(content = get_graphql_content(response)data = content["data"]["serviceAccountCreate"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccount"]assert len(errors) == 1error = errors[0]assert error["field"] == "permissions"assert error["code"] == AccountErrorCode.OUT_OF_SCOPE_PERMISSION.name- assert error["permissions"] == [PermissionEnum.MANAGE_PRODUCTS.name]# for superuserresponse = superuser_api_client.post_graphql(query, variables=variables)@@ -164,13 +162,12 @@ def test_service_account_create_mutation_for_service_account_out_of_scope_permiscontent = get_graphql_content(response)data = content["data"]["serviceAccountCreate"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccount"]assert len(errors) == 1error = errors[0]assert error["field"] == "permissions"assert error["code"] == AccountErrorCode.OUT_OF_SCOPE_PERMISSION.name- assert error["permissions"] == [PermissionEnum.MANAGE_PRODUCTS.name]def test_service_account_create_mutation_no_permissions(@@ -206,11 +203,10 @@ mutation ServiceAccountUpdate($id: ID!, $is_active: Boolean,}name}- serviceAccountErrors{+ accountErrors{fieldmessagecode- permissions}}}@@ -340,13 +336,12 @@ def test_service_account_update_mutation_out_of_scope_permissions(content = get_graphql_content(response)data = content["data"]["serviceAccountUpdate"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccount"]assert len(errors) == 1error = errors[0]assert error["field"] == "permissions"assert error["code"] == AccountErrorCode.OUT_OF_SCOPE_PERMISSION.name- assert error["permissions"] == [PermissionEnum.MANAGE_USERS.name]# for superuserresponse = superuser_api_client.post_graphql(query, variables=variables)@@ -398,13 +393,12 @@ def test_service_account_update_mutation_for_service_account_out_of_scope_permiscontent = get_graphql_content(response)data = content["data"]["serviceAccountUpdate"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccount"]assert len(errors) == 1error = errors[0]assert error["field"] == "permissions"assert error["code"] == AccountErrorCode.OUT_OF_SCOPE_PERMISSION.name- assert error["permissions"] == [PermissionEnum.MANAGE_USERS.name]def test_service_account_update_mutation_out_of_scope_service_account(@@ -444,7 +438,7 @@ def test_service_account_update_mutation_out_of_scope_service_account(content = get_graphql_content(response)data = content["data"]["serviceAccountUpdate"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccount"]assert len(errors) == 1error = errors[0]@@ -501,7 +495,7 @@ def test_service_account_update_mutation_for_service_account_out_of_scope_serviccontent = get_graphql_content(response)data = content["data"]["serviceAccountUpdate"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccount"]assert len(errors) == 1error = errors[0]@@ -524,7 +518,7 @@ def test_service_account_update_no_permission(app, staff_api_client, staff_user)SERVICE_ACCOUNT_DELETE_MUTATION = """mutation serviceAccountDelete($id: ID!){serviceAccountDelete(id: $id){- serviceAccountErrors{+ accountErrors{fieldmessagecode@@ -557,7 +551,7 @@ def test_service_account_delete(data = content["data"]["serviceAccountDelete"]assert data["serviceAccount"]- assert not data["serviceAccountErrors"]+ assert not data["accountErrors"]assert not App.objects.filter(id=app.id).exists()@@ -579,7 +573,7 @@ def test_service_account_delete_for_app(data = content["data"]["serviceAccountDelete"]assert data["serviceAccount"]- assert not data["serviceAccountErrors"]+ assert not data["accountErrors"]assert not App.objects.filter(id=app.id).exists()@@ -608,7 +602,7 @@ def test_service_account_delete_out_of_scope_app(content = get_graphql_content(response)data = content["data"]["serviceAccountDelete"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccount"]assert len(errors) == 1error = errors[0]@@ -621,7 +615,7 @@ def test_service_account_delete_out_of_scope_app(data = content["data"]["serviceAccountDelete"]assert data["serviceAccount"]- assert not data["serviceAccountErrors"]+ assert not data["accountErrors"]assert not App.objects.filter(id=app.id).exists()@@ -640,7 +634,7 @@ def test_service_account_delete_for_service_account_out_of_scope_service_accountcontent = get_graphql_content(response)data = content["data"]["serviceAccountDelete"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccount"]assert len(errors) == 1error = errors[0]@@ -859,7 +853,7 @@ mutation serviceAccountTokenCreate($input: ServiceAccountTokenInput!) {authTokenid}- serviceAccountErrors{+ accountErrors{fieldmessagecode@@ -952,7 +946,7 @@ def test_service_account_token_create_out_of_scope_service_account(content = get_graphql_content(response)data = content["data"]["serviceAccountTokenCreate"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccountToken"]assert len(errors) == 1error = errors[0]@@ -988,7 +982,7 @@ def test_service_account_token_create_as_service_account_out_of_scope_service_ac)content = get_graphql_content(response)data = content["data"]["serviceAccountTokenCreate"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccountToken"]assert len(errors) == 1error = errors[0]@@ -1008,7 +1002,7 @@ def test_service_account_token_create_no_permissions(staff_api_client, staff_useSERVICE_ACCOUNT_TOKEN_DELETE_MUTATION = """mutation serviceAccountTokenDelete($id: ID!){serviceAccountTokenDelete(id: $id){- serviceAccountErrors{+ accountErrors{fieldmessagecode@@ -1102,7 +1096,7 @@ def test_service_account_token_delete_out_of_scope_service_account(content = get_graphql_content(response)data = content["data"]["serviceAccountTokenDelete"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccountToken"]assert len(errors) == 1@@ -1116,7 +1110,7 @@ def test_service_account_token_delete_out_of_scope_service_account(content = get_graphql_content(response)data = content["data"]["serviceAccountTokenDelete"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert data["serviceAccountToken"]assert not errors@@ -1139,7 +1133,7 @@ def test_service_account_token_delete_for_service_account_out_of_scope_app(content = get_graphql_content(response)data = content["data"]["serviceAccountTokenDelete"]- errors = data["serviceAccountErrors"]+ errors = data["accountErrors"]assert not data["serviceAccountToken"]assert len(errors) == 1