def test_vanilla(self): uut = DynamicInt(self.the_key, self.bf) bf_mutations = get_mutation_set(self.bf) uut_mutations = get_mutation_set(uut) if not any(x in bf_mutations for x in bf_mutations): raise AssertionError('Not all similar_mutations are in uut_mutations') self.assertGreater(len(uut_mutations), len(bf_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_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_string(self): additional_field = String('the_string') uut = DynamicExtended(key=self.the_key, value=self.def_value, additional_field=additional_field) addional_mutations = get_mutation_set(additional_field) uut_mutations = get_mutation_set(uut) if not any(x in uut_mutations for x in addional_mutations): raise AssertionError('Not all addional_mutations are in uut_mutations') self.assertGreater(len(uut_mutations), len(addional_mutations))
def test_vanilla(self): uut = DynamicInt(self.the_key, self.bf) bf_mutations = get_mutation_set(self.bf) uut_mutations = get_mutation_set(uut) if not any(x in bf_mutations for x in bf_mutations): raise AssertionError( 'Not all similar_mutations are in uut_mutations') self.assertGreater(len(uut_mutations), len(bf_mutations))
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_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_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_vanilla_with_string(self): additional_field = String('the_string') uut = DynamicExtended(key=self.the_key, value=self.def_value, additional_field=additional_field) addional_mutations = get_mutation_set(additional_field) uut_mutations = get_mutation_set(uut) if not any(x in uut_mutations for x in addional_mutations): raise AssertionError( 'Not all addional_mutations are in uut_mutations') self.assertGreater(len(uut_mutations), len(addional_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_fuzz_password_false(self): username = '******' password = '******' uut = kurl.Login(username=username, password=password, fuzz_username=True, fuzz_password=False, fuzz_delims=True) mutations = get_mutation_set(uut) if not all(password in mutation for mutation in mutations): raise Exception('password does not always appear')
def test_fuzz_port_false(self): host = 'www.example.com' port = '1234' uut = kurl.HostPort(host, int(port), fuzz_host=True, fuzz_port=False, fuzz_delim=True) mutations = get_mutation_set(uut) if not all(port in mutation for mutation in mutations): raise Exception('port does not always appear')
def test_fuzz_host_true(self): host = 'www.example.com' port = 1234 uut = kurl.HostPort(host, port, fuzz_host=True, fuzz_port=False, fuzz_delim=False) mutations = get_mutation_set(uut) if all(host in mutation for mutation in mutations): raise Exception('host always appear')
def test_performing_string_mutations(self): uut = kurl.DecimalNumber(5) mutations = get_mutation_set(uut) int_cnt = sum(is_int(x) for x in mutations) self.assertLess(int_cnt, len(mutations)) non_int_cnt = sum(not is_int(x) for x in mutations) self.assertGreater(non_int_cnt, 5)
def test_no_value_2_mutations(self): ''' Verify that when no value is set, only two mutations may happen - true and false ''' t = warp_with_template(kjson.JsonBoolean(name='bool')) self.assertEqual(t.num_mutations(), 2) mutations = get_mutation_set(t) self.assertEqual(mutations, set(['true', 'false']))
def test_fuzz_delims_true(self): username = '******' password = '******' delim1 = ':' delim2 = '@' uut = kurl.Login(username=username, password=password, fuzz_username=False, fuzz_password=False, fuzz_delims=True) mutations = get_mutation_set(uut) if all(delim1 in mutation for mutation in mutations): raise Exception('"%s" always appear' % delim1) if all(delim2 in mutation for mutation in mutations): raise Exception('"%s" always appear' % delim2)