Related to https://github.com/grafana/oncall-private/issues/2826 Continuing work started in https://github.com/grafana/oncall/pull/5211, this adds support for Grafana service accounts tokens for API authentication (except alert group actions which will still require a user behind). Next steps would be updating the go client and the terraform provider to allow service account token auth for OnCall resources. Following proposal 1.1 from [doc](https://docs.google.com/document/d/1I3nFbsUEkiNPphBXT-kWefIeramTY71qqZ1OA06Kmls/edit?usp=sharing).
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
import factory
|
|
|
|
from apps.user_management.models import Organization, Region, ServiceAccount, Team, User
|
|
from common.utils import UniqueFaker
|
|
|
|
|
|
class OrganizationFactory(factory.DjangoModelFactory):
|
|
org_title = factory.Faker("word")
|
|
stack_id = UniqueFaker("pyint")
|
|
org_id = UniqueFaker("pyint")
|
|
stack_slug = factory.Faker("word")
|
|
|
|
class Meta:
|
|
model = Organization
|
|
|
|
|
|
class UserFactory(factory.DjangoModelFactory):
|
|
username = UniqueFaker("user_name")
|
|
email = factory.Faker("email")
|
|
user_id = UniqueFaker("pyint")
|
|
avatar_url = factory.Faker("url")
|
|
|
|
class Meta:
|
|
model = User
|
|
|
|
|
|
class TeamFactory(factory.DjangoModelFactory):
|
|
name = factory.Faker("user_name")
|
|
email = factory.Faker("email")
|
|
team_id = UniqueFaker("pyint")
|
|
avatar_url = factory.Faker("url")
|
|
|
|
class Meta:
|
|
model = Team
|
|
|
|
|
|
class RegionFactory(factory.DjangoModelFactory):
|
|
name = factory.Faker("country")
|
|
slug = factory.Faker("slug")
|
|
oncall_backend_url = factory.Faker("url")
|
|
|
|
class Meta:
|
|
model = Region
|
|
|
|
|
|
class ServiceAccountFactory(factory.DjangoModelFactory):
|
|
grafana_id = UniqueFaker("pyint")
|
|
login = UniqueFaker("user_name")
|
|
|
|
class Meta:
|
|
model = ServiceAccount
|