Exemplo n.º 1
0
    def test_create_meta_with_declared_icon_and_setup(self):
        gui_path = os.path.join('setup', 'gui')
        os.makedirs(gui_path)
        icon_content = b'this is the icon'
        with open(os.path.join(gui_path, 'icon.png'), 'wb') as f:
            f.write(icon_content)

        open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
        self.config_data['icon'] = 'my-icon.png'

        meta.create(self.config_data)

        expected_icon = os.path.join(self.meta_dir, 'gui', 'icon.png')
        self.assertTrue(os.path.exists(expected_icon),
                        'icon.png was not setup correctly')
        with open(expected_icon, 'rb') as f:
            self.assertEqual(f.read(), icon_content)

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)
        self.assertFalse('icon' in y,
                         'icon found in snap.yaml {}'.format(y))
Exemplo n.º 2
0
    def test_create_meta_without_config(self, mock_the_open, mock_wrap_exe):
        del self.config_data["config"]

        meta.create(self.config_data, ["amd64"])

        self.mock_makedirs.assert_called_once_with(self.meta_dir, exist_ok=True)
        mock_the_open.assert_has_calls(self.expected_open_calls)
Exemplo n.º 3
0
    def test_create_meta_with_app_with_security_policy(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
        open(os.path.join(os.curdir, 'stub-sec'), 'w').close()
        self.config_data['apps'] = {
            'app1': {
                'command': 'app1.sh',
                'uses': ['migration'],
            },
        }
        self.config_data['uses'] = {
            'migration': {
                'type': 'migration-skill',
                'security-policy': {
                    'apparmor': 'stub-sec',
                    'seccomp': 'stub-sec',
                },
            },
        }

        meta.create(self.config_data)

        app1_wrapper_path = os.path.join(self.snap_dir, 'command-app1.wrapper')
        self.assertTrue(
            os.path.exists(app1_wrapper_path),
            'the wrapper for app1 was not setup correctly')

        sec_path = os.path.join(self.meta_dir, 'stub-sec')
        self.assertTrue(
            os.path.exists(sec_path),
            'the security-policies for app1 were not setup correctly')

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)

        expected = {'architectures': ['amd64'],
                    'apps': {
                        'app1': {
                            'command': 'command-app1.wrapper',
                            'uses': ['migration'],
                        },
                    },
                    'uses': {
                        'migration': {
                            'type': 'migration-skill',
                            'security-policy': {
                                'apparmor': 'meta/stub-sec',
                                'seccomp': 'meta/stub-sec',
                            },
                        }
                    },
                    'description': 'my description',
                    'summary': 'my summary',
                    'name': 'my-package',
                    'version': '1.0'}

        self.assertEqual(y, expected)
Exemplo n.º 4
0
    def test_create_meta(self, mock_the_open, mock_wrap_exe):
        meta.create(self.config_data, ['amd64'])

        self.mock_makedirs.assert_has_calls([
            call(self.meta_dir, exist_ok=True),
            call(self.hooks_dir),
        ])

        mock_the_open.assert_has_calls(self.expected_open_calls)
        mock_wrap_exe.assert_has_calls([
            call(
                '$SNAP_APP_PATH/bin/bash',
                os.path.join(os.path.abspath(os.curdir),
                             'snap/bin/bash.wrapper'),
            ),
            call(
                'bin/config',
                os.path.join(self.hooks_dir, 'config'),
                args=[],
                cwd='$SNAP_APP_PATH',
            ),
        ])
        self.mock_copyfile.assert_has_calls([
            call('my-icon.png', os.path.join(self.meta_dir,
                 'my-icon.png')),
            call('file.apparmor', os.path.join(self.meta_dir,
                 'file.apparmor')),
            call('file.seccomp', os.path.join(self.meta_dir,
                 'file.seccomp')),
        ])
