Skip to content

Commit 8d8a72c

Browse files
authored
Merge pull request #114 from ipa-lab/merge_web_api_testing_development
Merge web api testing development
2 parents a0977af + f748d5f commit 8d8a72c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+10325
-1271
lines changed

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ scripts/mac_ansible_hosts.ini
2525
scripts/mac_ansible_id_rsa
2626
scripts/mac_ansible_id_rsa.pub
2727
.aider*
28+
29+
src/hackingBuddyGPT/usecases/web_api_testing/documentation/openapi_spec/
30+
src/hackingBuddyGPT/usecases/web_api_testing/documentation/reports/
31+
src/hackingBuddyGPT/usecases/web_api_testing/retrieve_spotify_token.py
32+
config/my_configs/*
33+
config/configs/*
34+
config/configs/

‎pyproject.toml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ dependencies = [
4545
'uvicorn[standard] == 0.30.6',
4646
'dataclasses_json == 0.6.7',
4747
'websockets == 13.1',
48-
'langchain-community',
49-
'langchain-openai',
48+
'pandas',
49+
'faker',
50+
'fpdf',
51+
'langchain_core',
52+
'langchain_community',
53+
'langchain_chroma',
54+
'langchain_openai',
5055
'markdown',
5156
'chromadb',
52-
'langchain-chroma',
5357
]
5458

5559
[project.urls]
@@ -69,7 +73,7 @@ where = ["src"]
6973
pythonpath = "src"
7074
addopts = ["--import-mode=importlib"]
7175
[project.optional-dependencies]
72-
testing = ['pytest', 'pytest-mock']
76+
testing = ['pytest', 'pytest-mock', 'pandas', 'faker', 'langchain_core']
7377
dev = [
7478
'ruff',
7579
]

‎src/hackingBuddyGPT/capabilities/http_request.py‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,11 @@ def __call__(
4545
body_is_base64: Optional[bool] = False,
4646
headers: Optional[Dict[str, str]] = None,
4747
) -> str:
48+
4849
if body is not None and body_is_base64:
4950
body = base64.b64decode(body).decode()
50-
if self.host[-1] != "/":
51+
if self.host[-1] != "/" and not path.startswith("/"):
5152
path = "/" + path
52-
resp = self._client.request(
53-
method,
54-
self.host + path,
55-
params=query,
56-
data=body,
57-
headers=headers,
58-
allow_redirects=self.follow_redirects,
59-
)
6053
try:
6154
resp = self._client.request(
6255
method,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from dataclasses import dataclass, field
2+
from typing import Dict, Any, List, Tuple
3+
from hackingBuddyGPT.capabilities import Capability
4+
5+
6+
from dataclasses import dataclass, field
7+
from typing import Any, Dict, List, Tuple
8+
9+
@dataclass
10+
class ParsedInformation(Capability):
11+
status_code: str
12+
reason_phrase: Dict[str, Any] = field(default_factory=dict)
13+
headers: Dict[str, Any] = field(default_factory=dict)
14+
response_body: Dict[str, Any] = field(default_factory=dict)
15+
registry: List[Tuple[str, str, str, str]] = field(default_factory=list)
16+
17+
def describe(self) -> str:
18+
"""
19+
Returns a description of the test case.
20+
"""
21+
return f"Parsed information for {self.status_code}, reason_phrase: {self.reason_phrase}, headers: {self.headers}, response_body: {self.response_body} "
22+
def __call__(self, status_code: str, reason_phrase: str, headers: str, response_body:str) -> dict:
23+
self.registry.append((status_code, response_body, headers,response_body))
24+
25+
return {"status_code": status_code, "reason_phrase": reason_phrase, "headers": headers, "response_body": response_body}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
from hackingBuddyGPT.capabilities import Capability
3+
4+
5+
from dataclasses import dataclass, field
6+
from typing import Any, Dict, List, Tuple
7+
8+
@dataclass
9+
class PythonTestCase(Capability):
10+
description: str
11+
input: Dict[str, Any] = field(default_factory=dict)
12+
expected_output: Dict[str, Any] = field(default_factory=dict)
13+
registry: List[Tuple[str, dict, dict]] = field(default_factory=list)
14+
15+
def describe(self) -> str:
16+
"""
17+
Returns a description of the test case.
18+
"""
19+
return f"Test Case: {self.description}\nInput: {self.input}\nExpected Output: {self.expected_output}"
20+
def __call__(self, description: str, input: dict, expected_output: dict) -> dict:
21+
self.registry.append((description, input, expected_output))
22+
return {"description": description, "input": input, "expected_output": expected_output}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
from .simple_openapi_documentation import SimpleWebAPIDocumentation
22
from .simple_web_api_testing import SimpleWebAPITesting
3+
from . import response_processing
4+
from . import documentation
5+
from . import prompt_generation
6+
from . import testing

0 commit comments

Comments
 (0)