def setUp(self) -> None:
     self.outpost = Outpost.objects.create(
         name="test",
         type=OutpostType.PROXY,
     )
     self.integration = DockerServiceConnection(name="test")
     ObjectManager().run()
Beispiel #2
0
 def setUp(self) -> None:
     super().setUp()
     ObjectManager().run()
     self.app = Application.objects.create(name="test", slug="test")
     self.provider: OAuth2Provider = OAuth2Provider.objects.create(
         name="test",
         client_id=generate_id(),
         client_secret=generate_key(),
         authorization_flow=create_test_flow(),
         redirect_uris="",
         signing_key=create_test_cert(),
     )
     self.provider.property_mappings.set(ScopeMapping.objects.all())
     # Needs to be assigned to an application for iss to be set
     self.app.provider = self.provider
     self.app.save()
     self.user = create_test_admin_user()
     self.token: RefreshToken = RefreshToken.objects.create(
         provider=self.provider,
         user=self.user,
         access_token=generate_id(),
         refresh_token=generate_id(),
         _scope="openid user profile",
         _id_token=json.dumps(asdict(IDToken("foo", "bar"), )),
     )
Beispiel #3
0
 def setUp(self):
     ObjectManager().run()
     self.source = LDAPSource.objects.create(
         name="ldap",
         slug="ldap",
         base_dn="dc=goauthentik,dc=io",
         additional_user_dn="ou=users",
         additional_group_dn="ou=groups",
     )
Beispiel #4
0
def managed_reconcile(self: MonitoredTask):
    """Run ObjectManager to ensure objects are up-to-date"""
    try:
        ObjectManager().run()
        self.set_status(
            TaskResult(TaskResultStatus.SUCCESSFUL,
                       ["Successfully updated managed models."]))
    except DatabaseError as exc:  # pragma: no cover
        self.set_status(TaskResult(TaskResultStatus.WARNING, [str(exc)]))
Beispiel #5
0
 def setUp(self):
     ObjectManager().run()
     cert = create_test_cert()
     self.provider: SAMLProvider = SAMLProvider.objects.create(
         authorization_flow=create_test_flow(),
         acs_url="http://testserver/source/saml/provider/acs/",
         signing_kp=cert,
         verification_kp=cert,
     )
     self.provider.property_mappings.set(SAMLPropertyMapping.objects.all())
     self.provider.save()
     self.source = SAMLSource.objects.create(
         slug="provider",
         issuer="authentik",
         signing_kp=cert,
         pre_authentication_flow=create_test_flow(),
     )
     self.factory = RequestFactory()
Beispiel #6
0
 def setUp(self):
     ObjectManager().run()
     cert = CertificateKeyPair.objects.first()
     self.provider: SAMLProvider = SAMLProvider.objects.create(
         authorization_flow=Flow.objects.get(
             slug="default-provider-authorization-implicit-consent"),
         acs_url="http://testserver/source/saml/provider/acs/",
         signing_kp=cert,
         verification_kp=cert,
     )
     self.provider.property_mappings.set(SAMLPropertyMapping.objects.all())
     self.provider.save()
     self.source = SAMLSource.objects.create(
         slug="provider",
         issuer="authentik",
         signing_kp=cert,
         pre_authentication_flow=Flow.objects.get(
             slug="default-source-pre-authentication"),
     )
     self.factory = RequestFactory()
Beispiel #7
0
 def wrapper(*args, **kwargs):
     """Run objectmanager before a test function"""
     ObjectManager().run()
     return func(*args, **kwargs)