Ejemplo n.º 1
0
    def test_ssh_generate(self):
        check_data_writable()
        response = self.client.get(reverse('admin-ssh'))
        self.assertContains(response, 'Generate SSH key')

        response = self.client.post(reverse('admin-ssh'),
                                    {'action': 'generate'})
        self.assertContains(response, 'Created new SSH key')
Ejemplo n.º 2
0
    def test_ssh_generate(self):
        check_data_writable()
        response = self.client.get(reverse('admin-ssh'))
        self.assertContains(response, 'Generate SSH key')

        response = self.client.post(
            reverse('admin-ssh'),
            {'action': 'generate'}
        )
        self.assertContains(response, 'Created new SSH key')
Ejemplo n.º 3
0
 def test_create_ssh_wrapper(self):
     check_data_writable()
     filename = os.path.join(settings.DATA_DIR, 'ssh',
                             'ssh-weblate-wrapper')
     create_ssh_wrapper()
     with open(filename, 'r') as handle:
         data = handle.read()
         self.assertTrue(ssh_file('known_hosts') in data)
         self.assertTrue(ssh_file('id_rsa') in data)
         self.assertTrue(settings.DATA_DIR in data)
     self.assertTrue(os.access(filename, os.X_OK))
Ejemplo n.º 4
0
 def test_create_ssh_wrapper(self):
     check_data_writable()
     filename = os.path.join(
         appsettings.DATA_DIR, 'ssh', 'ssh-weblate-wrapper'
     )
     create_ssh_wrapper()
     with open(filename, 'r') as handle:
         data = handle.read()
         self.assertTrue(ssh_file('known_hosts') in data)
         self.assertTrue(ssh_file('id_rsa') in data)
         self.assertTrue(appsettings.DATA_DIR in data)
     self.assertTrue(
         os.access(filename, os.X_OK)
     )
Ejemplo n.º 5
0
 def test_create_ssh_wrapper(self):
     check_data_writable()
     filename = get_wrapper_filename()
     create_ssh_wrapper()
     with open(filename, 'r') as handle:
         data = handle.read()
         self.assertTrue(ssh_file('known_hosts') in data)
         self.assertTrue(ssh_file('id_rsa') in data)
         self.assertTrue(settings.DATA_DIR in data)
     self.assertTrue(os.access(filename, os.X_OK))
     # Second run should not touch the file
     timestamp = os.stat(filename).st_mtime
     create_ssh_wrapper()
     self.assertEqual(timestamp, os.stat(filename).st_mtime)
Ejemplo n.º 6
0
 def test_create_ssh_wrapper(self):
     check_data_writable()
     filename = get_wrapper_filename()
     create_ssh_wrapper()
     with open(filename, 'r') as handle:
         data = handle.read()
         self.assertTrue(ssh_file('known_hosts') in data)
         self.assertTrue(ssh_file('id_rsa') in data)
         self.assertTrue(settings.DATA_DIR in data)
     self.assertTrue(
         os.access(filename, os.X_OK)
     )
     # Second run should not touch the file
     timestamp = os.stat(filename).st_mtime
     create_ssh_wrapper()
     self.assertEqual(timestamp, os.stat(filename).st_mtime)
Ejemplo n.º 7
0
    def test_ssh_add(self):
        check_data_writable()
        try:
            oldpath = os.environ['PATH']
            os.environ['PATH'] = ':'.join(
                (get_test_file(''), os.environ['PATH']))
            # Verify there is button for adding
            response = self.client.get(reverse('admin-ssh'))
            self.assertContains(response, 'Add host key')

            # Add the key
            response = self.client.post(reverse('admin-ssh'), {
                'action': 'add-host',
                'host': 'github.com'
            })
            self.assertContains(response, 'Added host key for github.com')
        finally:
            os.environ['PATH'] = oldpath

        # Check the file contains it
        hostsfile = os.path.join(appsettings.DATA_DIR, 'ssh', 'known_hosts')
        with open(hostsfile) as handle:
            self.assertIn('github.com', handle.read())
Ejemplo n.º 8
0
    def test_ssh_add(self):
        check_data_writable()
        try:
            oldpath = os.environ['PATH']
            os.environ['PATH'] = ':'.join(
                (get_test_file(''), os.environ['PATH'])
            )
            # Verify there is button for adding
            response = self.client.get(reverse('admin-ssh'))
            self.assertContains(response, 'Add host key')

            # Add the key
            response = self.client.post(
                reverse('admin-ssh'),
                {'action': 'add-host', 'host': 'github.com'}
            )
            self.assertContains(response, 'Added host key for github.com')
        finally:
            os.environ['PATH'] = oldpath

        # Check the file contains it
        hostsfile = os.path.join(appsettings.DATA_DIR, 'ssh', 'known_hosts')
        with open(hostsfile) as handle:
            self.assertIn('github.com', handle.read())
Ejemplo n.º 9
0
    return url


def get_versions_list():
    """Return list with version information summary."""
    return (
        [('Weblate', '', GIT_VERSION)] +
        get_versions() +
        get_optional_versions()
    )


def get_versions_string():
    """Return string with version information summary."""
    result = []
    for version in get_versions_list():
        result.append(
            ' * {0} {1}'.format(
                version[0],
                version[2]
            )
        )
    return '\n'.join(result)


# Check for requirements

check_requirements()
check_data_writable()
create_ssh_wrapper()
Ejemplo n.º 10
0
 def test_parse(self):
     check_data_writable()
     shutil.copy(TEST_HOSTS, os.path.join(settings.DATA_DIR, 'ssh'))
     hosts = get_host_keys()
     self.assertEqual(len(hosts), 50)
Ejemplo n.º 11
0
    return url


def get_versions_list():
    """Return list with version information summary."""
    return (
        [('Weblate', '', GIT_VERSION)] +
        get_versions() +
        get_optional_versions()
    )


def get_versions_string():
    """Return string with version information summary."""
    result = []
    for version in get_versions_list():
        result.append(
            ' * {0} {1}'.format(
                version[0],
                version[2]
            )
        )
    return '\n'.join(result)


# Check for requirements

check_requirements()
check_data_writable()
create_ssh_wrapper()
Ejemplo n.º 12
0
 def test_parse(self):
     check_data_writable()
     shutil.copy(TEST_HOSTS, os.path.join(settings.DATA_DIR, 'ssh'))
     hosts = get_host_keys()
     self.assertEqual(len(hosts), 50)