示例#1
0
def login_box_raw(request, return_url='/', auth_systems=None):
    """
  a chunk of HTML that shows the various login options
  """
    default_auth_system_obj = None
    if helios_auth.DEFAULT_AUTH_SYSTEM:
        default_auth_system_obj = AUTH_SYSTEMS[helios_auth.DEFAULT_AUTH_SYSTEM]

    # make sure that auth_systems includes only available and enabled auth systems
    if auth_systems != None:
        enabled_auth_systems = set(auth_systems).intersection(
            set(helios_auth.ENABLED_AUTH_SYSTEMS)).intersection(
                set(AUTH_SYSTEMS.keys()))
    else:
        enabled_auth_systems = set(
            helios_auth.ENABLED_AUTH_SYSTEMS).intersection(
                set(AUTH_SYSTEMS.keys()))

    form = password.LoginForm()

    return render_template_raw(
        request, 'login_box', {
            'enabled_auth_systems': enabled_auth_systems,
            'return_url': return_url,
            'default_auth_system': helios_auth.DEFAULT_AUTH_SYSTEM,
            'default_auth_system_obj': default_auth_system_obj,
            'form': form
        })
示例#2
0
 def test_can_create_election(self):
     """
     check that auth systems have the can_create_election call and that it's true for the common ones
     """
     for auth_system, auth_system_module in list(AUTH_SYSTEMS.items()):
         assert(hasattr(auth_system_module, 'can_create_election'))
         if auth_system != 'clever':
             assert(auth_system_module.can_create_election('foobar', {}))
示例#3
0
 def test_can_create_election(self):
     """
     check that auth systems have the can_create_election call and that it's true for the common ones
     """
     for auth_system, auth_system_module in AUTH_SYSTEMS.items():
         assert hasattr(auth_system_module, "can_create_election")
         if auth_system != "clever":
             assert auth_system_module.can_create_election("foobar", {})
示例#4
0
    def test_eligibility(self):
        """
        test that users are reported as eligible for something

        FIXME: also test constraints on eligibility
        """
        for auth_system, auth_system_module in list(AUTH_SYSTEMS.items()):
            u = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_status_update', info={'name':'Foo Bar Status Update'})

            self.assertTrue(u.is_eligible_for({'auth_system': auth_system}))
示例#5
0
    def test_status_update(self):
        """
        check that a user set up with status update ability reports it as such,
        and otherwise does not report it
        """
        for auth_system, auth_system_module in list(AUTH_SYSTEMS.items()):
            u = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_status_update', info={'name':'Foo Bar Status Update'})

            if hasattr(auth_system_module, 'send_message'):
                self.assertNotEqual(u.update_status_template, None)
            else:
                self.assertEqual(u.update_status_template, None)
示例#6
0
 def test_unique_users(self):
     """
     there should not be two users with the same user_type and user_id
     """
     for auth_system, auth_system_module in list(AUTH_SYSTEMS.items()):
         models.User.objects.create(user_type = auth_system, user_id = 'foobar', info={'name':'Foo Bar'})
         
         def double_insert():
             models.User.objects.create(user_type = auth_system, user_id = 'foobar', info={'name': 'Foo2 Bar'})
             
         self.assertRaises(IntegrityError, double_insert)
         transaction.rollback()
示例#7
0
    def test_create_or_update(self):
        """
        shouldn't create two users, and should reset the password
        """
        for auth_system, auth_system_module in list(AUTH_SYSTEMS.items()):
            u = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_cou', info={'name':'Foo Bar'})

            def double_update_or_create():
                new_name = 'Foo2 Bar'
                u2 = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_cou', info={'name': new_name})

                self.assertEqual(u.id, u2.id)
                self.assertEqual(u2.info['name'], new_name)
示例#8
0
    def test_eq(self):
        for auth_system, auth_system_module in AUTH_SYSTEMS.items():
            u = models.User.update_or_create(
                user_type=auth_system,
                user_id="foobar_eq",
                info={"name": "Foo Bar Status Update"},
            )
            u2 = models.User.update_or_create(
                user_type=auth_system,
                user_id="foobar_eq",
                info={"name": "Foo Bar Status Update"},
            )

            self.assertEqual(u, u2)
示例#9
0
    def test_create_or_update(self):
        """
        shouldn't create two users, and should reset the password
        """
        for auth_system, auth_system_module in AUTH_SYSTEMS.items():
            u = models.User.update_or_create(user_type=auth_system,
                                             user_id="foobar_cou",
                                             info={"name": "Foo Bar"})

            def double_update_or_create():
                new_name = "Foo2 Bar"
                u2 = models.User.update_or_create(user_type=auth_system,
                                                  user_id="foobar_cou",
                                                  info={"name": new_name})

                self.assertEqual(u.id, u2.id)
                self.assertEqual(u2.info["name"], new_name)
示例#10
0
    def test_eq(self):
        for auth_system, auth_system_module in list(AUTH_SYSTEMS.items()):
            u = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_eq', info={'name':'Foo Bar Status Update'})
            u2 = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_eq', info={'name':'Foo Bar Status Update'})

            self.assertEqual(u, u2)