Exemplo n.º 5
0
    def test_create_meta(self, mock_the_open, mock_wrap_exe):
        meta.create(self.config_data, ['amd64'])

        self.mock_makedirs.assert_has_calls([
            call(self.meta_dir, exist_ok=True),
            call(self.hooks_dir),
        ])

        self.mock_rename.assert_has_calls([
            call(os.path.join(self.snap_dir, 'bin', 'config.wrapper'),
                 os.path.join(self.hooks_dir, 'config')),
        ])

        mock_the_open.assert_has_calls(self.expected_open_calls)
        mock_wrap_exe.assert_has_calls([
            call(
                '$SNAP_APP_PATH/bin/bash',
                os.path.join(self.snap_dir, 'bin', 'bash.wrapper'),
                args=None, shebang=None
            ),
            call(
                '$SNAP_APP_PATH/bin/config',
                os.path.join(self.snap_dir, 'bin', 'config.wrapper'),
                args=[], shebang=None,
            ),
        ])
        self.mock_copyfile.assert_has_calls([
            call('my-icon.png', os.path.join(self.meta_dir,
                 'my-icon.png')),
            call('file.apparmor', os.path.join(self.meta_dir,
                 'file.apparmor')),
            call('file.seccomp', os.path.join(self.meta_dir,
                 'file.seccomp')),
        ])
Exemplo n.º 6
0
    def test_create_meta_with_vararg_config(self, mock_the_open,
                                            mock_wrap_exe):
        self.config_data['config'] = 'python3 my.py --config'

        meta.create(self.config_data, ['amd64'])

        self.mock_makedirs.assert_has_calls([
            call(self.meta_dir, exist_ok=True),
            call(self.hooks_dir),
        ])

        self.mock_rename.assert_has_calls([
            call(os.path.join(self.snap_dir, 'python3.wrapper'),
                 os.path.join(self.hooks_dir, 'config')),
        ])

        mock_the_open.assert_has_calls(self.expected_open_calls)
        mock_wrap_exe.assert_has_calls([
            call(
                '$SNAP_APP_PATH/bin/bash',
                os.path.join(os.path.abspath(os.curdir),
                             'snap/bin/bash.wrapper'),
                args=None, shebang=None,
            ),
            call(
                '$SNAP_APP_PATH/python3',
                os.path.join(self.snap_dir, 'python3.wrapper'),
                args=['my.py', '--config'], shebang=None,
            ),
        ])
Exemplo n.º 7
0
    def test_create_meta_with_declared_icon_and_setup(self):
        fake_logger = fixtures.FakeLogger(level=logging.INFO)
        self.useFixture(fake_logger)

        gui_path = os.path.join('setup', 'gui')
        os.makedirs(gui_path)
        icon_content = b'this is the icon'
        with open(os.path.join(gui_path, 'icon.png'), 'wb') as f:
            f.write(icon_content)

        open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
        self.config_data['icon'] = 'my-icon.png'

        meta.create(self.config_data)

        expected_icon = os.path.join(self.meta_dir, 'gui', 'icon.png')
        self.assertTrue(os.path.exists(expected_icon),
                        'icon.png was not setup correctly')
        with open(expected_icon, 'rb') as f:
            self.assertEqual(f.read(), icon_content)

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')

        self.assertTrue(
            "DEPRECATED: 'icon' defined in snapcraft.yaml"
            in fake_logger.output, 'Missing deprecation message for icon')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)
        self.assertFalse('icon' in y,
                         'icon found in snap.yaml {}'.format(y))
