Updated test to the new API

This commit is contained in:
nik012003
2022-07-12 23:23:08 +02:00
parent e331a31530
commit d25c8d9df6
3 changed files with 5 additions and 6 deletions

View File

@@ -27,7 +27,6 @@ class FiregexAPI:
def login(self,password):
req = self.s.post(f"{self.address}api/login", data=f"username=login&password={password}")
print(req.text)
try :
self.s.set_token(req.json()["access_token"])
return True
@@ -46,8 +45,8 @@ class FiregexAPI:
except Exception:
return False
def create_service(self,service_name,service_port, ipv6 = False):
req = self.s.post(f"{self.address}api/services/add" , json={"name":service_name,"port":service_port, "ipv6": ipv6})
def create_service(self,service_name,service_port, proto, ip_int):
req = self.s.post(f"{self.address}api/services/add" , json={"name":service_name,"port":service_port, "ip_int": ip_int, "proto": proto})
return req.json()["service_id"] if req.json()["status"] == "ok" else None
def get_service(self,service_id):

View File

@@ -50,7 +50,7 @@ else: puts(f"Test Failed: Coundl't change the password ✗", color=colors.red);
#Create new Service
service = firegex.create_service(args.service_name,args.service_port)
service = firegex.create_service(args.service_name,args.service_port,"tcp","127.0.0.1/24")
if service:
puts(f"Sucessfully created service {args.service_name} with public port {args.service_port}", color=colors.green)
service_created = True