def test_not_fuzzable(self): uut = DynamicString(key=self.the_key, value=self.def_value, fuzzable=False) res = uut.render().bytes self.assertEqual(res, self.def_value) self.assertEqual(uut.num_mutations(), 0)
def test_set_session_data(self): new_value = 'new_value' uut = DynamicString(key=self.the_key, value=self.def_value) res = uut.render().bytes self.assertEqual(res, self.def_value) uut.set_session_data({self.the_key: new_value}) res = uut.render().bytes self.assertEqual(res, new_value)
def test_vanilla(self): similar_string = String(self.def_value) uut = DynamicString(key=self.the_key, value=self.def_value) similar_mutations = get_mutation_set(similar_string) uut_mutations = get_mutation_set(uut) if not any(x in uut_mutations for x in similar_mutations): raise AssertionError( 'Not all similar_mutations are in uut_mutations') self.assertGreater(len(uut_mutations), len(similar_mutations))
def test_vanilla_with_encoder(self): similar_string = String(self.def_value, encoder=ENC_STR_BASE64_NO_NL) uut = DynamicString(key=self.the_key, value=self.def_value, encoder=ENC_STR_BASE64_NO_NL) similar_mutations = get_mutation_set(similar_string) uut_mutations = get_mutation_set(uut) if not any(x in uut_mutations for x in similar_mutations): raise AssertionError( 'Not all similar_mutations are in uut_mutations') self.assertGreater(len(uut_mutations), len(similar_mutations))
def test_limited_string(self): similar_string = String(self.def_value, max_size=len(self.def_value)) uut = DynamicString(key=self.the_key, value=self.def_value, keep_size=True) similar_mutations = get_mutation_set(similar_string) uut_mutations = get_mutation_set(uut) if not any(x in uut_mutations for x in similar_mutations): raise AssertionError( 'Not all similar_mutations are in uut_mutations') self.assertGreater(len(uut_mutations), len(similar_mutations)) if any(len(x) != len(self.def_value) for x in uut_mutations): raise AssertionError( 'There are results with different size than the default value')
def test_default_value(self): uut = DynamicString(key=self.the_key, value=self.def_value) res = uut.render().bytes self.assertEqual(res, self.def_value)