Exemplo n.º 1
0
    def test_that_sso_digest_computes_correctly(self):
        """Verifies sso_digest computes correctly"""

        # computed "by hand"
        assert sso_digest(123, 1486069731, 1800) == (
            'a64ea7218e4a67d863e03ec43ac40240af39f5924af46e02b2199e3f7974b8d3'
        )
Exemplo n.º 2
0
    def get(self, request, *args, **kargs):  # pylint: disable=unused-argument, no-self-use
        """
        Request for exam SSO parameters
        """
        profile = request.user.profile
        student_id = profile.student_id

        if not ExamProfile.objects.filter(
                profile=profile,
                status=ExamProfile.PROFILE_SUCCESS,
        ).exists():
            # UI should in theory not send a user here in this state,
            # but it's not impossible so let's handle it politely
            return Response(data={
                'error': 'You are not ready to schedule an exam at this time',
            }, status=status.HTTP_403_FORBIDDEN)

        timestamp = int(now_in_utc().timestamp())
        session_timeout = request.session.get_expiry_age()

        try:
            digest = sso_digest(student_id, timestamp, session_timeout)
        except ImproperlyConfigured:
            return Response(status=500)

        return Response(data={
            'sso_digest': digest,
            'timestamp': timestamp,
            'session_timeout': session_timeout,
            'sso_redirect_url': request.build_absolute_uri('/'),
        })
Exemplo n.º 3
0
 def test_that_no_client_code_raises(self):
     """Verifies that if we don't set the passphrase we raise an exception"""
     with self.assertRaises(ImproperlyConfigured):
         sso_digest(123, 1486069731, 1800)
Exemplo n.º 4
0
 def test_that_no_client_code_raises(self):
     """Verifies that if we don't set the passphrase we raise an exception"""
     with self.assertRaises(ImproperlyConfigured):
         sso_digest(123, 1486069731, 1800)