Skip to content

Commit

Permalink
GML-1660 make connection()
Browse files Browse the repository at this point in the history
  • Loading branch information
Lu Zhou authored and Lu Zhou committed Jun 10, 2024
1 parent 185d1d4 commit 3476060
Showing 1 changed file with 48 additions and 46 deletions.
94 changes: 48 additions & 46 deletions tests/test_jwtAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,59 @@
from tests.pyTigerGraphUnitTest import make_connection

class TestJWTTokenAuth(unittest.TestCase):
@classmethod
def setUpClass(cls):
server_config = {
"host": "http://127.0.0.1",
"graphname": "jwttoken",
"username": "tigergraph",
"password": "tigergraph",
"gsqlSecret": "",
"restppPort": "9000",
"gsPort": "14240",
"gsqlVersion": "",
"userCert": None,
"certPath": None,
"sslPort": "443",
"tgCloud": False,
"gcp": False,
"jwtToken": ""
}

path = os.path.dirname(os.path.realpath(__file__))
fname = os.path.join(path, "testserver.json")

if exists(fname):
with open(fname, "r") as config_file:
config = json.load(config_file)
server_config.update(config)

cls.conn = TigerGraphConnection(
host=server_config["host"],
graphname=server_config["graphname"],
username=server_config["username"],
password=server_config["password"],
tgCloud=server_config["tgCloud"],
restppPort=server_config["restppPort"],
gsPort=server_config["gsPort"],
gsqlVersion=server_config["gsqlVersion"],
useCert=server_config["userCert"],
certPath=server_config["certPath"],
sslPort=server_config["sslPort"],
gcp=server_config["gcp"],
jwtToken=server_config["jwtToken"]
)
# @classmethod
# def setUpClass(cls):
# cls.conn = make_connection()
# server_config = {
# "host": "http://127.0.0.1",
# "graphname": "jwttoken",
# "username": "tigergraph",
# "password": "tigergraph",
# "gsqlSecret": "",
# "restppPort": "9000",
# "gsPort": "14240",
# "gsqlVersion": "",
# "userCert": None,
# "certPath": None,
# "sslPort": "443",
# "tgCloud": False,
# "gcp": False,
# "jwtToken": ""
# }

# path = os.path.dirname(os.path.realpath(__file__))
# fname = os.path.join(path, "testserver.json")

# if exists(fname):
# with open(fname, "r") as config_file:
# config = json.load(config_file)
# server_config.update(config)

# cls.conn = TigerGraphConnection(
# host=server_config["host"],
# graphname=server_config["graphname"],
# username=server_config["username"],
# password=server_config["password"],
# tgCloud=server_config["tgCloud"],
# restppPort=server_config["restppPort"],
# gsPort=server_config["gsPort"],
# gsqlVersion=server_config["gsqlVersion"],
# useCert=server_config["userCert"],
# certPath=server_config["certPath"],
# sslPort=server_config["sslPort"],
# gcp=server_config["gcp"],
# jwtToken=server_config["jwtToken"]
# )
@classmethod
def setUpClass(cls):
cls.conn = make_connection()


def test_jwtauth(self):
self.conn.gsql("CREATE GRAPH jwttoken()")
print (self.conn.graphname)
self.conn.getToken(self.conn.createSecret())
# self.conn.gsql("DROP GRAPH jwttoken")
# self.conn.gsql("CREATE GRAPH tests()")
# print (self.conn.graphname)
# self.conn.gsql("USE GRAPH jwttoken")
# self.conn.getToken(self.conn.createSecret())

authheader = self.conn.authHeader
print (f"authheader from init conn: {authheader}")
Expand Down

0 comments on commit 3476060

Please sign in to comment.