Esempio n. 1
0
 def test_debug(self):
     """Testing: debug message."""
     conf = pass_import.Config(3, False)
     with tests.captured() as (out, err):
         conf.debug('pass', 'debug message')
         message = out.getvalue().strip()
     self.assertEqual(err.getvalue().strip(), '')
     self.assertEqual(message, ('\x1b[1m\x1b[95m  .  \x1b[0m\x1b[35m'
                                'pass: \x1b[0mdebug message'))
Esempio n. 2
0
    def test_message(self):
        """Testing: classic message message."""
        with tests.captured() as (out, err):
            self.conf.message('classic message')
            message = out.getvalue().strip()
        self.assertEqual(err.getvalue().strip(), '')
        self.assertEqual(message, '\x1b[1m  .  \x1b[0mclassic message')

        conf = pass_import.Config(True, True)
        with tests.captured() as (out, err):
            conf.message('classic message')
            message = out.getvalue().strip()
        self.assertEqual(err.getvalue().strip(), '')
        self.assertEqual(message, '')
Esempio n. 3
0
    def test_verbose(self):
        """Testing: message verbose."""
        conf = pass_import.Config(1, False)
        with tests.captured() as (out, err):
            conf.verbose('pass', 'verbose msg')
            message = out.getvalue().strip()
        self.assertEqual(err.getvalue().strip(), '')
        self.assertEqual(message, ('\x1b[1m\x1b[95m  .  \x1b[0m\x1b[35m'
                                   'pass: \x1b[0mverbose msg'))

        with tests.captured() as (out, err):
            conf.verbose('pass')
            message = out.getvalue().strip()
        self.assertEqual(err.getvalue().strip(), '')
        self.assertEqual(message, ('\x1b[1m\x1b[95m  .  \x1b[0m\x1b[35mpass'
                                   '\x1b[0m'))
Esempio n. 4
0
 def test_showentry(self):
     """Testing: show a password entry."""
     conf = pass_import.Config(2, False)
     entry = {
         'path': 'Social/mastodon.social',
         'password': '******',
         'login': '******',
         'group': 'Social'
     }
     ref = ('\x1b[1m\x1b[95m  .  \x1b[0m\x1b[35mPath: \x1b[0mSocial/mastodo'
            'n.social\n\x1b[1m\x1b[95m  .  \x1b[0m\x1b[35mData: \x1b[0mEaP:'
            'bCmLZliqa|]WR/#HZP\n           login: roddhjav')
     with tests.captured() as (out, err):
         conf.show(entry)
         message = out.getvalue().strip()
     self.assertEqual(err.getvalue().strip(), '')
     self.assertEqual(message, ref)
Esempio n. 5
0
    def test_readconfig(self):
        """Testing: read configuration file."""
        args = {'separator': '6', 'config': self.assets + 'config.yml'}
        conf = pass_import.Config()
        conf.readconfig(args)

        ref = {
            'separator': '6',
            'delimiter': ',',
            'cleans': {
                ' ': '6'
            },
            'protocols': [],
            'invalids': ['<', '>', ':', '"', '/', '\\', '|', '?', '*', '\x00'],
            'config': 'tests/assets/config.yml'
        }
        self.assertEqual(conf, ref)
Esempio n. 6
0
 def setUp(self):
     self.conf = pass_import.Config(0, False)
Esempio n. 7
0
 def setUp(self):
     """Initialse a config object."""
     self.conf = pass_import.Config(0, False)