Ejemplo n.º 1
0
    def _CreatePackageAlias(self):
        """Creates a new or edits an existing package alias, with verification."""
        package_alias = self.request.get('package_alias').strip()
        munki_pkg_name = self.request.get('munki_pkg_name').strip()

        if not package_alias:
            msg = 'Package Alias is required.'
            self.redirect('/admin/package_alias?msg=%s' % msg)
            return

        if not munki_pkg_name:
            munki_pkg_name = None
        elif not models.PackageInfo.all().filter('name =',
                                                 munki_pkg_name).get():
            msg = 'Munki pkg %s does not exist.' % munki_pkg_name
            self.redirect('/admin/package_alias?msg=%s' % msg)
            return

        alias = models.PackageAlias(key_name=package_alias,
                                    munki_pkg_name=munki_pkg_name)
        if not munki_pkg_name:
            alias.enabled = False
        alias.put()
        msg = 'Package Alias successfully saved.'
        self.redirect('/admin/package_alias?msg=%s' % msg)
Ejemplo n.º 2
0
    def testDisplayMain(self, render_mock, *_):
        aliasname = 'aliasname'
        pkgname = 'pkgname'
        models.PackageAlias(key_name=aliasname, munki_pkg_name=pkgname).put()

        self.testapp.get('/admin/package_alias')

        args = test.GetArgFromCallHistory(render_mock, arg_index=1)
        self.assertEqual(1, len(args['package_aliases'].fetch(None)))
Ejemplo n.º 3
0
    def testDisablePackageAlias(self, *_):
        aliasname = 'aliasname'
        pkgname = 'pkgname'
        models.PackageAlias(key_name=aliasname, munki_pkg_name=pkgname).put()

        self.testapp.post('/admin/package_alias', {
            'enabled': 0,
            'key_name': aliasname
        },
                          status=httplib.OK)

        aliases = models.PackageAlias.all().fetch(None)
        self.assertEqual(1, len(aliases))
        self.assertFalse(aliases[0].enabled)