Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(control_silo): Consolidate User models (and authenticator) and tests #74222

Closed
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion bin/mock-user
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import argparse


def main(username, newsletter_consent_prompt=None):
from sentry.models.user import User
from sentry.users.models.user import User

user = User.objects.get(username__iexact=username)

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
)
from sentry.models.projectkey import ProjectKey
from sentry.models.relay import Relay
from sentry.models.user import User
from sentry.relay.utils import get_header_relay_id, get_header_relay_signature
from sentry.silo.base import SiloLimit, SiloMode
from sentry.users.models.user import User
from sentry.users.services.user import RpcUser
from sentry.users.services.user.service import user_service
from sentry.utils.linksign import process_signature
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/bases/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from sentry.models.organization import OrganizationStatus
from sentry.models.organizationmapping import OrganizationMapping
from sentry.models.organizationmembermapping import OrganizationMemberMapping
from sentry.models.user import User
from sentry.organizations.services.organization import organization_service
from sentry.users.models.user import User
from sentry.users.services.user import RpcUser
from sentry.users.services.user.service import user_service

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/auth_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from sentry.auth.authenticators.u2f import U2fInterface
from sentry.auth.services.auth.impl import promote_request_rpc_user
from sentry.auth.superuser import SUPERUSER_ORG_ID
from sentry.models.authenticator import Authenticator
from sentry.organizations.services.organization import organization_service
from sentry.users.models.authenticator import Authenticator
from sentry.utils import auth, json, metrics
from sentry.utils.auth import DISABLE_SSO_CHECK_FOR_LOCAL_DEV, has_completed_sso, initiate_login
from sentry.utils.settings import is_self_hosted
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/authenticator_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sentry.api.api_owners import ApiOwner
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import Endpoint, control_silo_endpoint
from sentry.models.authenticator import Authenticator
from sentry.users.models.authenticator import Authenticator


@control_silo_endpoint
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/group_ai_autofix.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from sentry.api.serializers import EventSerializer, serialize
from sentry.autofix.utils import get_autofix_repos_from_project_code_mappings
from sentry.models.group import Group
from sentry.models.user import User
from sentry.seer.signed_seer_api import sign_with_seer_secret
from sentry.types.ratelimit import RateLimit, RateLimitCategory
from sentry.users.models.user import User
from sentry.users.services.user.service import user_service

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/group_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
from sentry.models.integrations.external_issue import ExternalIssue
from sentry.models.platformexternalissue import PlatformExternalIssue
from sentry.models.team import Team
from sentry.models.userreport import UserReport
from sentry.plugins.base import plugins
from sentry.tasks.post_process import fetch_buffered_group_stats
from sentry.types.ratelimit import RateLimit, RateLimitCategory
from sentry.users.models.userreport import UserReport
from sentry.users.services.user.service import user_service
from sentry.utils import metrics

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/group_event_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
from sentry.api.serializers import EventSerializer, serialize
from sentry.issues.grouptype import GroupCategory
from sentry.models.environment import Environment
from sentry.models.user import User
from sentry.search.events.filter import convert_search_filter_to_snuba_query, format_search_filter
from sentry.snuba.dataset import Dataset
from sentry.types.ratelimit import RateLimit, RateLimitCategory
from sentry.users.models.user import User
from sentry.utils import metrics

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/group_integration_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
from sentry.models.group import Group
from sentry.models.grouplink import GroupLink
from sentry.models.integrations.external_issue import ExternalIssue
from sentry.models.user import User
from sentry.shared_integrations.exceptions import IntegrationError, IntegrationFormError
from sentry.signals import integration_issue_created, integration_issue_linked
from sentry.types.activity import ActivityType
from sentry.users.models.user import User

MISSING_FEATURE_MESSAGE = "Your organization does not have access to this feature."

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/group_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sentry.models.group import Group
from sentry.models.grouplink import GroupLink
from sentry.models.integrations.external_issue import ExternalIssue
from sentry.models.user import User
from sentry.users.models.user import User


