예제 #1
0
 def test_user_delete_invalid_uid(self):
     make_user("123joe", testcase=self)
     make_user("123jane", testcase=self)
     self.assertEqual(2, len(self.plugin.enumerateUsers(login="******")))
     self.assertEqual(1, len(self.plugin.enumerateUsers(login="******")))
     self.plugin.doDeleteUser(userid="123foo")
     self.assertEqual(2, len(self.plugin.enumerateUsers(login="******")))
예제 #2
0
 def test_authentication_user_no_pass_deny(self):
     make_user("joe", testcase=self)
     credentials = {
         "login": "******",
         "password": "******",
     }
     result = self.plugin.authenticateCredentials(credentials)
     self.assertIsNone(result)
 def test_authentication_user_no_pass_deny(self):
     make_user('joe', testcase=self)
     credentials = {
         'login': '******',
         'password': '******',
     }
     result = self.plugin.authenticateCredentials(credentials)
     self.assertIsNone(result)
 def test_authentication_user_same_pass_allow(self):
     make_user('joe', testcase=self, password='******')
     credentials = {
         'login': '******',
         'password': '******'
     }
     result = self.plugin.authenticateCredentials(credentials)
     self.assertEqual(result, ('joe', 'joe'))
예제 #5
0
 def test_authentication_user_same_pass_allow(self):
     make_user('joe', testcase=self, password='******')
     credentials = {
         'login': '******',
         'password': '******'
     }
     result = self.plugin.authenticateCredentials(credentials)
     self.assertEqual(result, ('joe', 'joe'))
예제 #6
0
 def test_authentication_user_no_pass_deny(self):
     make_user('joe', testcase=self)
     credentials = {
         'login': '******',
         'password': '******',
     }
     result = self.plugin.authenticateCredentials(credentials)
     self.assertIsNone(result)
예제 #7
0
    def test_authentication_zope_admin(self):
        self.aclu.userFolderAddUser("admin", "admin", [], [])  # zope admin
        make_user("administrator", testcase=self)  # oauth administrator

        # check searching exact user by plugins: authomatic and ZODBUserManager
        self.assertEqual(
            len(self.aclu.searchUsers(id="adm", exact_match=True)), 0)
        administrator = self.aclu.searchUsers(id="administrator",
                                              exact_match=True)[0]
        admin = self.aclu.searchUsers(id="admin", exact_match=True)[0]
        self.assertEqual(administrator["pluginid"], "authomatic")
        self.assertEqual(admin["pluginid"], "users")
        self.assertEqual(self.aclu.getUserById("admin").getId(), "admin")
    def test_sheet_existing_user_attributes(self):
        # mock a user
        PNAME = 'mockhub'
        authomatic_result = MockResult(
            user=self._make_authomatic_user(provider_name=PNAME),
            provider=MockResult(name=PNAME)
        )
        uis = make_user('mustermann')
        uis.handle_result(authomatic_result)

        # mock cfg
        with mock.patch(
            'pas.plugins.authomatic.useridentities.authomatic_cfg'
        ) as cfg:
            cfg.return_value = self._make_cfg(PNAME)
            sheet = uis.propertysheet
        self.assertIsInstance(sheet, UserPropertySheet)
        self.assertEqual(
            sheet.getProperty('home_page'),
            u'http://peterhudec.github.io/authomatic/'
        )
        self.assertEqual(sheet.getProperty('fullname'), u'Andrew Pipkin')
        self.assertEqual(
            sheet.getProperty('email'),
            u'*****@*****.**'
        )
    def test_sheet_existing_user_attributes(self):
        # mock a user
        PNAME = 'mockhub'
        authomatic_result = MockResult(
            user=self._make_authomatic_user(provider_name=PNAME),
            provider=MockResult(name=PNAME)
        )
        uis = make_user('mustermann')
        uis.handle_result(authomatic_result)

        # mock cfg
        with mock.patch(
            'pas.plugins.authomatic.useridentities.authomatic_cfg'
        ) as cfg:
            cfg.return_value = self._make_cfg(PNAME)
            sheet = uis.propertysheet
        self.assertIsInstance(sheet, UserPropertySheet)
        self.assertEqual(
            sheet.getProperty('home_page'),
            u'http://peterhudec.github.io/authomatic/'
        )
        self.assertEqual(sheet.getProperty('fullname'), u'Andrew Pipkin')
        self.assertEqual(
            sheet.getProperty('email'),
            u'*****@*****.**'
        )
