예제 #1
0
                mock_search.assert_called_with(expected_query)
                mock_create.assert_has_calls([call(1), call(2)])
                self.assertEqual(result, [3, 3])


# Integration Tests

# Get data from environment
LDAP_USERNAME = getenv('LDAP_TEST_USERNAME')
LDAP_PASSWORD = getenv('LDAP_TEST_PASSWORD')
LDAP_USER_NETHZ = getenv('LDAP_TEST_USER_NETHZ')
LDAP_USER_PASSWORD = getenv('LDAP_TEST_USER_PASSWORD')

requires_credentials = skip_if_false(LDAP_USERNAME and LDAP_PASSWORD,
                                     "LDAP test requires environment "
                                     "variables 'LDAP_TEST_USERNAME' and "
                                     "'LDAP_TEST_PASSWORD")


class LdapIntegrationTest(WebTest):
    """Tests for LDAP connection."""

    def setUp(self, *args, **kwargs):
        """Extended setUp.

        Load environment variables and test general ldap connection.
        """
        extra_config = {
            'LDAP_USERNAME': LDAP_USERNAME,
            'LDAP_PASSWORD': LDAP_PASSWORD,
        }
예제 #2
0
                    [call(address, '') for address in receive_from],
                    any_order=True)

    def test_remote_remove_called(self):
        """Test that removing the file over ssh is attempted."""
        addresses = ['a', 'b']
        with patch('amivapi.groups.mailing_lists.ssh_remove') as remove:
            with self.app.app_context():
                remove_files(addresses)
                remove.assert_has_calls(
                    [call(address) for address in addresses], any_order=True)


# Decorator to mark tests to be skipped if ssh envvars are missing.
skip_without_address = skip_if_false(
    getenv('SSH_TEST_ADDRESS'), "SSH test requires environment variable" +
    " 'REMOTE_MAILING_LIST_ADDRESS'")


class SSHIntegrationTest(WebTestNoAuth):
    """Test the actual ssh connection.

    You need to set environment variables to run these tests:

    SSH_TEST_ADDRESS: [email protected]
    SSH_TEST_KEYFILE: path to your keyfile, optional
    SSH_TEST_DIRECTORY: remote path, default: '/tmp/amivapi-test/'

    py.test will inform you if the tests are skipped.
    """
    def setUp(self):
예제 #3
0
                mock_search.assert_called_with(expected_query)
                mock_create.assert_has_calls([call(1), call(2)])
                self.assertEqual(result, [3, 3])


# Integration Tests

# Get data from environment
LDAP_USERNAME = getenv('LDAP_TEST_USERNAME')
LDAP_PASSWORD = getenv('LDAP_TEST_PASSWORD')
LDAP_USER_NETHZ = getenv('LDAP_TEST_USER_NETHZ')
LDAP_USER_PASSWORD = getenv('LDAP_TEST_USER_PASSWORD')

requires_credentials = skip_if_false(
    LDAP_USERNAME and LDAP_PASSWORD, "LDAP test requires environment "
    "variables 'LDAP_TEST_USERNAME' and "
    "'LDAP_TEST_PASSWORD")


class LdapIntegrationTest(WebTest):
    """Tests for LDAP connection."""
    def setUp(self, *args, **kwargs):
        """Extended setUp.

        Load environment variables and test general ldap connection.
        """
        extra_config = {
            'LDAP_USERNAME': LDAP_USERNAME,
            'LDAP_PASSWORD': LDAP_PASSWORD,
        }
        extra_config.update(kwargs)