Exemplo n.º 1
0
    def test_set_id_verification_status_expired(self):
        """
        The user details are synced properly and an email is sent when the email is changed.
        """

        SSOVerification.objects.create(
            user=self.user,
            status="approved",
            name=self.user.profile.name,
            identity_provider_type=self.provider_class_name,
            identity_provider_slug=self.provider_slug,
        )

        with mock.patch('common.djangoapps.third_party_auth.pipeline.earliest_allowed_verification_date') as earliest_date:  # lint-amnesty, pylint: disable=line-too-long
            earliest_date.return_value = datetime.datetime.now(
                pytz.UTC) + datetime.timedelta(days=1)
            # Begin the pipeline.
            pipeline.set_id_verification_status(
                auth_entry=pipeline.AUTH_ENTRY_LOGIN,
                strategy=self.strategy,
                details=self.details,
                user=self.user,
            )

            assert SSOVerification.objects.filter(
                user=self.user,
                status="approved",
                name=self.user.profile.name,
                identity_provider_type=self.provider_class_name,
                identity_provider_slug=self.provider_slug,
            ).count() == 2
    def test_verification_signal(self):
        """
        Verification signal is sent upon approval.
        """
        with mock.patch('openedx.core.djangoapps.signals.signals.LEARNER_NOW_VERIFIED.send_robust') as mock_signal:
            # Begin the pipeline.
            pipeline.set_id_verification_status(
                auth_entry=pipeline.AUTH_ENTRY_LOGIN,
                strategy=self.strategy,
                details=self.details,
                user=self.user,
            )

        # Ensure a verification signal was sent
        assert mock_signal.call_count == 1
Exemplo n.º 3
0
    def test_set_id_verification_status_new_user(self):
        """
        The user details are synced properly and an email is sent when the email is changed.
        """
        # Begin the pipeline.
        pipeline.set_id_verification_status(
            auth_entry=pipeline.AUTH_ENTRY_LOGIN,
            strategy=self.strategy,
            details=self.details,
            user=self.user,
        )

        verification = SSOVerification.objects.get(user=self.user)

        assert verification.identity_provider_type == self.provider_class_name
        assert verification.identity_provider_slug == self.provider_slug
        assert verification.status == 'approved'
        assert verification.name == self.user.profile.name
Exemplo n.º 4
0
    def test_set_id_verification_status_returning_user(self):
        """
        The user details are synced properly and an email is sent when the email is changed.
        """

        SSOVerification.objects.create(
            user=self.user,
            status="approved",
            name=self.user.profile.name,
            identity_provider_type=self.provider_class_name,
            identity_provider_slug=self.provider_slug,
        )

        # Begin the pipeline.
        pipeline.set_id_verification_status(
            auth_entry=pipeline.AUTH_ENTRY_LOGIN,
            strategy=self.strategy,
            details=self.details,
            user=self.user,
        )

        assert SSOVerification.objects.filter(user=self.user).count() == 1