Beispiel #1
0
 def test_get_callbacks(self):
     """
     When callbacks are configured, ``get_callbacks()`` should return
     a list of the configured callbacks and an empty list otherwise.
     """
     self.assertEqual(get_callbacks('http://www.example.com'), ['mama_cas.callbacks.user_name_attributes'])
     self.assertEqual(get_callbacks('http://example.org'), [])
 def test_get_callbacks(self):
     """
     When callbacks are configured, ``get_callbacks()`` should return
     a list of the configured callbacks and an empty list otherwise.
     """
     self.assertEqual(get_callbacks('http://www.example.com'),
                      ['mama_cas.callbacks.user_name_attributes'])
     self.assertEqual(get_callbacks('http://example.org'), [])
Beispiel #3
0
def get_attributes(user, service):
    """
    Return a dictionary of user attributes from the set of configured
    callback functions.
    """
    attributes = {}
    for path in get_callbacks(service):
        callback = import_string(path)
        attributes.update(callback(user, service))
    return attributes
Beispiel #4
0
def get_attributes(user, service):
    """
    Return a dictionary of user attributes from the set of configured
    callback functions.
    """
    attributes = {}
    for path in get_callbacks(service):
        callback = import_string(path)
        attributes.update(callback(user, service))
    return attributes
    def test_invalid_custom_backend(self):
        """
        Test that a custom service backend without properly defined
        attributes raises ``NotImplementedError``
        """

        with self.assertRaises(NotImplementedError):
            service_allowed('http://www.example.com')

        with self.assertRaises(NotImplementedError):
            get_callbacks('http://www.example.com')

        with self.assertRaises(NotImplementedError):
            get_logout_url('http://www.example.com')

        with self.assertRaises(NotImplementedError):
            logout_allowed('http://www.example.com')

        with self.assertRaises(NotImplementedError):
            proxy_allowed('http://www.example.com')
Beispiel #6
0
 def handle(self, **options):
     service = options['service']
     pgturl = options['pgturl']
     if service_allowed(service):
         self.stdout.write('Valid Service: %s' % service)
         self.stdout.write('Proxy Allowed: %s' % proxy_allowed(service))
         if pgturl:
             self.stdout.write('Proxy Callback Allowed: %s' %
                               proxy_callback_allowed(service, pgturl))
         self.stdout.write('Logout Allowed: %s' % logout_allowed(service))
         self.stdout.write('Logout URL: %s' % get_logout_url(service))
         self.stdout.write('Callbacks: %s' % get_callbacks(service))
     else:
         self.stdout.write(self.style.ERROR('Invalid Service: %s' %
                                            service))
Beispiel #7
0
    def handle(self, **options):
        self.service = options['service']
        self.pgturl = options['pgturl']
        self.verbosity = options['verbosity']

        if service_allowed(self.service):
            try:
                self.stdout.write(self.style.SUCCESS("Valid service: %s" % self.service))
            except AttributeError:
                # Django 1.8 does not have the "Success" style
                self.stdout.write(self.style.SQL_FIELD("Valid service: %s" % self.service))
            if self.verbosity >= 1:
                self.format_output('Proxy allowed', proxy_allowed(self.service))
                if self.pgturl:
                    self.format_output('Proxy callback allowed', proxy_callback_allowed(self.service, self.pgturl))
                self.format_output('Logout allowed', logout_allowed(self.service))
                self.format_output('Logout URL', get_logout_url(self.service))
                self.format_output('Callbacks', ', '.join(get_callbacks(self.service)))
            if self.verbosity >= 2:
                self.format_output('Backend', get_backend_path(self.service))
        else:
            self.stdout.write(self.style.ERROR("Invalid service: %s" % self.service))