예제 #10
0
    def test_user_enumaration(self):
        make_user("123joe", testcase=self)
        make_user("123jane", testcase=self)
        make_user("123wily", testcase=self)
        make_user("123willi", testcase=self)
        # check by user id
        self.assertEqual(
            [{
                "login": "******",
                "pluginid": "authomatic",
                "id": "123joe"
            }],
            self.plugin.enumerateUsers(id="123joe", exact_match=True),
        )
        self.assertEqual(
            [{
                "login": "******",
                "pluginid": "authomatic",
                "id": "123joe"
            }],
            self.plugin.enumerateUsers(id="123joe"),
        )
        self.assertEqual(4, len(self.plugin.enumerateUsers(id="123")))
        self.assertEqual(
            0, len(self.plugin.enumerateUsers(id="123", exact_match=True)))
        self.assertEqual(2, len(self.plugin.enumerateUsers(id="123j")))
        self.assertEqual(
            0, len(self.plugin.enumerateUsers(id="123", exact_match=True)))

        # check by login
        self.assertEqual(
            [{
                "login": "******",
                "pluginid": "authomatic",
                "id": "123joe"
            }],
            self.plugin.enumerateUsers(login="******", exact_match=True),
        )
        self.assertEqual(
            [{
                "login": "******",
                "pluginid": "authomatic",
                "id": "123joe"
            }],
            self.plugin.enumerateUsers(login="******"),
        )
        self.assertEqual(2, len(self.plugin.enumerateUsers(login="******")))
        self.assertEqual(2, len(self.plugin.enumerateUsers(login="******")))
        # https://github.com/collective/pas.plugins.authomatic/pull/25/commits/5c0f6b1dc76a0d769e35a845ce4c4dd4307655ba
        # Due to the workarround, now the enumerateUsers plugin doesn't return
        # any users when searching with an empty query
        self.assertEqual(0, len(self.plugin.enumerateUsers()))
    def test_user_enumaration(self):
        make_user('123joe', testcase=self)
        make_user('123jane', testcase=self)
        make_user('123wily', testcase=self)
        make_user('123willi', testcase=self)
        # check by user id
        self.assertEqual(
            [{'login': '******', 'pluginid': 'authomatic', 'id': '123joe'}],
            self.plugin.enumerateUsers(id='123joe', exact_match=True)
        )
        self.assertEqual(
            [{'login': '******', 'pluginid': 'authomatic', 'id': '123joe'}],
            self.plugin.enumerateUsers(id='123joe')
        )
        self.assertEqual(
            4,
            len(self.plugin.enumerateUsers(id='123'))
        )
        self.assertEqual(
            2,
            len(self.plugin.enumerateUsers(id='123j'))
        )

        # check by login
        self.assertEqual(
            [{'login': '******', 'pluginid': 'authomatic', 'id': '123joe'}],
            self.plugin.enumerateUsers(login='******', exact_match=True)
        )
        self.assertEqual(
            [{'login': '******', 'pluginid': 'authomatic', 'id': '123joe'}],
            self.plugin.enumerateUsers(login='******')
        )
        self.assertEqual(
            2,
            len(self.plugin.enumerateUsers(login='******'))
        )
        self.assertEqual(
            2,
            len(self.plugin.enumerateUsers(login='******'))
        )
        # https://github.com/collective/pas.plugins.authomatic/pull/25/commits/5c0f6b1dc76a0d769e35a845ce4c4dd4307655ba
        # Due to the workarround, now the enumerateUsers plugin doesn't return
        # any users when searching with an empty query
        self.assertEqual(
            0,
            len(self.plugin.enumerateUsers())
        )
예제 #12
0
    def test_user_enumaration(self):
        make_user('123joe', testcase=self)
        make_user('123jane', testcase=self)
        make_user('123wily', testcase=self)
        make_user('123willi', testcase=self)
        # check by user id
        self.assertEqual(
            [{'login': '******', 'pluginid': 'authomatic', 'id': '123joe'}],
            self.plugin.enumerateUsers(id='123joe', exact_match=True)
        )
        self.assertEqual(
            [{'login': '******', 'pluginid': 'authomatic', 'id': '123joe'}],
            self.plugin.enumerateUsers(id='123joe')
        )
        self.assertEqual(
            4,
            len(self.plugin.enumerateUsers(id='123'))
        )
        self.assertEqual(
            2,
            len(self.plugin.enumerateUsers(id='123j'))
        )

        # check by login
        self.assertEqual(
            [{'login': '******', 'pluginid': 'authomatic', 'id': '123joe'}],
            self.plugin.enumerateUsers(login='******', exact_match=True)
        )
        self.assertEqual(
            [{'login': '******', 'pluginid': 'authomatic', 'id': '123joe'}],
            self.plugin.enumerateUsers(login='******')
        )
        self.assertEqual(
            2,
            len(self.plugin.enumerateUsers(login='******'))
        )
        self.assertEqual(
            2,
            len(self.plugin.enumerateUsers(login='******'))
        )
        # https://github.com/collective/pas.plugins.authomatic/pull/25/commits/5c0f6b1dc76a0d769e35a845ce4c4dd4307655ba
        # Due to the workarround, now the enumerateUsers plugin doesn't return
        # any users when searching with an empty query
        self.assertEqual(
            0,
            len(self.plugin.enumerateUsers())
        )
예제 #13
0
    def test_sheet_existing_user_attributes(self):
        # mock a user
        PNAME = "mockhub"
        authomatic_result = MockResult(
            user=self._make_authomatic_user(provider_name=PNAME),
            provider=MockResult(name=PNAME),
        )
        uis = make_user("mustermann")
        uis.handle_result(authomatic_result)

        # mock cfg
        with mock.patch(
                "pas.plugins.authomatic.useridentities.authomatic_cfg") as cfg:
            cfg.return_value = self._make_cfg(PNAME)
            sheet = uis.propertysheet
        self.assertIsInstance(sheet, UserPropertySheet)
        self.assertEqual(sheet.getProperty("home_page"),
                         "http://peterhudec.github.io/authomatic/")
        self.assertEqual(sheet.getProperty("fullname"), "Andrew Pipkin")
        self.assertEqual(sheet.getProperty("email"), "*****@*****.**")
예제 #14
0
 def test_authentication_user_same_pass_allow(self):
     make_user("joe", testcase=self, password="******")
     credentials = {"login": "******", "password": "******"}
     result = self.plugin.authenticateCredentials(credentials)
     self.assertEqual(result, ("joe", "joe"))