예제 #1
0
  def testPost(self, render_mock, *_):
    mode = 'Mod1'
    self.testapp.post('/admin/panic', {'mode': mode, 'enabled': 'enable'})

    render_mock.assert_called_once()
    self.assertTrue(
        test.GetArgFromCallHistory(
            render_mock).endswith('panic_set_verify.html'))
    self.assertEqual(
        {'name': mode, 'enabled': 'enable'},
        test.GetArgFromCallHistory(render_mock, arg_index=1)['mode'])
  def testDisplayMainWithIncorrectTag(self, render, *_):
    resp = gae_main.app.get_response('/admin/manifest_modifications?mod_type=b')
    self.assertEqual(httplib.OK, resp.status_int)

    params = test.GetArgFromCallHistory(render, arg_index=1)
    self.assertEqual(1, len(params['mods']))
    self.assertGreater(len(params['error']), 0)
    def testDisplayMainAsAdmin(self, render, *_):
        resp = gae_main.app.get_response('/admin/manifest_modifications')
        self.assertEqual(httplib.OK, resp.status_int)

        params = test.GetArgFromCallHistory(render, arg_index=1)
        self.assertEqual(1, len(params['mods']))
        self.assertEqual(True, params['can_add_manifest_mods'])
        self.assertEqual(0, len(params['error']))
    def testUserFilter(self, render, *_):
        resp = gae_main.app.get_response(
            '/admin/manifest_modifications?filter_field=admin&'
            '[email protected]')
        self.assertEqual(httplib.OK, resp.status_int)

        params = test.GetArgFromCallHistory(render, arg_index=1)
        self.assertEqual(1, len(params['mods']))
예제 #5
0
    def testSiteSummary(self, render, *_):
        resp = gae_main.app.get_response('/admin/?filter-type=site&filter=MTV')
        self.assertEqual(httplib.OK, resp.status_int)

        params = test.GetArgFromCallHistory(render, arg_index=1)

        self.assertEqual('search', params['report_type'])
        self.assertEqual(2, len(params['computers']))
    def testOwnerFilterEmptyResult(self, render, *_):
        resp = gae_main.app.get_response(
            '/admin/manifest_modifications?filter_field=target&'
            'filter_value=notfound')
        self.assertEqual(httplib.OK, resp.status_int)

        params = test.GetArgFromCallHistory(render, arg_index=1)
        self.assertEqual(0, len(params['mods']))
예제 #7
0
    def testGet(self, render_mock, _):
        tagname = 'ak47'
        models.Tag(key_name=tagname).put()

        self.testapp.get('/admin/tags', status=httplib.OK)

        args = test.GetArgFromCallHistory(render_mock, arg_index=1)
        self.assertEqual(tagname, args['tags'][0].key().name())
예제 #8
0
  def testGet(self, render_mock, _):
    data = {'192.168.1.1': 'zerocool'}
    models.KeyValueCache.MemcacheWrappedSet(
        'client_exit_ip_blocks', 'text_value', util.Serialize(data))

    self.testapp.get('/admin/ip_blacklist', status=httplib.OK)

    args = test.GetArgFromCallHistory(render_mock, arg_index=1)
    self.assertEquals(data.items(), args['list'])
예제 #9
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)))
예제 #10
0
    def testHaveEntriesWithSameSerial(self, render, *_):
        resp = gae_main.app.get_response('/admin/host/NEWUUID1==/')

        self.assertEqual(httplib.OK, resp.status_int)
        params = test.GetArgFromCallHistory(render, arg_index=1)
        self.assertEqual(1, len(params['duplicates']))
        other = params['duplicates'][0]
        self.assertEqual(self.common_serial, other.serial)
        self.assertEqual('UUID1', other.uuid)
예제 #11
0
  def testGet(self, render_mock, *_):
    self.testapp.get('/admin/panic', status=httplib.OK)

    modes = []
    for mode in panic.common.PANIC_MODES:
      modes.append({'name': mode, 'enabled': False})

    render_mock.assert_called_once()
    self.assertEqual(
        modes, test.GetArgFromCallHistory(render_mock, arg_index=1)['modes'])
예제 #12
0
    def testGet(self, render_mock, *_):
        package.settings.LIST_OF_CATEGORIES = 'category1,category2'

        filename = 'testpackage.dmg'
        self.test_package.put()

        resp = self.testapp.get('/admin/package/' + filename)

        self.assertEqual(httplib.OK, resp.status_int)
        args = test.GetArgFromCallHistory(render_mock, arg_index=1)

        self.assertEqual(filename, args['pkg'].filename)
