예제 #1
0
 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)
예제 #2
0
 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))
예제 #3
0
 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))
예제 #4
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)
예제 #5
0
 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')
예제 #6
0
 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)