Ejemplo n.º 1
0
 def test_show_user_config_with_defaults(self):
     with capture_stdout() as output:
         self.run_command('config', '-d')
     output = yaml.load(output.getvalue())
     self.assertEqual(output['option'], 'value')
     self.assertEqual(output['library'], 'lib')
     self.assertEqual(output['import']['timid'], False)
Ejemplo n.º 2
0
    def test_list_unicode_query(self):
        self.item.title = u'na\xefve'
        self.item.store()
        self.lib._connection().commit()

        with capture_stdout() as stdout:
            self._run_list([u'na\xefve'])
        out = stdout.getvalue()
        self.assertTrue(u'na\xefve' in out.decode(stdout.encoding))
Ejemplo n.º 3
0
 def test_list_album_path(self):
     with capture_stdout() as stdout:
         self._run_list(album=True, fmt='$path')
     self.assertEqual(stdout.getvalue().strip(), u'xxx')
Ejemplo n.º 4
0
 def test_list_item_path(self):
     with capture_stdout() as stdout:
         self._run_list(fmt='$path')
     self.assertEqual(stdout.getvalue().strip(), u'xxx/yyy')
Ejemplo n.º 5
0
 def test_list_outputs_item(self):
     with capture_stdout() as stdout:
         self._run_list()
     self.assertIn(u'the title', stdout.getvalue())
Ejemplo n.º 6
0
 def test_list_item_format_multiple(self):
     with capture_stdout() as stdout:
         self._run_list(fmt='$artist - $album - $year')
     self.assertEqual(u'the artist - the album - 0001',
                      stdout.getvalue().strip())
Ejemplo n.º 7
0
 def test_config_paths_with_cli(self):
     with capture_stdout() as output:
         self.run_command('--config', self.cli_config_path, 'config', '-p')
     paths = output.getvalue().split('\n')
     self.assertEqual(len(paths), 3)
     self.assertEqual(paths[0], self.cli_config_path)
Ejemplo n.º 8
0
 def test_list_album_format(self):
     with capture_stdout() as stdout:
         self._run_list(album=True, fmt='$genre')
     self.assertIn(u'the genre', stdout.getvalue())
     self.assertNotIn(u'the album', stdout.getvalue())
Ejemplo n.º 9
0
    def test_mount_kv_engine(self):
        kvengine = get_test_kv_engine(self.baseurl)

        self.test_response.status_code = 204
        with capture_stdout(self.vault_client.mount_kv_engine, kvengine) as output:
            self.assertEqual(output.strip(), "[*] pkictl - Mounted KV secrets engine: test-kv")
Ejemplo n.º 10
0
    def test_configure_ca_policies(self):
        ca = get_test_intermediate_ca(self.baseurl)

        self.test_response.status_code = 204
        with capture_stdout(self.vault_client.configure_ca_policies, ca) as output:
            self.assertEqual(output.strip(), "[*] pkictl - Configured policy 'intermediate-ca-server-policy' for intermediate CA: test-intermediate-ca")
Ejemplo n.º 11
0
    def test_set_crl_configuration(self):
        ca = get_test_intermediate_ca(self.baseurl)

        self.test_response.status_code = 204
        with capture_stdout(self.vault_client.set_crl_configuration, ca) as output:
            self.assertEqual(output.strip(), "[*] pkictl - Set CRL configuration for CA: test-intermediate-ca")
Ejemplo n.º 12
0
    def test_configure_ca_urls(self):
        rootca = get_test_root_ca(self.baseurl)

        self.test_response.status_code = 204
        with capture_stdout(self.vault_client.configure_ca_urls, rootca) as output:
            self.assertEqual(output.strip(), "[*] pkictl - Configured URLs for CA: test-root-ca")
Ejemplo n.º 13
0
    def test_output_message(self):
        m = "standard output message"

        with capture_stdout(utils.output_message, msg=m) as output:
            self.assertEqual(output.strip(), f"[*] pkictl - {m}")
Ejemplo n.º 14
0
 def test_config_paths_with_cli(self):
     with capture_stdout() as output:
         self.run_command('--config', self.cli_config_path, 'config', '-p')
     paths = output.getvalue().split('\n')
     self.assertEqual(len(paths), 3)
     self.assertEqual(paths[0], self.cli_config_path)
