def setUpClass(cls): super().setUpClass() enterprise_plan = generator.get_enterprise_plan() cls.account = generator.get_billing_account_for_idp() cls.domain_with_sso = Domain.get_or_create_with_name( "helping-earth-001", is_active=True) Subscription.new_domain_subscription( account=cls.account, domain=cls.domain_with_sso.name, plan_version=enterprise_plan, ) cls.idp = generator.create_idp('helping-earth', cls.account) cls.idp.is_active = True cls.idp.save() cls.account_pending_sso = generator.get_billing_account_for_idp() cls.domain_pending_sso = Domain.get_or_create_with_name( "dimagi-dot-org-001", is_active=True) Subscription.new_domain_subscription( account=cls.account_pending_sso, domain=cls.domain_pending_sso.name, plan_version=enterprise_plan, ) cls.inactive_idp_account = generator.get_billing_account_for_idp() cls.domain_with_inactive_sso = Domain.get_or_create_with_name( "vaultwax-001", is_active=True) Subscription.new_domain_subscription( account=cls.inactive_idp_account, domain=cls.domain_with_inactive_sso.name, plan_version=enterprise_plan, ) cls.inactive_idp = generator.create_idp('vaultwax', cls.inactive_idp_account) cls.domain_trusting_idp = Domain.get_or_create_with_name( "domain-trusts-helping-earth", is_active=True) cls.idp.create_trust_with_domain(cls.domain_trusting_idp.name, "*****@*****.**") cls.domain_trusting_inactive_idp = Domain.get_or_create_with_name( "domain-trusts-vaultwax", is_active=True) cls.inactive_idp.create_trust_with_domain( cls.domain_trusting_inactive_idp.name, "*****@*****.**") cls.other_domain = Domain.get_or_create_with_name("hello-test", is_active=True)
def setUpClass(cls): super().setUpClass() cls.account = generator.get_billing_account_for_idp() cls.domain = Domain.get_or_create_with_name("helping-earth-001", is_active=True) enterprise_plan = generator.get_enterprise_plan() Subscription.new_domain_subscription( account=cls.account, domain=cls.domain.name, plan_version=enterprise_plan, ) cls.user = WebUser.create(cls.domain.name, '*****@*****.**', 'testpwd', None, None) cls.idp = generator.create_idp('helping-earth', cls.account) cls.idp.is_active = True cls.idp.save() AuthenticatedEmailDomain.objects.create( email_domain='helpingearth.org', identity_provider=cls.idp, ) cls.domain_created_by_user = Domain.get_or_create_with_name( "my-test-project", is_active=True) cls.domain_created_by_user.creating_user = cls.user.username cls.domain_created_by_user.save() cls.external_domain = Domain.get_or_create_with_name("vaultwax-001", is_active=True) cls.user_without_idp = WebUser.create(cls.external_domain.name, '*****@*****.**', 'testpwd', None, None)
def test_cache_is_cleared_when_domain_is_added_to_idp(self): """ Ensure that the quickcache for is_domain_using_sso properly gets cleared when a domain suddenly gains SSO access. """ self.assertFalse(is_domain_using_sso(self.domain_pending_sso.name)) new_idp = generator.create_idp('dimagi-org', self.account_pending_sso) new_idp.is_active = True new_idp.save() new_idp.save() # this avoids a race condition with tests self.assertTrue(is_domain_using_sso(self.domain_pending_sso.name))
def setUp(self): super().setUp() self.idp = generator.create_idp('vaultwax', self.account, include_certs=True) self.request = RequestFactory().get('/sso/test') self.request_args = (self.idp.slug, ) self.request.is_secure = lambda: False self.request.META = { 'HTTP_HOST': 'test.commcarehq.org', 'PATH_INFO': '/sso/test', 'SERVER_PORT': '80', } self.view = mock.MagicMock(return_value='fake response')
def setUpClass(cls): super().setUpClass() cls.account = generator.get_billing_account_for_idp() cls.domain = Domain.get_or_create_with_name("vaultwax-001", is_active=True) # this will be the user that's "logging in" with SAML2 via the SsoBackend cls.user = WebUser.create( cls.domain.name, '*****@*****.**', 'testpwd', None, None ) cls.idp = generator.create_idp('vaultwax', cls.account) cls.idp.is_active = True cls.idp.save() AuthenticatedEmailDomain.objects.create( email_domain='vaultwax.com', identity_provider=cls.idp, ) idp_vwx = generator.create_idp('vwx-link', cls.account) AuthenticatedEmailDomain.objects.create( email_domain='vwx.link', identity_provider=idp_vwx, # note which idp is mapped here )
def setUp(self): super().setUp() self.idp = generator.create_idp('vaultwax', self.account)