Beispiel #1
0
    def test_cache_cleanup_when_domain_subscription_changes(self):
        """
        Ensure that the cache for IdentityProvider.does_domain_trust_this_idp
        is cleared when the status of a domain's subscription changes.
        """
        domain = Domain.get_or_create_with_name("vaultwax-001", is_active=True)
        self.addCleanup(lambda: domain.delete())
        enterprise_plan = generator.get_enterprise_plan()

        self.assertFalse(self.idp.does_domain_trust_this_idp(domain.name))

        sub = Subscription.new_domain_subscription(
            self.idp.owner,
            domain.name,
            enterprise_plan,
        )
        self.assertTrue(self.idp.does_domain_trust_this_idp(domain.name))

        sub.is_active = False
        sub.save()
        self.assertFalse(self.idp.does_domain_trust_this_idp(domain.name))

        sub.is_active = True
        sub.save()
        self.assertTrue(self.idp.does_domain_trust_this_idp(domain.name))

        SubscriptionAdjustment.objects.all().delete()
        Subscription.visible_and_suppressed_objects.all().delete()
        self.assertFalse(self.idp.does_domain_trust_this_idp(domain.name))
Beispiel #2
0
    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 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)