def test_no_username_with_password(self): ''' Verify that an exception is raised when creating a Login without username but with password ''' with self.assertRaises(KittyException): kurl.Login(password='******')
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_no_password(self): ''' Verify default rendered value of login with username ''' expected = 'user@' uut = kurl.Login(username='******') actual = uut.render().bytes self.assertEqual(actual, expected)
def test_default_full(self): ''' Verify default rendered value of login with username and password ''' expected = 'user:password@' uut = kurl.Login(username='******', password='******') actual = uut.render().bytes self.assertEqual(actual, expected)
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)
def test_constructed_url_full(self): ''' verify the default value of a url without login ''' expected = 'http://*****:*****@www.google.com:123/index.html?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8' container = kurl.HttpUrl( 'http', login=kurl.Login('user', 'pass'), hostport=kurl.HostPort('www.google.com', port=123, name='our host'), path=kurl.Path('index.html', name='the page'), search=kurl.Search('sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8'), name='uut' ) actual = container.render().bytes self.assertEqual(actual, expected)
def test_empty(self): expected = '' uut = kurl.Login() actual = uut.render().bytes self.assertEqual(actual, expected)
def test_not_fuzzable(self): uut = kurl.Login(username='******', password='******', fuzzable=False) self.assertEqual(uut.num_mutations(), 0) self.assertFalse(uut.mutate())