|
@@ -22,6 +22,15 @@ from sentry.incidents.models import (
|
|
|
PendingIncidentSnapshot,
|
|
|
TimeSeriesSnapshot,
|
|
|
)
|
|
|
+from sentry.models import (
|
|
|
+ ApiApplication,
|
|
|
+ ApiAuthorization,
|
|
|
+ ApiKey,
|
|
|
+ ApiToken,
|
|
|
+ Authenticator,
|
|
|
+ AuthIdentity,
|
|
|
+ AuthProvider,
|
|
|
+)
|
|
|
from sentry.models.actor import ACTOR_TYPES, Actor
|
|
|
from sentry.models.counter import Counter
|
|
|
from sentry.models.dashboard import Dashboard, DashboardTombstone
|
|
@@ -299,6 +308,60 @@ class ModelBackupTests(TransactionTestCase):
|
|
|
self.create_organization(owner=user)
|
|
|
return self.import_export_then_validate()
|
|
|
|
|
|
+ @targets_models(Actor)
|
|
|
+ def test_actor(self):
|
|
|
+ self.create_user(email="test@example.com")
|
|
|
+ self.create_team(name="pre save team", organization=self.organization)
|
|
|
+ return self.import_export_then_validate()
|
|
|
+
|
|
|
+ @targets_models(ApiAuthorization, ApiApplication)
|
|
|
+ def test_api_authorization_application(self):
|
|
|
+ user = self.create_user()
|
|
|
+ app = ApiApplication.objects.create(name="test", owner=user)
|
|
|
+ ApiAuthorization.objects.create(
|
|
|
+ application=app, user=self.create_user("example@example.com")
|
|
|
+ )
|
|
|
+ return self.import_export_then_validate()
|
|
|
+
|
|
|
+ @targets_models(ApiToken)
|
|
|
+ def test_apitoken(self):
|
|
|
+ user = self.create_user()
|
|
|
+ app = ApiApplication.objects.create(
|
|
|
+ owner=user, redirect_uris="http://example.com\nhttp://sub.example.com/path"
|
|
|
+ )
|
|
|
+ ApiToken.objects.create(application=app, user=user, token=uuid4().hex, expires_at=None)
|
|
|
+ return self.import_export_then_validate()
|
|
|
+
|
|
|
+ @targets_models(ApiKey)
|
|
|
+ def test_apikey(self):
|
|
|
+ user = self.create_user()
|
|
|
+ org = self.create_organization(owner=user)
|
|
|
+ ApiKey.objects.create(key=uuid4().hex, organization_id=org.id)
|
|
|
+ return self.import_export_then_validate()
|
|
|
+
|
|
|
+ @targets_models(Authenticator)
|
|
|
+ def test_authenticator(self):
|
|
|
+ user = self.create_user()
|
|
|
+ Authenticator.objects.create(user=user, type=1)
|
|
|
+ return self.import_export_then_validate()
|
|
|
+
|
|
|
+ @targets_models(AuthIdentity, AuthProvider)
|
|
|
+ def test_auth_identity_provider(self):
|
|
|
+ user = self.create_user()
|
|
|
+ test_data = {
|
|
|
+ "key1": "value1",
|
|
|
+ "key2": 42,
|
|
|
+ "key3": [1, 2, 3],
|
|
|
+ "key4": {"nested_key": "nested_value"},
|
|
|
+ }
|
|
|
+ AuthIdentity.objects.create(
|
|
|
+ user=user,
|
|
|
+ auth_provider=AuthProvider.objects.create(organization_id=1, provider="sentry"),
|
|
|
+ ident="123456789",
|
|
|
+ data=test_data,
|
|
|
+ )
|
|
|
+ return self.import_export_then_validate()
|
|
|
+
|
|
|
@targets_models(OrganizationAccessRequest, OrganizationMember, OrganizationMemberTeam, Team)
|
|
|
def test_organization_membership(self):
|
|
|
organization = self.create_organization(name="test_org", owner=self.user)
|