예제 #13
0
  def testPostDeleteNoManModsNoGroup(self, render_mock, *unused_args):
    """Test post() delete action, no manifest modifications, no group."""
    self.testapp.get('/admin/groups', status=httplib.OK)
    render_dict = test.GetArgFromCallHistory(render_mock, arg_index=1)

    params = {
        'xsrf_token': render_dict['xsrf_token'],
        'group': 'test group42',
        'action': 'delete',
    }

    self.testapp.post('/admin/groups', params, status=httplib.NOT_FOUND)
예제 #14
0
    def testSelfReport(self, render, *_):
        resp = gae_main.app.get_response('/admin/')

        self.assertEqual(httplib.OK, resp.status_int)
        params = test.GetArgFromCallHistory(render, arg_index=1)
        self.assertTrue(params['self_report'])

        self.assertEqual('owner', params['search_type'])
        self.assertEqual('zerocool', params['search_term'])

        self.assertEqual(2, len(params['computers']))
        self.assertEqual('zerocool', params['computers'][0].owner)
        self.assertEqual('zerocool', params['computers'][1].owner)
예제 #15
0
    def testOwnerSummary(self, render, *_):
        resp = gae_main.app.get_response(
            '/admin/?filter-type=owner&filter=zerocool')
        self.assertEqual(httplib.OK, resp.status_int)

        params = test.GetArgFromCallHistory(render, arg_index=1)

        self.assertFalse(params['self_report'])
        self.assertEqual('search', params['report_type'])
        self.assertEqual(2, len(params['computers']))
        self.assertEqual(('MTV', 2), params['summary']['sites_histogram'][0])
        self.assertAlmostEqual(99.0196,
                               params['summary']['conns_off_corp_percent'], 3)
예제 #16
0
    def testPostWithValidToken(self, render_mock, _):
        newuser = '******'
        self.testapp.get('/admin/acl_groups', status=httplib.OK)
        params = test.GetArgFromCallHistory(render_mock, arg_index=1)

        params = {'xsrf_token': params['xsrf_token'], 'item_0': [newuser]}
        self.testapp.post('/admin/acl_groups/support_users',
                          params,
                          status=httplib.FOUND)

        users = json.loads(
            models.KeyValueCache.MemcacheWrappedGet('support_users',
                                                    'text_value'))
        self.assertEqual([newuser], users)
예제 #17
0
    def testDisplayUpdateLogs(self, render_mock, _):
        product_id = 'pid'
        p = models.AppleSUSProduct(key_name=product_id,
                                   product_id=product_id,
                                   tracks=['unstable'])
        p.put()
        models.AdminAppleSUSProductLog.Log(p, 'action description')

        self.testapp.get('/admin/applesus/logs', {'product_id': product_id},
                         status=httplib.OK)

        args = test.GetArgFromCallHistory(render_mock, arg_index=1)
        self.assertEqual(1, len(args['logs']))
        self.assertEqual(product_id, args['product_id'])
예제 #18
0
  def testPostChangeNoGroup(self, render_mock, *unused_args):
    """Test post() change action, group doesn't exist."""
    self.testapp.get('/admin/groups', status=httplib.OK)
    render_dict = test.GetArgFromCallHistory(render_mock, arg_index=1)

    params = {
        'xsrf_token': render_dict['xsrf_token'],
        'group': 'test group42',
        'action': 'change',
        'user': '******',
        'add': '1'
    }

    self.testapp.post('/admin/groups', params, status=httplib.NOT_FOUND)
예제 #19
0
    def testDisplayMain(self, render_mock, _):
        product_id = 'pid'
        models.AppleSUSProduct(key_name=product_id,
                               product_id=product_id,
                               tracks=['unstable']).put()

        self.testapp.get('/admin/applesus/', status=httplib.OK)

        args = test.GetArgFromCallHistory(render_mock, arg_index=1)

        self.assertEqual(1, len(args['products']))
        self.assertLess(args['products'][0].stable_promote_date,
                        (datetime.datetime.now() +
                         datetime.timedelta(days=60)).date())
