示例#1
0
    def test_credentials_authentication_from_a_not_existig_client_returns_none(self):
        create_client('client1', ip_address='192.186.1.1')

        self.set_params_for_remote_request(clientid='client3', client_ip='192.168.1.1')

        creds = extract_user(self.portal, self.portal.REQUEST)
        self.assertEquals(None, authenticate_credentials(self.portal, creds))
示例#2
0
    def test_credentials_authentication_for_invalid_ip_returns_none(self):
        create_client('client1', ip_address='192.186.1.1')

        self.set_params_for_remote_request(client_ip='192.168.1.233')

        creds = extract_user(self.portal, self.portal.REQUEST)
        self.assertEquals(None, authenticate_credentials(self.portal, creds))
示例#3
0
    def test_credentials_authentication_for_invalid_ip_returns_none(self):
        create(Builder('admin_unit')
               .id('client1')
               .having(title=u'Client1', ip_address='192.186.1.1'))

        self.set_params_for_remote_request(client_ip='192.168.1.233')

        creds = extract_user(self.portal, self.portal.REQUEST)
        self.assertEquals(None, authenticate_credentials(self.portal, creds))
示例#4
0
    def test_after_successfully_credentials_authentication_the_request_provides_the_internal_request_layer(self):
        client_ip = '192.168.1.233'
        create_client('client1', ip_address=client_ip)
        self.set_params_for_remote_request(client_ip=client_ip)

        creds = extract_user(self.portal, self.portal.REQUEST)
        authenticate_credentials(self.portal, creds)

        self.assertTrue(
            IInternalOpengeverRequestLayer.providedBy(self.portal.REQUEST))
示例#5
0
    def test_after_successfully_credentials_authentication_the_request_provides_the_internal_request_layer(
            self):
        client_ip = '192.168.1.233'
        create_client('client1', ip_address=client_ip)
        self.set_params_for_remote_request(client_ip=client_ip)

        creds = extract_user(self.portal, self.portal.REQUEST)
        authenticate_credentials(self.portal, creds)

        self.assertTrue(
            IInternalOpengeverRequestLayer.providedBy(self.portal.REQUEST))
示例#6
0
    def test_credentials_authentication_works_also_with_a_coma_sepereted_list(self):
        """The plugin should also work with a client with a comma
        seperated list of ip_adresses. """

        create_client('client1', ip_address='192.168.1.53,192.168.1.2')

        self.set_params_for_remote_request(client_ip='192.168.1.2')

        creds = extract_user(self.portal, self.portal.REQUEST)
        self.assertEquals(
            ('hugo.boss', 'hugo.boss'),
            authenticate_credentials(self.portal, creds))
示例#7
0
    def test_credentials_authentication_works_also_with_a_coma_sepereted_list(
            self):
        """The plugin should also work with a client with a comma
        seperated list of ip_adresses. """

        create_client('client1', ip_address='192.168.1.53,192.168.1.2')

        self.set_params_for_remote_request(client_ip='192.168.1.2')

        creds = extract_user(self.portal, self.portal.REQUEST)
        self.assertEquals(('hugo.boss', 'hugo.boss'),
                          authenticate_credentials(self.portal, creds))
示例#8
0
    def test_after_successfully_credentials_authentication_the_request_provides_the_disable_csrf_protection_layer(self):
        ip = '192.168.1.233'
        create(Builder('admin_unit')
               .id('client1')
               .having(title=u'Client1', ip_address=ip))

        self.set_params_for_remote_request(client_ip=ip)

        creds = extract_user(self.portal, self.portal.REQUEST)
        authenticate_credentials(self.portal, creds)

        self.assertTrue(IDisableCSRFProtection.providedBy(self.portal.REQUEST))
示例#9
0
    def test_credentials_authentication_from_a_not_existig_client_returns_none(
            self):
        ip_address = '192.186.1.1'

        create(
            Builder('admin_unit').id('client1').having(title=u'Client1',
                                                       ip_address=ip_address))

        self.set_params_for_remote_request(clientid='client3',
                                           client_ip='192.168.1.1')

        creds = extract_user(self.portal, self.portal.REQUEST)
        self.assertEquals(None, authenticate_credentials(self.portal, creds))
示例#10
0
    def test_after_successfully_credentials_authentication_the_request_provides_the_disable_csrf_protection_layer(
            self):
        ip = '192.168.1.233'
        create(
            Builder('admin_unit').id('client1').having(title=u'Client1',
                                                       ip_address=ip))

        self.set_params_for_remote_request(client_ip=ip)

        creds = extract_user(self.portal, self.portal.REQUEST)
        authenticate_credentials(self.portal, creds)

        self.assertTrue(IDisableCSRFProtection.providedBy(self.portal.REQUEST))
示例#11
0
    def test_successfull_credentials_authentication_returns_a_tuple_with_the_userid(self):
        ip = '192.168.1.233'
        create_client('client1', ip_address=ip)
        self.set_params_for_remote_request(client_ip=ip)

        creds = extract_user(self.portal, self.portal.REQUEST)
        self.assertEquals(
            {'login': '******',
             'remote_host': 'http://nohost/client1',
             'id': 'hugo.boss',
             'remote_address': '192.168.1.233', 'cid': 'client1'},
            creds)

        self.assertEquals(
            ('hugo.boss', 'hugo.boss'),
            authenticate_credentials(self.portal, creds))
示例#12
0
    def test_successfull_credentials_authentication_returns_a_tuple_with_the_userid(
            self):
        ip = '192.168.1.233'
        create_client('client1', ip_address=ip)
        self.set_params_for_remote_request(client_ip=ip)

        creds = extract_user(self.portal, self.portal.REQUEST)
        self.assertEquals(
            {
                'login': '******',
                'remote_host': 'http://nohost/client1',
                'id': 'hugo.boss',
                'remote_address': '192.168.1.233',
                'cid': 'client1'
            }, creds)

        self.assertEquals(('hugo.boss', 'hugo.boss'),
                          authenticate_credentials(self.portal, creds))