Exemplo n.º 8
0
    def test_create_meta_with_app(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
        self.config_data['apps'] = {
            'app1': {
                'command': 'app1.sh'
            },
        }

        meta.create(self.config_data)

        app1_wrapper_path = os.path.join(self.snap_dir, 'command-app1.wrapper')
        self.assertTrue(os.path.exists(app1_wrapper_path),
                        'the wrapper for app1 was not setup correctly')

        self.assertTrue(os.path.exists(self.snap_yaml),
                        'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)

        expected = {
            'architectures': ['amd64'],
            'apps': {
                'app1': {
                    'command': 'command-app1.wrapper',
                },
            },
            'description': 'my description',
            'summary': 'my summary',
            'name': 'my-package',
            'version': '1.0'
        }

        self.assertEqual(y, expected)
Exemplo n.º 9
0
    def test_create_meta_with_vararg_config(self, mock_the_open,
                                            mock_wrap_exe):
        self.config_data['config'] = 'python3 my.py --config'

        meta.create(self.config_data, ['amd64'])

        self.mock_makedirs.assert_has_calls([
            call(self.meta_dir, exist_ok=True),
            call(self.hooks_dir),
        ])

        mock_the_open.assert_has_calls(self.expected_open_calls)
        mock_wrap_exe.assert_has_calls([
            call(
                '$SNAP_APP_PATH/bin/bash',
                os.path.join(os.path.abspath(os.curdir),
                             'snap/bin/bash.wrapper'),
            ),
            call(
                'python3',
                os.path.join(self.hooks_dir, 'config'),
                args=['my.py', '--config'],
                cwd='$SNAP_APP_PATH',
            ),
        ])
Exemplo n.º 10
0
    def test_create_meta_with_app(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
        self.config_data['apps'] = {
            'app1': {'command': 'app1.sh'},
        }

        meta.create(self.config_data)

        app1_wrapper_path = os.path.join(self.snap_dir, 'command-app1.wrapper')
        self.assertTrue(
            os.path.exists(app1_wrapper_path),
            'the wrapper for app1 was not setup correctly')

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)

        expected = {'architectures': ['amd64'],
                    'apps': {
                        'app1': {
                            'command': 'command-app1.wrapper',
                        },
                    },
                    'description': 'my description',
                    'summary': 'my summary',
                    'name': 'my-package',
                    'version': '1.0'}

        self.assertEqual(y, expected)
Exemplo n.º 11
0
    def test_create_meta_with_implicit_migration_skill(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
        open(os.path.join(os.curdir, 'stub-sec'), 'w').close()
        self.config_data['apps'] = {
            'app1': {
                'command': 'app1.sh',
                'uses': ['migration-skill'],
            },
        }
        self.config_data['uses'] = {
            'migration-skill': {
                'security-policy': {
                    'apparmor': 'stub-sec',
                    'seccomp': 'stub-sec',
                },
            },
        }

        meta.create(self.config_data)

        app1_wrapper_path = os.path.join(self.snap_dir, 'command-app1.wrapper')
        self.assertTrue(os.path.exists(app1_wrapper_path),
                        'the wrapper for app1 was not setup correctly')

        sec_path = os.path.join(self.meta_dir, 'stub-sec')
        self.assertTrue(
            os.path.exists(sec_path),
            'the security-policies for app1 were not setup correctly')

        self.assertTrue(os.path.exists(self.snap_yaml),
                        'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)

        expected = {
            'architectures': ['amd64'],
            'apps': {
                'app1': {
                    'command': 'command-app1.wrapper',
                    'uses': ['migration-skill'],
                },
            },
            'uses': {
                'migration-skill': {
                    'security-policy': {
                        'apparmor': 'meta/stub-sec',
                        'seccomp': 'meta/stub-sec',
                    },
                }
            },
            'description': 'my description',
            'summary': 'my summary',
            'name': 'my-package',
            'version': '1.0'
        }

        self.assertEqual(y, expected)
Exemplo n.º 12
0
    def test_create_meta_without_config(self, mock_the_open, mock_wrap_exe):
        del self.config_data['config']

        meta.create(self.config_data, ['amd64'])

        self.mock_makedirs.assert_called_once_with(self.meta_dir,
                                                   exist_ok=True)
        mock_the_open.assert_has_calls(self.expected_open_calls)
Exemplo n.º 13
0
    def test_create_meta_with_config(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'config.sh'), 'w').close()
        self.config_data['config'] = 'config.sh'

        meta.create(self.config_data)

        self.assertTrue(os.path.exists(os.path.join(self.hooks_dir, 'config')),
                        'the config was not setup correctly')
Exemplo n.º 14
0
    def test_create_meta_with_config(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'config.sh'), 'w').close()
        self.config_data['config'] = 'config.sh'

        meta.create(self.config_data)

        self.assertTrue(
            os.path.exists(os.path.join(self.hooks_dir, 'config')),
            'the config was not setup correctly')
Exemplo n.º 15
0
    def test_create_no_change_if_not_migration_skill(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
        open(os.path.join(os.curdir, 'stub-sec'), 'w').close()
        self.config_data['apps'] = {
            'app1': {
                'command': 'app1.sh',
                'uses': ['migration'],
            },
        }
        self.config_data['uses'] = {
            'migration': {
                'type': 'not-a-migration-skillz',
                'security-policy': {
                    'apparmor': 'stub-sec',
                    'seccomp': 'stub-sec',
                },
            },
        }

        meta.create(self.config_data)

        self.assertTrue(os.path.exists(self.snap_yaml),
                        'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)

        expected = {
            'architectures': ['amd64'],
            'apps': {
                'app1': {
                    'command': 'command-app1.wrapper',
                    'uses': ['migration'],
                },
            },
            'uses': {
                'migration': {
                    'type': 'not-a-migration-skillz',
                    'security-policy': {
                        'apparmor': 'stub-sec',
                        'seccomp': 'stub-sec',
                    },
                }
            },
            'description': 'my description',
            'summary': 'my summary',
            'name': 'my-package',
            'version': '1.0'
        }

        self.assertEqual(y, expected)
Exemplo n.º 16
0
def snap(args):
    cmd(args)

    # This check is to support manual assembly.
    if not os.path.exists(os.path.join(common.get_snapdir(), 'meta')):
        arches = [snapcraft.common.get_arch(), ]

        config = _load_config()

        # FIXME this should be done in a more contained manner
        common.env = config.snap_env()

        meta.create(config.data, arches)
Exemplo n.º 17
0
def snap(args):
    cmd(args)

    # This check is to support manual assembly.
    if not os.path.exists(os.path.join(common.get_snapdir(), 'meta')):
        arches = [snapcraft.common.get_arch(), ]

        config = _load_config()

        # FIXME this should be done in a more contained manner
        common.env = config.snap_env()

        meta.create(config.data, arches)
Exemplo n.º 18
0
    def test_create_meta_with_declared_icon_and_setup_ran_twice_ok(self):
        gui_path = os.path.join('setup', 'gui')
        os.makedirs(gui_path)
        icon_content = b'this is the icon'
        with open(os.path.join(gui_path, 'icon.png'), 'wb') as f:
            f.write(icon_content)

        open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
        self.config_data['icon'] = 'my-icon.png'

        meta.create(self.config_data)

        # Running again should be good
        meta.create(self.config_data)
Exemplo n.º 19
0
    def test_create_no_change_if_not_migration_skill(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'app1.sh'), 'w').close()
        open(os.path.join(os.curdir, 'stub-sec'), 'w').close()
        self.config_data['apps'] = {
            'app1': {
                'command': 'app1.sh',
                'uses': ['migration'],
            },
        }
        self.config_data['uses'] = {
            'migration': {
                'type': 'migration-skillz',
                'security-policy': {
                    'apparmor': 'stub-sec',
                    'seccomp': 'stub-sec',
                },
            },
        }

        meta.create(self.config_data)

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)

        expected = {'architectures': ['amd64'],
                    'apps': {
                        'app1': {
                            'command': 'command-app1.wrapper',
                            'uses': ['migration'],
                        },
                    },
                    'uses': {
                        'migration': {
                            'type': 'migration-skillz',
                            'security-policy': {
                                'apparmor': 'stub-sec',
                                'seccomp': 'stub-sec',
                            },
                        }
                    },
                    'description': 'my description',
                    'summary': 'my summary',
                    'name': 'my-package',
                    'version': '1.0'}

        self.assertEqual(y, expected)
Exemplo n.º 20
0
def snap(args):
    cmd(args)

    config = _load_config()
    # TODO move all this to meta.create
    if 'architectures' in config.data:
        arches = config.data['architectures']
    else:
        arches = [snapcraft.common.get_arch(), ]

    # FIXME this should be done in a more contained manner
    common.env = config.snap_env()

    meta.create(config.data, arches)
Exemplo n.º 21
0
    def test_create_meta_with_vararg_config(self, mock_the_open, mock_wrap_exe):
        self.config_data["config"] = "python3 my.py --config"

        meta.create(self.config_data, ["amd64"])

        self.mock_makedirs.assert_has_calls([call(self.meta_dir, exist_ok=True), call(self.hooks_dir)])

        mock_the_open.assert_has_calls(self.expected_open_calls)
        mock_wrap_exe.assert_has_calls(
            [
                call("$SNAP_APP_PATH/bin/bash", os.path.join(os.path.abspath(os.curdir), "snap/bin/bash.wrapper")),
                call(
                    "python3", os.path.join(self.hooks_dir, "config"), args=["my.py", "--config"], cwd="$SNAP_APP_PATH"
                ),
            ]
        )
Exemplo n.º 22
0
    def test_create_meta_with_license(self, mock_the_open, mock_wrap_exe):
        self.config_data.pop('config')
        self.config_data['license'] = 'LICENSE'

        meta.create(self.config_data)

        self.mock_makedirs.assert_has_calls([
            call(self.meta_dir, exist_ok=True),
            call(self.hooks_dir),
        ])

        self.mock_rename.assert_not_called()
        mock_the_open.assert_has_calls(self.expected_open_calls)

        self.mock_copyfile.assert_any_call(
            'LICENSE', os.path.join(self.hooks_dir, 'license'))
Exemplo n.º 23
0
    def test_create_meta_with_icon(self):
        open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
        self.config_data['icon'] = 'my-icon.png'

        meta.create(self.config_data)

        self.assertTrue(
            os.path.exists(os.path.join(self.meta_dir, 'icon.png')),
            'icon.png was not setup correctly')

        self.assertTrue(os.path.exists(self.snap_yaml),
                        'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)
        self.assertFalse('icon' in y, 'icon found in snap.yaml {}'.format(y))
Exemplo n.º 24
0
    def test_create_meta(self):
        meta.create(self.config_data)

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)

        expected = {'architectures': ['amd64'],
                    'description': 'my description',
                    'summary': 'my summary',
                    'name': 'my-package',
                    'version': '1.0'}

        self.assertEqual(y, expected)
Exemplo n.º 25
0
    def test_create_meta_with_icon(self):
        open(os.path.join(os.curdir, 'my-icon.png'), 'w').close()
        self.config_data['icon'] = 'my-icon.png'

        meta.create(self.config_data)

        self.assertTrue(
            os.path.exists(os.path.join(self.meta_dir, 'icon.png')),
            'icon.png was not setup correctly')

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)
        self.assertFalse('icon' in y,
                         'icon found in snap.yaml {}'.format(y))
Exemplo n.º 26
0
    def test_create_meta_with_license(self):
        open(os.path.join(os.curdir, 'LICENSE'), 'w').close()
        self.config_data['license'] = 'LICENSE'

        meta.create(self.config_data)

        self.assertTrue(
            os.path.exists(os.path.join(self.meta_dir, 'license.txt')),
            'license.txt was not setup correctly')

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)
        self.assertFalse('license' in y,
                         'license found in snap.yaml {}'.format(y))
