Beispiel #1
0
 def test_run_keyfile(self, ch_mock, gp_mock):
     gp_mock.return_value = 'reallysafeone'
     ch_mock.return_value = 0
     with _capture_output() as fout:
         kdbxpasswordpwned.main([
             _asset('sample_with_key.kdbx'),
             '-k',
             _asset('sample.key'),
         ])
     self.assertEqual(fout[0].getvalue(), '')
     ch_mock.assert_has_calls([mock.call('testit'), mock.call('blabla')])
Beispiel #2
0
    def test_run(self, ch_mock, gp_mock):
        gp_mock.return_value = 'reallysafeone'
        ch_mock.return_value = 3
        with _capture_output() as fout:
            kdbxpasswordpwned.main([_asset('sample.kdbx')])
        self.assertEqual(
            fout[0].getvalue(), '''\
Password for title1 seen 3 times before
Password for title2 seen 3 times before
''')
        ch_mock.assert_has_calls([mock.call('testit'), mock.call('blabla')])
Beispiel #3
0
    def test_run_show_user_and_password(self, ch_mock, gp_mock):
        gp_mock.return_value = 'reallysafeone'
        ch_mock.return_value = 2
        with _capture_output() as fout:
            kdbxpasswordpwned.main([_asset('sample.kdbx'), '-up'])
        self.assertEqual(
            fout[0].getvalue(), '''\
Password for title1 seen 2 times before - testuser - testit
Password for title2 seen 2 times before - None - blabla
''')
        ch_mock.assert_has_calls([mock.call('testit'), mock.call('blabla')])
Beispiel #4
0
 def test_issue_4(self, ch_mock, gp_mock):
     '''
     https://github.com/fopina/kdbxpasswordpwned/issues/4
     argon format support added by moving
     from libkeepass to pykeepass
     '''
     gp_mock.return_value = '123456'
     ch_mock.return_value = 0
     with _capture_output() as fout:
         kdbxpasswordpwned.main([
             _asset('issue_4.kdbx'),
         ])
     self.assertEqual(fout[0].getvalue(), '')
     ch_mock.assert_not_called()