class IntegrationIssueSerializer(IntegrationSerializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from sentry.api.serializers import serialize
from sentry.grouping.grouping_info import get_grouping_info
from sentry.models.group import Group
from sentry.models.user import User
from sentry.seer.similarity.similar_issues import get_similarity_data_from_seer
from sentry.seer.similarity.types import SeerSimilarIssueData, SimilarIssuesEmbeddingsRequest
from sentry.seer.similarity.utils import get_stacktrace_string
from sentry.users.models.user import User
from sentry.utils.safe import get_path

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/group_user_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sentry.api.paginator import DateTimePaginator
from sentry.api.serializers import serialize
from sentry.models.environment import Environment
from sentry.models.userreport import UserReport
from sentry.users.models.userreport import UserReport


@region_silo_endpoint
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import Endpoint, control_silo_endpoint
from sentry.api.serializers import serialize
from sentry.models.user import User
from sentry.users.models.user import User


@control_silo_endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sentry.mediators.external_issues.issue_link_creator import IssueLinkCreator
from sentry.models.group import Group
from sentry.models.project import Project
from sentry.models.user import User
from sentry.users.models.user import User
from sentry.users.services.user.serial import serialize_rpc_user


Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/oauth_userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sentry.api.base import Endpoint, control_silo_endpoint
from sentry.api.exceptions import ParameterValidationError, ResourceDoesNotExist, SentryAPIException
from sentry.models.apitoken import ApiToken
from sentry.models.useremail import UserEmail
from sentry.users.models.useremail import UserEmail


class InsufficientScopesError(SentryAPIException):
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/org_auth_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
from sentry.models.organizationmapping import OrganizationMapping
from sentry.models.organizationmembermapping import OrganizationMemberMapping
from sentry.models.orgauthtoken import MAX_NAME_LENGTH, OrgAuthToken
from sentry.models.user import User
from sentry.organizations.services.organization.model import (
RpcOrganization,
RpcUserOrganizationContext,
)
from sentry.security.utils import capture_security_activity
from sentry.users.models.user import User
from sentry.utils.security.orgauthtoken_token import (
SystemUrlPrefixMissingException,
generate_token,
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/organization_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
from sentry.models.options.organization_option import OrganizationOption
from sentry.models.organization import Organization, OrganizationStatus
from sentry.models.scheduledeletion import RegionScheduledDeletion
from sentry.models.useremail import UserEmail
from sentry.organizations.services.organization import organization_service
from sentry.organizations.services.organization.model import (
RpcOrganization,
Expand All @@ -77,6 +76,7 @@
OrganizationSlugCollisionException,
organization_provisioning_service,
)
from sentry.users.models.useremail import UserEmail
from sentry.users.services.user.serial import serialize_generic_user
from sentry.utils.audit import create_audit_entry

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sentry.api.bases.organization import OrganizationEndpoint
from sentry.api.serializers.rest_framework.base import CamelSnakeSerializer
from sentry.models.organization import Organization
from sentry.models.user import User
from sentry.users.models.user import User
from sentry.utils.email import MessageBuilder
from sentry.utils.strings import oxfordize_list

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/organization_user_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sentry.api.paginator import DateTimePaginator
from sentry.api.serializers import serialize
from sentry.api.serializers.models import UserReportWithGroupSerializer
from sentry.models.userreport import UserReport
from sentry.users.models.userreport import UserReport


class _PaginateKwargs(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_user_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from sentry.ingest.userreport import Conflict, save_userreport
from sentry.models.environment import Environment
from sentry.models.projectkey import ProjectKey
from sentry.models.userreport import UserReport
from sentry.users.models.userreport import UserReport


class UserReportSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/relocations/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
from sentry.auth.elevated_mode import has_elevated_mode
from sentry.models.files.file import File
from sentry.models.relocation import Relocation, RelocationFile
from sentry.models.user import MAX_USERNAME_LENGTH
from sentry.options import get
from sentry.search.utils import tokenize_query
from sentry.signals import relocation_link_promo_code
from sentry.slug.patterns import ORG_SLUG_PATTERN
from sentry.tasks.relocation import uploading_complete
from sentry.users.models.user import MAX_USERNAME_LENGTH
from sentry.users.services.user.model import RpcUser
from sentry.users.services.user.service import user_service
from sentry.utils.db import atomic_transaction
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/api/endpoints/user_authenticator_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from sentry.auth.authenticators.u2f import decode_credential_id
from sentry.auth.staff import has_staff_option, is_active_staff
from sentry.auth.superuser import is_active_superuser
from sentry.models.authenticator import Authenticator
from sentry.models.user import User
from sentry.security.utils import capture_security_activity
from sentry.users.models.authenticator import Authenticator
from sentry.users.models.user import User
from sentry.utils.auth import MFA_SESSION_KEY


Expand Down
4 changes: 2 additions & 2 deletions src/sentry/api/endpoints/user_authenticator_enroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
from sentry.api.serializers import serialize
from sentry.auth.authenticators.base import EnrollmentStatus, NewEnrollmentDisallowed
from sentry.auth.authenticators.sms import SMSRateLimitExceeded
from sentry.models.authenticator import Authenticator
from sentry.models.user import User
from sentry.organizations.services.organization import organization_service
from sentry.security.utils import capture_security_activity
from sentry.users.models.authenticator import Authenticator
from sentry.users.models.user import User
from sentry.utils.auth import MFA_SESSION_KEY

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/user_authenticator_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sentry.api.base import control_silo_endpoint
from sentry.api.bases.user import UserEndpoint
from sentry.api.serializers import serialize
from sentry.models.authenticator import Authenticator
from sentry.users.models.authenticator import Authenticator


@control_silo_endpoint
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/api/endpoints/user_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
from sentry.api.serializers.rest_framework import CamelSnakeModelSerializer
from sentry.auth.elevated_mode import has_elevated_mode
from sentry.constants import LANGUAGES
from sentry.models.options.user_option import UserOption
from sentry.models.organization import OrganizationStatus
from sentry.models.organizationmapping import OrganizationMapping
from sentry.models.organizationmembermapping import OrganizationMemberMapping
from sentry.models.user import User
from sentry.models.useremail import UserEmail
from sentry.organizations.services.organization import organization_service
from sentry.organizations.services.organization.model import RpcOrganizationDeleteState
from sentry.users.models.user import User
from sentry.users.models.user_option import UserOption
from sentry.users.models.useremail import UserEmail
from sentry.users.services.user.serial import serialize_generic_user
from sentry.utils.dates import AVAILABLE_TIMEZONES

Expand Down
6 changes: 3 additions & 3 deletions src/sentry/api/endpoints/user_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from sentry.api.decorators import sudo_required
from sentry.api.serializers import serialize
from sentry.api.validators import AllowedEmailField
from sentry.models.options.user_option import UserOption
from sentry.models.user import User
from sentry.models.useremail import UserEmail
from sentry.users.models.user import User
from sentry.users.models.user_option import UserOption
from sentry.users.models.useremail import UserEmail

logger = logging.getLogger("sentry.accounts")

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/user_emails_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from sentry.api.base import control_silo_endpoint
from sentry.api.bases.user import UserEndpoint
from sentry.api.validators import AllowedEmailField
from sentry.models.useremail import UserEmail
from sentry.types.ratelimit import RateLimit, RateLimitCategory
from sentry.users.models.useremail import UserEmail

logger = logging.getLogger("sentry.accounts")

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/user_identity_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from sentry.models.authidentity import AuthIdentity
from sentry.models.identity import Identity
from sentry.models.user import User
from sentry.users.models.user import User
from social_auth.models import UserSocialAuth


Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/user_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from sentry.api.permissions import SuperuserOrStaffFeatureFlaggedPermission
from sentry.api.serializers import serialize
from sentry.db.models.query import in_iexact
from sentry.models.user import User
from sentry.search.utils import tokenize_query
from sentry.users.models.user import User


@control_silo_endpoint
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/user_ips.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sentry.api.decorators import sudo_required
from sentry.api.paginator import DateTimePaginator
from sentry.api.serializers import serialize
from sentry.models.userip import UserIP
from sentry.users.models.userip import UserIP


@control_silo_endpoint
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/user_notification_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from sentry.api.base import control_silo_endpoint
from sentry.api.bases.user import UserEndpoint
from sentry.api.serializers import Serializer, serialize
from sentry.models.options.user_option import UserOption
from sentry.notifications.types import UserOptionsSettingsKey
from sentry.users.models.user_option import UserOption

USER_OPTION_SETTINGS = {
UserOptionsSettingsKey.SELF_ACTIVITY: {
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/api/endpoints/user_notification_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import control_silo_endpoint
from sentry.api.bases.user import UserEndpoint
from sentry.models.options.user_option import UserOption
from sentry.models.useremail import UserEmail
from sentry.users.models.user_option import UserOption
from sentry.users.models.useremail import UserEmail

INVALID_EMAIL_MSG = (
"Invalid email value(s) provided. Email values must be verified emails for the given user."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from sentry.api.serializers import serialize
from sentry.api.validators.notifications import validate_type
from sentry.models.notificationsettingoption import NotificationSettingOption
from sentry.models.user import User
from sentry.notifications.serializers import NotificationSettingsOptionSerializer
from sentry.notifications.validators import UserNotificationSettingOptionWithValueSerializer
from sentry.users.models.user import User


@control_silo_endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sentry.api.base import control_silo_endpoint
from sentry.api.bases.user import UserEndpoint
from sentry.models.notificationsettingoption import NotificationSettingOption
from sentry.models.user import User
from sentry.users.models.user import User


@control_silo_endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from sentry.api.validators.notifications import validate_type
from sentry.integrations.types import PERSONAL_NOTIFICATION_PROVIDERS
from sentry.models.notificationsettingprovider import NotificationSettingProvider
from sentry.models.user import User
from sentry.notifications.serializers import NotificationSettingsProviderSerializer
from sentry.notifications.types import NotificationSettingsOptionEnum
from sentry.notifications.validators import UserNotificationSettingsProvidersDetailsSerializer
from sentry.users.models.user import User


@control_silo_endpoint
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/user_permission_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sentry.api.bases.user import UserEndpoint
from sentry.api.decorators import sudo_required
from sentry.api.permissions import SuperuserOrStaffFeatureFlaggedPermission
from sentry.models.userpermission import UserPermission
from sentry.users.models.userpermission import UserPermission

audit_logger = logging.getLogger("sentry.audit.user")

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/user_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sentry.api.base import control_silo_endpoint
from sentry.api.bases.user import UserEndpoint
from sentry.api.permissions import SuperuserOrStaffFeatureFlaggedPermission
from sentry.models.userpermission import UserPermission
from sentry.users.models.userpermission import UserPermission


@control_silo_endpoint
Expand Down
Loading
Loading