예제 #20
0
  def testPostDeleteNoManMods(self, render_mock, *unused_args):
    """Test post() delete action, no manifest modifications."""
    self.testapp.get('/admin/groups', status=httplib.OK)
    render_dict = test.GetArgFromCallHistory(render_mock, arg_index=1)

    params = {
        'xsrf_token': render_dict['xsrf_token'],
        'group': 'test group',
        'action': 'delete',
    }

    resp = self.testapp.post('/admin/groups', params, status=httplib.FOUND)
    redirect_url = '/admin/groups?msg=Group successfully deleted.'

    self.assertTrue(resp.location.endswith(redirect_url))
    self.assertNotIn('test group', models.Group.GetAllGroupNames())
예제 #21
0
  def testPostCreate(self, render_mock, *unused_args):
    """Test post() create action."""

    self.testapp.get('/admin/groups', status=httplib.OK)
    render_dict = test.GetArgFromCallHistory(render_mock, arg_index=1)

    params = {
        'xsrf_token': render_dict['xsrf_token'],
        'group': 'test group3',
        'action': 'create',
        'user': '******',
    }

    resp = self.testapp.post('/admin/groups', params, status=httplib.FOUND)
    redirect_url = '/admin/groups?msg=Group successfully saved.'

    self.assertTrue(resp.location.endswith(redirect_url))
    self.assertIn('user5', models.Group.get_by_key_name('test group3').users)
예제 #22
0
  def testPostDeleteWithManMods(self, render_mock, *unused_args):
    """Test post() delete action, manifiest modifications exist."""
    models.GroupManifestModification.GenerateInstance(
        mod_type='group', target='test group', munki_pkg_name='Firefox').put()

    self.testapp.get('/admin/groups', status=httplib.OK)
    render_dict = test.GetArgFromCallHistory(render_mock, arg_index=1)

    params = {
        'xsrf_token': render_dict['xsrf_token'],
        'group': 'test group',
        'action': 'delete',
    }

    resp = self.testapp.post('/admin/groups', params, status=httplib.FOUND)
    redirect_url = ("/admin/groups?msg=Group not deleted as it's being used "
                    "for Manifest Modifications.")

    self.assertTrue(resp.location.endswith(redirect_url))
    self.assertIn('test group', models.Group.GetAllGroupNames())
예제 #23
0
  def testGet(self, render_mock, _):
    past = datetime.datetime.now() - datetime.timedelta(days=1)

    broken_uuid = 'uuid1'
    models.Computer(
        key_name=broken_uuid, preflight_datetime=past, uuid=broken_uuid).put()
    models.ComputerClientBroken(
        uuid=broken_uuid, details='42343243234', connections_off_corp=50,
        broken_datetimes=[datetime.datetime.now()]).put()

    toomany_preflight_uuid = 'toomany_preflight_since_postflight'
    models.Computer(
        uuid=toomany_preflight_uuid, connections_on_corp=40,
        preflight_count_since_postflight=50, postflight_datetime=past,
        preflight_datetime=datetime.datetime.now(),
    ).put()

    models.Computer(
        uuid='not_broken', connections_on_corp=40,
        preflight_count_since_postflight=3, postflight_datetime=past,
        preflight_datetime=datetime.datetime.now(),
    ).put()

    no_connections_uuid = 'client without connections'
    models.Computer(
        uuid=no_connections_uuid, preflight_count_since_postflight=6).put()

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

    args = test.GetArgFromCallHistory(render_mock, arg_index=1)

    self.assertEqual(
        [no_connections_uuid],
        _ComputersListToUuidList(args['zero_conn_computers']))

    self.assertEqual(
        [broken_uuid], _ComputersListToUuidList(args['py_computers']))

    self.assertEqual(
        [toomany_preflight_uuid],
        _ComputersListToUuidList(args['pf_computers']))
예제 #24
0
 def testGet(self, render_mock, *unused_args):
   """Test get()."""
   self.testapp.get('/admin/groups', status=httplib.OK)
   render_dict = test.GetArgFromCallHistory(render_mock, arg_index=1)
   self.assertIn('test group', [x.key().name() for x in render_dict['groups']])
예제 #25
0
    def testSelfReport(self, render, *_):
        resp = gae_main.app.get_response('/admin/host/UUID2/')

        params = test.GetArgFromCallHistory(render, arg_index=1)
        self.assertEqual(httplib.OK, resp.status_int)
        self.assertTrue(params['self_report'])