예제 #1
0
    def test_auth_add_again(self, uuid4):
        """Testing the auth add command execution"""

        sys.argv = ['/bin/rho', "auth", "add", "--name", "auth_2",
                    "--username", "user", "--sshkeyfile",
                    TMP_KEY, "--vault",
                    TMP_VAULT_PASS]

        creds = [{u'id': u'1', u'name': u'auth_1', u'username': u'user',
                  u'password': u'', u'sudo_password': None,
                  u'ssh_key_file': u'/tmp/privatekey'}]

        with redirect_credentials(creds):
            AuthAddCommand().main()

        self.assertEqual(creds,
                         [{u'id': u'1',
                           u'name': u'auth_1',
                           u'username': u'user',
                           u'password': u'',
                           u'sudo_password': None,
                           u'ssh_key_file': u'/tmp/privatekey'},
                          {u'id': u'2',
                           u'name': u'auth_2',
                           u'username': u'user',
                           u'password': None,
                           u'sudo_password': None,
                           u'ssh_key_file': u'/tmp/privatekey'}])
예제 #2
0
    def test_a_auth_add_again(self):
        """Testing the auth add command execution"""

        sys.argv = [
            '/bin/rho', "auth", "add", "--name", "auth2", "--username", "user",
            "--sshkeyfile", "./privatekey", "--vault", TMP_VAULT_PASS
        ]
        AuthAddCommand().main()
예제 #3
0
    def test_auth_add_bad_key(self, uuid4):
        """Testing the auth add command execution"""
        sys.argv = ['/bin/rho', "auth", "add", "--name", "auth_1",
                    "--username", "user", "--sshkeyfile",
                    "/not/a/valid/path", "--vault",
                    TMP_VAULT_PASS]

        auth_add_out = six.StringIO()
        with self.assertRaises(SystemExit):
            with redirect_stdout(auth_add_out):
                AuthAddCommand().main()
                self.assertIn("/not/a/valid/path", auth_add_out)