sapling/tests/integration/third_party/dummyssh.py
Johan Schuijt-Li 5e4a97cecc tests: provision fb identity in to testing certificates
Summary:
In order to do more complete tests around authentication we need to provide
fb identity in to our test certificates.

Reviewed By: StanislavGlebik

Differential Revision: D15046017

fbshipit-source-id: 3f3cd450425944a2970c6f02e7eb92a878076a05
2019-05-21 12:25:19 -07:00

45 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python
from __future__ import absolute_import
import os
import sys
os.chdir(os.getenv("TESTTMP"))
if sys.argv[1] != "user@dummy":
sys.exit(-1)
os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get("LOCALIP", "[::1]")
log = open("dummylog", "ab")
log.write("Got arguments")
for i, arg in enumerate(sys.argv[1:]):
log.write(" %d:%s" % (i + 1, arg))
log.write("\n")
log.close()
hgcmd = sys.argv[2]
if os.name == "nt":
# hack to make simple unix single quote quoting work on windows
hgcmd = hgcmd.replace("'", '"')
log = open("dummylog", "a+b")
cert = os.path.join(os.getenv("TESTDIR"), "certs/localhost.crt")
capem = os.path.join(os.getenv("TESTDIR"), "certs/root-ca.crt")
privatekey = os.path.join(os.getenv("TESTDIR"), "certs/localhost.key")
if "hgcli" in hgcmd:
hgcmd += (
" --mononoke-path [::1]:"
+ os.getenv("MONONOKE_SOCKET")
+ (" --cert %s --ca-pem %s --private-key %s --common-name localhost" % (cert, capem, privatekey))
)
mock_username = os.environ.get("MOCK_USERNAME")
hgcmd += " --mock-username '{}'".format(mock_username)
r = os.system(hgcmd)
sys.exit(bool(r))