Ejemplo n.º 15
0
 def test_list_album_uses_album_artist(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertNotIn(u'the artist', stdout.getvalue())
     self.assertIn(u'the album artist', stdout.getvalue())
Ejemplo n.º 16
0
 def test_show_user_config_with_cli(self):
     with capture_stdout() as output:
         self.run_command('--config', self.cli_config_path, 'config')
     output = yaml.load(output.getvalue())
     self.assertEqual(output['library'], 'lib')
     self.assertEqual(output['option'], 'cli overwrite')
Ejemplo n.º 17
0
    def test_mount_kv_engine_exists(self):
        kvengine = get_test_kv_engine(self.baseurl)

        self.test_response.status_code = 400
        with capture_stdout(self.vault_client.mount_kv_engine, kvengine) as output:
            self.assertEqual(output.strip(), "[*] pkictl - KV secrets engine 'test-kv' already exists")
Ejemplo n.º 18
0
 def test_show_user_config(self):
     with capture_stdout() as output:
         self.run_command('config')
     output = yaml.load(output.getvalue())
     self.assertEqual(output['option'], 'value')
Ejemplo n.º 19
0
 def test_list_outputs_item(self):
     with capture_stdout() as stdout:
         self._run_list()
     self.assertIn(u'the title', stdout.getvalue())
Ejemplo n.º 20
0
 def test_show_user_config_with_cli(self):
     with capture_stdout() as output:
         self.run_command('--config', self.cli_config_path, 'config')
     output = yaml.load(output.getvalue())
     self.assertEqual(output['library'], 'lib')
     self.assertEqual(output['option'], 'cli overwrite')
Ejemplo n.º 21
0
 def test_list_item_path(self):
     with capture_stdout() as stdout:
         self._run_list(fmt='$path')
     self.assertEqual(stdout.getvalue().strip(), u'xxx/yyy')
Ejemplo n.º 22
0
 def test_list_uses_track_artist(self):
     with capture_stdout() as stdout:
         self._run_list()
     self.assertIn(u"the artist", stdout.getvalue())
     self.assertNotIn(u"the album artist", stdout.getvalue())
Ejemplo n.º 23
0
 def test_list_album_outputs_something(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertGreater(len(stdout.getvalue()), 0)
Ejemplo n.º 24
0
 def test_list_album_format(self):
     with capture_stdout() as stdout:
         self._run_list(album=True, fmt='$genre')
     self.assertIn(u'the genre', stdout.getvalue())
     self.assertNotIn(u'the album', stdout.getvalue())
Ejemplo n.º 25
0
 def test_list_album_path(self):
     with capture_stdout() as stdout:
         self._run_list(album=True, fmt='$path')
     self.assertEqual(stdout.getvalue().strip(), u'xxx')
Ejemplo n.º 26
0
 def test_list_album_omits_title(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertNotIn(u'the title', stdout.getvalue())
Ejemplo n.º 27
0
 def test_list_album_uses_album_artist(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertNotIn(u'the artist', stdout.getvalue())
     self.assertIn(u'the album artist', stdout.getvalue())
Ejemplo n.º 28
0
 def test_list_album_outputs_something(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertGreater(len(stdout.getvalue()), 0)
Ejemplo n.º 29
0
 def test_list_item_format_artist(self):
     with capture_stdout() as stdout:
         self._run_list(fmt='$artist')
     self.assertIn(u'the artist', stdout.getvalue())
Ejemplo n.º 30
0
 def test_list_album_omits_title(self):
     with capture_stdout() as stdout:
         self._run_list(album=True)
     self.assertNotIn(u'the title', stdout.getvalue())
Ejemplo n.º 31
0
 def test_list_item_format_multiple(self):
     with capture_stdout() as stdout:
         self._run_list(fmt='$artist - $album - $year')
     self.assertEqual(u'the artist - the album - 0001',
                      stdout.getvalue().strip())
Ejemplo n.º 32
0
 def test_list_item_format_artist(self):
     with capture_stdout() as stdout:
         self._run_list(fmt='$artist')
     self.assertIn(u'the artist', stdout.getvalue())
Ejemplo n.º 33
0
 def test_show_user_config(self):
     with capture_stdout() as output:
         self.run_command('config')
     output = yaml.load(output.getvalue())
     self.assertEqual(output['option'], 'value')