Exemplo n.º 1
0
    def attack(self):
        username = "******".format(self.ident)
        password = "******"

        try:
            s = Service(self.service.root, username, password)
            s.deregister(s.get_deregistration_token())
            self.counter.add(3)
        except:
            pass

        s = self.service.register(username, password)
        self.LOG.debug("Registered user " + username)
        self.counter.add(1)

        c = 0
        classes = s.model.classes.values()
        self.counter.add(1)

        classkeys = s._get_json('/classkeys')['classes']
        self.counter.add(1)

        while c == 0:
            table = random.choice(classes)
            if not (table.has_id and table.name in classkeys):
                continue
            query = s.query(table.name).select(classkeys[table.name][0])

            c = query.count()
            self.counter.add(1)

        n = random.randint(1, min(100, c))
        members = random.sample(map(lambda r: r[0], query.rows()), n)
        self.counter.add(1)

        self.LOG.debug("Will construct list of %s with: %r", table.name, members)

        with s.list_manager() as lm:
            l = lm.create_list(members, table.name)
            self.LOG.debug('Created list %s, size: %d', l.name, l.size)
            self.counter.add(1)

        try:
            s.deregister(s.get_deregistration_token())
            self.counter.add(2)
        except:
            pass
    def test_user_registration(self):
        username = '******'.format(uuid.uuid4())
        password = '******'
        try:
            s = Service(self.SERVICE.root, username, password)
            s.deregister(s.get_deregistration_token())
        except:
            pass

        s = self.SERVICE.register(username, password)

        self.assertEqual(s.root, self.SERVICE.root)
        self.assertEqual(2, len(s.get_all_lists()))

        drt = s.get_deregistration_token()
        s.deregister(drt)

        self.assertRaises(WebserviceError, s.get_all_lists)
Exemplo n.º 3
0
    def test_user_registration(self):
        username = '******'.format(uuid.uuid4())
        password = '******'
        try:
            s = Service(self.SERVICE.root, username, password)
            s.deregister(s.get_deregistration_token())
        except:
            pass

        s = self.SERVICE.register(username, password)

        self.assertEqual(s.root, self.SERVICE.root)
        self.assertEqual(2, len(s.get_all_lists()))

        drt = s.get_deregistration_token()
        s.deregister(drt)

        self.assertRaises(WebserviceError, s.get_all_lists)