Exemplo n.º 27
0
    def test_create_meta_with_license(self):
        open(os.path.join(os.curdir, 'LICENSE'), 'w').close()
        self.config_data['license'] = 'LICENSE'

        meta.create(self.config_data)

        self.assertTrue(
            os.path.exists(os.path.join(self.meta_dir, 'license.txt')),
            'license.txt was not setup correctly')

        self.assertTrue(os.path.exists(self.snap_yaml),
                        'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)
        self.assertFalse('license' in y,
                         'license found in snap.yaml {}'.format(y))
Exemplo n.º 28
0
    def test_create_meta_with_config_with_args(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'config.sh'), 'w').close()
        self.config_data['config'] = 'config.sh something'

        meta.create(self.config_data)

        config_hook = os.path.join(self.hooks_dir, 'config')
        self.assertTrue(os.path.exists(config_hook),
                        'the config was not setup correctly')

        with open(config_hook) as f:
            config_wrapper = f.readlines()

        expected_wrapper = [
            '#!/bin/sh\n', '\n', '\n', 'exec "$SNAP/config.sh" something $*\n'
        ]
        self.assertEqual(config_wrapper, expected_wrapper)
Exemplo n.º 29
0
    def test_create_meta_with_config_with_args(self):
        os.makedirs(self.snap_dir)
        open(os.path.join(self.snap_dir, 'config.sh'), 'w').close()
        self.config_data['config'] = 'config.sh something'

        meta.create(self.config_data)

        config_hook = os.path.join(self.hooks_dir, 'config')
        self.assertTrue(
            os.path.exists(config_hook), 'the config was not setup correctly')

        with open(config_hook) as f:
            config_wrapper = f.readlines()

        expected_wrapper = [
            '#!/bin/sh\n', '\n', '\n',
            'exec "$SNAP/config.sh" something $*\n']
        self.assertEqual(config_wrapper, expected_wrapper)
Exemplo n.º 30
0
    def test_create_meta(self):
        meta.create(self.config_data)

        self.assertTrue(os.path.exists(self.snap_yaml),
                        'snap.yaml was not created')

        with open(self.snap_yaml) as f:
            y = yaml.load(f)

        expected = {
            'architectures': ['amd64'],
            'description': 'my description',
            'summary': 'my summary',
            'name': 'my-package',
            'version': '1.0'
        }

        self.assertEqual(y, expected)
Exemplo n.º 31
0
    def test_create_meta(self, mock_the_open, mock_wrap_exe):
        meta.create(self.config_data, ["amd64"])

        self.mock_makedirs.assert_has_calls([call(self.meta_dir, exist_ok=True), call(self.hooks_dir)])

        mock_the_open.assert_has_calls(self.expected_open_calls)
        mock_wrap_exe.assert_has_calls(
            [
                call("$SNAP_APP_PATH/bin/bash", os.path.join(os.path.abspath(os.curdir), "snap/bin/bash.wrapper")),
                call("bin/config", os.path.join(self.hooks_dir, "config"), args=[], cwd="$SNAP_APP_PATH"),
            ]
        )
        self.mock_copyfile.assert_has_calls(
            [
                call("my-icon.png", os.path.join(self.meta_dir, "my-icon.png")),
                call("file.apparmor", os.path.join(self.meta_dir, "file.apparmor")),
                call("file.seccomp", os.path.join(self.meta_dir, "file.seccomp")),
            ]
        )
Exemplo n.º 32
0
    def test_create_meta_with_license_in_setup(self):
        os.mkdir('setup')
        license_text = 'this is the license'
        with open(os.path.join('setup', 'license.txt'), 'w') as f:
            f.write(license_text)

        meta.create(self.config_data)

        expected_license = os.path.join(self.meta_dir, 'license.txt')
        self.assertTrue(os.path.exists(expected_license),
                        'license.txt was not setup correctly')
        with open(expected_license) as f:
            self.assertEqual(f.read(), license_text)

        self.assertTrue(
            os.path.exists(self.snap_yaml), 'snap.yaml was not created')
        with open(self.snap_yaml) as f:
            y = yaml.load(f)
        self.assertFalse('license' in y,
                         'license found in snap.yaml {}'.format(y))
Exemplo n.º 33
0
 def _create_meta(self, step, part_names):
     if step == 'strip' and part_names == self.config.part_names:
         common.env = self.config.snap_env()
         meta.create(self.config.data)
Exemplo n.º 34
0
 def _create_meta(self, step, part_names):
     if step == 'strip' and part_names == self.config.part_names:
         common.env = self.config.snap_env()
         meta.create(self.config.data)