matimo-bruno 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- matimo_bruno-0.1.0/.gitignore +63 -0
- matimo_bruno-0.1.0/PKG-INFO +188 -0
- matimo_bruno-0.1.0/README.md +174 -0
- matimo_bruno-0.1.0/pyproject.toml +27 -0
- matimo_bruno-0.1.0/src/matimo_bruno/__init__.py +7 -0
- matimo_bruno-0.1.0/src/matimo_bruno/_bru_utils.py +51 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_add_request/definition.yaml +108 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_add_request/executor.py +139 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_create_collection/definition.yaml +45 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_create_collection/executor.py +53 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_get_collection_info/definition.yaml +60 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_get_collection_info/executor.py +110 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_import_openapi/definition.yaml +74 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_import_openapi/executor.py +90 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_list_collections/definition.yaml +48 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_list_collections/executor.py +82 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_run_collection/definition.yaml +135 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_run_collection/executor.py +138 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_run_request/definition.yaml +70 -0
- matimo_bruno-0.1.0/src/matimo_bruno/tools/bruno_run_request/executor.py +116 -0
- matimo_bruno-0.1.0/tests/unit/test_bruno_tools.py +751 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
**/node_modules/
|
|
3
|
+
package-lock.json
|
|
4
|
+
yarn.lock
|
|
5
|
+
|
|
6
|
+
# Build output
|
|
7
|
+
**/dist/
|
|
8
|
+
*.tsbuildinfo
|
|
9
|
+
|
|
10
|
+
# Python compiled / build
|
|
11
|
+
**/__pycache__/
|
|
12
|
+
*.py[cod]
|
|
13
|
+
*$py.class
|
|
14
|
+
*.egg-info/
|
|
15
|
+
*.egg
|
|
16
|
+
**/build/
|
|
17
|
+
**/.eggs/
|
|
18
|
+
**/.venv/
|
|
19
|
+
**/.mypy_cache/
|
|
20
|
+
**/.ruff_cache/
|
|
21
|
+
**/.pytest_cache/
|
|
22
|
+
|
|
23
|
+
# Test coverage
|
|
24
|
+
**/coverage/
|
|
25
|
+
**/.nyc_output/
|
|
26
|
+
|
|
27
|
+
# IDE
|
|
28
|
+
.vscode/
|
|
29
|
+
.idea/
|
|
30
|
+
*.swp
|
|
31
|
+
*.swo
|
|
32
|
+
*~
|
|
33
|
+
.DS_Store
|
|
34
|
+
|
|
35
|
+
# Environment
|
|
36
|
+
.env
|
|
37
|
+
.env.local
|
|
38
|
+
.env.*.local
|
|
39
|
+
|
|
40
|
+
# Logs
|
|
41
|
+
*.log
|
|
42
|
+
npm-debug.log*
|
|
43
|
+
yarn-debug.log*
|
|
44
|
+
yarn-error.log*
|
|
45
|
+
|
|
46
|
+
# OS
|
|
47
|
+
.DS_Store
|
|
48
|
+
Thumbs.db
|
|
49
|
+
|
|
50
|
+
# Temporary files
|
|
51
|
+
tmp/
|
|
52
|
+
temp/
|
|
53
|
+
*.tmp
|
|
54
|
+
typescript/examples/mcp/matimo-tools/.matimo-approvals.json
|
|
55
|
+
typescript/examples/mcp/matimo-tools/fetch-weather/definition.yaml
|
|
56
|
+
typescript/examples/mcp/matimo-tools/npm_downloads/definition.yaml
|
|
57
|
+
typescript/examples/mcp/matimo-tools/skills/ecosystem-health/SKILL.md
|
|
58
|
+
typescript/examples/mcp/matimo-tools/skills/matimo-health-check/SKILL.md
|
|
59
|
+
typescript/examples/mcp/matimo-tools/skills/moltbook-identity/SKILL.md
|
|
60
|
+
typescript/packages/cli/.matimo/certs/server.crt
|
|
61
|
+
typescript/packages/cli/.matimo/certs/server.key
|
|
62
|
+
typescript/examples/mcp/.matimo/certs/server.crt
|
|
63
|
+
typescript/examples/mcp/.matimo/certs/server.key
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: matimo-bruno
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Matimo provider — Bruno API testing tools (collections, requests, imports, reports)
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: agents,ai,api-testing,bruno,matimo,tools
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Requires-Dist: matimo-core<0.2.0,>=0.1.0
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# matimo-bruno
|
|
16
|
+
|
|
17
|
+
Bruno CLI tools for Matimo — Enable AI agents to autonomously manage, execute, and validate API test collections.
|
|
18
|
+
|
|
19
|
+
## 📦 Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install matimo-bruno
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 🚀 Quick Start
|
|
26
|
+
|
|
27
|
+
### Python
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from matimo import Matimo
|
|
31
|
+
|
|
32
|
+
matimo = await Matimo.init()
|
|
33
|
+
|
|
34
|
+
# List all collections in workspace
|
|
35
|
+
collections = await matimo.execute('bruno_list_collections', {
|
|
36
|
+
'workspace_path': './collections'
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
# Get collection metadata before running
|
|
40
|
+
info = await matimo.execute('bruno_get_collection_info', {
|
|
41
|
+
'collection_path': './collections/payment-api'
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
# Run entire collection
|
|
45
|
+
result = await matimo.execute('bruno_run_collection', {
|
|
46
|
+
'collection_path': './collections/payment-api',
|
|
47
|
+
'environment': 'staging',
|
|
48
|
+
'report_path': './reports/staging-results.json'
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
# Run single request for debugging
|
|
52
|
+
response = await matimo.execute('bruno_run_request', {
|
|
53
|
+
'collection_path': './collections/auth',
|
|
54
|
+
'request_name': 'Login',
|
|
55
|
+
'environment': 'staging'
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
# Bootstrap from OpenAPI spec
|
|
59
|
+
imported = await matimo.execute('bruno_import_openapi', {
|
|
60
|
+
'spec_source': 'https://api.example.com/openapi.json',
|
|
61
|
+
'output_directory': './collections',
|
|
62
|
+
'collection_name': 'Generated API Tests'
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
# Create new collection
|
|
66
|
+
created = await matimo.execute('bruno_create_collection', {
|
|
67
|
+
'collection_path': './collections/new-service',
|
|
68
|
+
'collection_name': 'New Service Tests'
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 📋 Available Tools
|
|
73
|
+
|
|
74
|
+
### 1. `bruno_run_collection`
|
|
75
|
+
Execute a Bruno API collection with configurable environments, data files, and reporting.
|
|
76
|
+
|
|
77
|
+
**Parameters:**
|
|
78
|
+
- `collection_path` (required) — Path to collection file or directory
|
|
79
|
+
- `environment` — Environment name (dev, staging, prod)
|
|
80
|
+
- `env_file` — Path to environment file override
|
|
81
|
+
- `data_file` — CSV/JSON data file for data-driven testing
|
|
82
|
+
- `iteration_count` — Number of iterations to run
|
|
83
|
+
- `delay_ms` — Delay between requests
|
|
84
|
+
- `tags` — Comma-separated tags (run requests with ALL tags)
|
|
85
|
+
- `exclude_tags` — Comma-separated tags (skip requests with ANY tags)
|
|
86
|
+
- `tests_only` — Run only requests with tests/assertions
|
|
87
|
+
- `bail_on_failure` — Stop on first failure
|
|
88
|
+
- `parallel` — Run requests in parallel
|
|
89
|
+
- `sandbox_mode` — JavaScript execution mode ('safe' or 'developer')
|
|
90
|
+
- `report_format` — Report format (json, junit, html)
|
|
91
|
+
- `report_path` — Path to write report file
|
|
92
|
+
|
|
93
|
+
**Returns:** Collection execution results, summary, and report path
|
|
94
|
+
|
|
95
|
+
### 2. `bruno_run_request`
|
|
96
|
+
Execute a single request for targeted debugging and validation.
|
|
97
|
+
|
|
98
|
+
**Parameters:**
|
|
99
|
+
- `collection_path` (required) — Collection directory
|
|
100
|
+
- `request_name` (required) — Request name to execute
|
|
101
|
+
- `environment` — Environment name override
|
|
102
|
+
- `env_file` — Environment file override
|
|
103
|
+
- `sandbox_mode` — JavaScript execution mode
|
|
104
|
+
|
|
105
|
+
**Returns:** Request/response details and assertion results
|
|
106
|
+
|
|
107
|
+
### 3. `bruno_list_collections`
|
|
108
|
+
Discover all collections in a workspace.
|
|
109
|
+
|
|
110
|
+
**Parameters:**
|
|
111
|
+
- `workspace_path` (required) — Workspace directory
|
|
112
|
+
- `filter` — Filter by collection name (substring)
|
|
113
|
+
|
|
114
|
+
**Returns:** Array of collection metadata
|
|
115
|
+
|
|
116
|
+
### 4. `bruno_get_collection_info`
|
|
117
|
+
Introspect collection structure before execution.
|
|
118
|
+
|
|
119
|
+
**Parameters:**
|
|
120
|
+
- `collection_path` (required) — Collection path
|
|
121
|
+
|
|
122
|
+
**Returns:** Collection structure, requests, environments, variables
|
|
123
|
+
|
|
124
|
+
### 5. `bruno_import_openapi`
|
|
125
|
+
Bootstrap a collection from OpenAPI 3.0 specification.
|
|
126
|
+
|
|
127
|
+
**Parameters:**
|
|
128
|
+
- `spec_source` (required) — Path or URL to OpenAPI spec
|
|
129
|
+
- `output_directory` (required) — Where to create collection
|
|
130
|
+
- `collection_name` — Collection name
|
|
131
|
+
- `collection_format` — 'bru' or 'opencollection'
|
|
132
|
+
- `group_by` — Group by 'tags' or 'path'
|
|
133
|
+
- `insecure` — Skip TLS verification
|
|
134
|
+
|
|
135
|
+
**Returns:** Collection path and metadata
|
|
136
|
+
|
|
137
|
+
### 6. `bruno_create_collection`
|
|
138
|
+
Create a new empty collection scaffold.
|
|
139
|
+
|
|
140
|
+
**Parameters:**
|
|
141
|
+
- `collection_path` (required) — Collection creation path
|
|
142
|
+
- `collection_name` (required) — Collection name
|
|
143
|
+
|
|
144
|
+
**Returns:** Creation status and path
|
|
145
|
+
|
|
146
|
+
## 🔄 Agent Workflows
|
|
147
|
+
|
|
148
|
+
### Autonomous Test Execution
|
|
149
|
+
```
|
|
150
|
+
Agent discovers spec → import_openapi → set environment → run_collection → parse results
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Multi-Environment Validation
|
|
154
|
+
```
|
|
155
|
+
list_collections → for each environment: set_env + run_collection → compare results
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Targeted Debugging
|
|
159
|
+
```
|
|
160
|
+
get_collection_info → run_request (single endpoint) → analyze response
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Data-Driven Testing
|
|
164
|
+
```
|
|
165
|
+
run_collection with CSV file → multiple iterations → aggregate metrics
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 🔐 Authentication
|
|
169
|
+
|
|
170
|
+
Tools use environment variables for credentials. Bruno CLI manages environment setup — tools wrap CLI execution.
|
|
171
|
+
|
|
172
|
+
## 📖 Prerequisites
|
|
173
|
+
|
|
174
|
+
- **Bruno CLI** installed globally: `pnpm install -g @usebruno/cli`
|
|
175
|
+
- **Python** 3.11+
|
|
176
|
+
- Bruno collections in `.bru` format or OpenAPI specs
|
|
177
|
+
|
|
178
|
+
## 🤝 Integration
|
|
179
|
+
|
|
180
|
+
Works with:
|
|
181
|
+
- **LangChain** — Convert to StructuredTool
|
|
182
|
+
- **CrewAI** — Convert to BaseTool
|
|
183
|
+
- **MCP** — Expose via JSON-RPC to Claude / other MCP clients
|
|
184
|
+
- **Native** — Direct SDK usage
|
|
185
|
+
|
|
186
|
+
## 📝 License
|
|
187
|
+
|
|
188
|
+
MIT
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# matimo-bruno
|
|
2
|
+
|
|
3
|
+
Bruno CLI tools for Matimo — Enable AI agents to autonomously manage, execute, and validate API test collections.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install matimo-bruno
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 🚀 Quick Start
|
|
12
|
+
|
|
13
|
+
### Python
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from matimo import Matimo
|
|
17
|
+
|
|
18
|
+
matimo = await Matimo.init()
|
|
19
|
+
|
|
20
|
+
# List all collections in workspace
|
|
21
|
+
collections = await matimo.execute('bruno_list_collections', {
|
|
22
|
+
'workspace_path': './collections'
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
# Get collection metadata before running
|
|
26
|
+
info = await matimo.execute('bruno_get_collection_info', {
|
|
27
|
+
'collection_path': './collections/payment-api'
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
# Run entire collection
|
|
31
|
+
result = await matimo.execute('bruno_run_collection', {
|
|
32
|
+
'collection_path': './collections/payment-api',
|
|
33
|
+
'environment': 'staging',
|
|
34
|
+
'report_path': './reports/staging-results.json'
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
# Run single request for debugging
|
|
38
|
+
response = await matimo.execute('bruno_run_request', {
|
|
39
|
+
'collection_path': './collections/auth',
|
|
40
|
+
'request_name': 'Login',
|
|
41
|
+
'environment': 'staging'
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
# Bootstrap from OpenAPI spec
|
|
45
|
+
imported = await matimo.execute('bruno_import_openapi', {
|
|
46
|
+
'spec_source': 'https://api.example.com/openapi.json',
|
|
47
|
+
'output_directory': './collections',
|
|
48
|
+
'collection_name': 'Generated API Tests'
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
# Create new collection
|
|
52
|
+
created = await matimo.execute('bruno_create_collection', {
|
|
53
|
+
'collection_path': './collections/new-service',
|
|
54
|
+
'collection_name': 'New Service Tests'
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 📋 Available Tools
|
|
59
|
+
|
|
60
|
+
### 1. `bruno_run_collection`
|
|
61
|
+
Execute a Bruno API collection with configurable environments, data files, and reporting.
|
|
62
|
+
|
|
63
|
+
**Parameters:**
|
|
64
|
+
- `collection_path` (required) — Path to collection file or directory
|
|
65
|
+
- `environment` — Environment name (dev, staging, prod)
|
|
66
|
+
- `env_file` — Path to environment file override
|
|
67
|
+
- `data_file` — CSV/JSON data file for data-driven testing
|
|
68
|
+
- `iteration_count` — Number of iterations to run
|
|
69
|
+
- `delay_ms` — Delay between requests
|
|
70
|
+
- `tags` — Comma-separated tags (run requests with ALL tags)
|
|
71
|
+
- `exclude_tags` — Comma-separated tags (skip requests with ANY tags)
|
|
72
|
+
- `tests_only` — Run only requests with tests/assertions
|
|
73
|
+
- `bail_on_failure` — Stop on first failure
|
|
74
|
+
- `parallel` — Run requests in parallel
|
|
75
|
+
- `sandbox_mode` — JavaScript execution mode ('safe' or 'developer')
|
|
76
|
+
- `report_format` — Report format (json, junit, html)
|
|
77
|
+
- `report_path` — Path to write report file
|
|
78
|
+
|
|
79
|
+
**Returns:** Collection execution results, summary, and report path
|
|
80
|
+
|
|
81
|
+
### 2. `bruno_run_request`
|
|
82
|
+
Execute a single request for targeted debugging and validation.
|
|
83
|
+
|
|
84
|
+
**Parameters:**
|
|
85
|
+
- `collection_path` (required) — Collection directory
|
|
86
|
+
- `request_name` (required) — Request name to execute
|
|
87
|
+
- `environment` — Environment name override
|
|
88
|
+
- `env_file` — Environment file override
|
|
89
|
+
- `sandbox_mode` — JavaScript execution mode
|
|
90
|
+
|
|
91
|
+
**Returns:** Request/response details and assertion results
|
|
92
|
+
|
|
93
|
+
### 3. `bruno_list_collections`
|
|
94
|
+
Discover all collections in a workspace.
|
|
95
|
+
|
|
96
|
+
**Parameters:**
|
|
97
|
+
- `workspace_path` (required) — Workspace directory
|
|
98
|
+
- `filter` — Filter by collection name (substring)
|
|
99
|
+
|
|
100
|
+
**Returns:** Array of collection metadata
|
|
101
|
+
|
|
102
|
+
### 4. `bruno_get_collection_info`
|
|
103
|
+
Introspect collection structure before execution.
|
|
104
|
+
|
|
105
|
+
**Parameters:**
|
|
106
|
+
- `collection_path` (required) — Collection path
|
|
107
|
+
|
|
108
|
+
**Returns:** Collection structure, requests, environments, variables
|
|
109
|
+
|
|
110
|
+
### 5. `bruno_import_openapi`
|
|
111
|
+
Bootstrap a collection from OpenAPI 3.0 specification.
|
|
112
|
+
|
|
113
|
+
**Parameters:**
|
|
114
|
+
- `spec_source` (required) — Path or URL to OpenAPI spec
|
|
115
|
+
- `output_directory` (required) — Where to create collection
|
|
116
|
+
- `collection_name` — Collection name
|
|
117
|
+
- `collection_format` — 'bru' or 'opencollection'
|
|
118
|
+
- `group_by` — Group by 'tags' or 'path'
|
|
119
|
+
- `insecure` — Skip TLS verification
|
|
120
|
+
|
|
121
|
+
**Returns:** Collection path and metadata
|
|
122
|
+
|
|
123
|
+
### 6. `bruno_create_collection`
|
|
124
|
+
Create a new empty collection scaffold.
|
|
125
|
+
|
|
126
|
+
**Parameters:**
|
|
127
|
+
- `collection_path` (required) — Collection creation path
|
|
128
|
+
- `collection_name` (required) — Collection name
|
|
129
|
+
|
|
130
|
+
**Returns:** Creation status and path
|
|
131
|
+
|
|
132
|
+
## 🔄 Agent Workflows
|
|
133
|
+
|
|
134
|
+
### Autonomous Test Execution
|
|
135
|
+
```
|
|
136
|
+
Agent discovers spec → import_openapi → set environment → run_collection → parse results
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Multi-Environment Validation
|
|
140
|
+
```
|
|
141
|
+
list_collections → for each environment: set_env + run_collection → compare results
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Targeted Debugging
|
|
145
|
+
```
|
|
146
|
+
get_collection_info → run_request (single endpoint) → analyze response
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Data-Driven Testing
|
|
150
|
+
```
|
|
151
|
+
run_collection with CSV file → multiple iterations → aggregate metrics
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## 🔐 Authentication
|
|
155
|
+
|
|
156
|
+
Tools use environment variables for credentials. Bruno CLI manages environment setup — tools wrap CLI execution.
|
|
157
|
+
|
|
158
|
+
## 📖 Prerequisites
|
|
159
|
+
|
|
160
|
+
- **Bruno CLI** installed globally: `pnpm install -g @usebruno/cli`
|
|
161
|
+
- **Python** 3.11+
|
|
162
|
+
- Bruno collections in `.bru` format or OpenAPI specs
|
|
163
|
+
|
|
164
|
+
## 🤝 Integration
|
|
165
|
+
|
|
166
|
+
Works with:
|
|
167
|
+
- **LangChain** — Convert to StructuredTool
|
|
168
|
+
- **CrewAI** — Convert to BaseTool
|
|
169
|
+
- **MCP** — Expose via JSON-RPC to Claude / other MCP clients
|
|
170
|
+
- **Native** — Direct SDK usage
|
|
171
|
+
|
|
172
|
+
## 📝 License
|
|
173
|
+
|
|
174
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "matimo-bruno"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Matimo provider — Bruno API testing tools (collections, requests, imports, reports)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
keywords = ["ai", "tools", "agents", "matimo", "bruno", "api-testing"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"matimo-core>=0.1.0,<0.2.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.entry-points."matimo.providers"]
|
|
24
|
+
bruno = "matimo_bruno:get_tools_path"
|
|
25
|
+
|
|
26
|
+
[tool.hatch.build.targets.wheel]
|
|
27
|
+
packages = ["src/matimo_bruno"]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Shared utilities for Bruno CLI tools."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
BRU_MIN_VERSION: tuple[int, int, int] = (1, 0, 0)
|
|
9
|
+
BRU_MIN_VERSION_STR = "1.0.0"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def check_bru_version() -> None:
|
|
13
|
+
"""Verify the Bruno CLI is installed and meets the minimum required version.
|
|
14
|
+
|
|
15
|
+
Raises:
|
|
16
|
+
RuntimeError: If ``bru`` is not installed or below :data:`BRU_MIN_VERSION`.
|
|
17
|
+
|
|
18
|
+
Silently skips the version comparison when the version output cannot be
|
|
19
|
+
parsed (graceful degradation — the tool is installed, which is sufficient).
|
|
20
|
+
"""
|
|
21
|
+
if shutil.which("bru") is None:
|
|
22
|
+
raise RuntimeError(
|
|
23
|
+
"Bruno CLI ('bru') is not installed or not in PATH. "
|
|
24
|
+
"Install it with: npm install -g @usebruno/cli "
|
|
25
|
+
"or via Homebrew: brew install bruno"
|
|
26
|
+
)
|
|
27
|
+
try:
|
|
28
|
+
result = subprocess.run(
|
|
29
|
+
["bru", "--version"],
|
|
30
|
+
capture_output=True,
|
|
31
|
+
text=True,
|
|
32
|
+
timeout=5,
|
|
33
|
+
)
|
|
34
|
+
version_str = result.stdout.strip()
|
|
35
|
+
match = re.match(r"^(\d+)\.(\d+)\.(\d+)", version_str)
|
|
36
|
+
if match:
|
|
37
|
+
installed: tuple[int, int, int] = (
|
|
38
|
+
int(match.group(1)),
|
|
39
|
+
int(match.group(2)),
|
|
40
|
+
int(match.group(3)),
|
|
41
|
+
)
|
|
42
|
+
if installed < BRU_MIN_VERSION:
|
|
43
|
+
raise RuntimeError(
|
|
44
|
+
f"Bruno CLI version {version_str} is below the minimum required "
|
|
45
|
+
f"version {BRU_MIN_VERSION_STR}. "
|
|
46
|
+
f"Upgrade with: npm install -g @usebruno/cli"
|
|
47
|
+
)
|
|
48
|
+
except RuntimeError:
|
|
49
|
+
raise # Re-raise version-too-low errors
|
|
50
|
+
except Exception: # noqa: BLE001
|
|
51
|
+
pass # Best-effort check — if version cannot be determined, proceed
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
name: bruno_add_request
|
|
2
|
+
description: Add a new HTTP request to a Bruno collection programmatically. Creates a .bru file with the specified method, URL, headers, body, and test assertions.
|
|
3
|
+
version: '1.0.0'
|
|
4
|
+
status: approved
|
|
5
|
+
|
|
6
|
+
parameters:
|
|
7
|
+
collection_path:
|
|
8
|
+
type: string
|
|
9
|
+
required: true
|
|
10
|
+
description: Path to Bruno collection directory
|
|
11
|
+
example: './api-tests/payment-api'
|
|
12
|
+
|
|
13
|
+
request_name:
|
|
14
|
+
type: string
|
|
15
|
+
required: true
|
|
16
|
+
description: Request name (becomes .bru filename, alphanumeric + hyphens)
|
|
17
|
+
example: 'get-users'
|
|
18
|
+
|
|
19
|
+
method:
|
|
20
|
+
type: string
|
|
21
|
+
required: true
|
|
22
|
+
description: HTTP method
|
|
23
|
+
enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']
|
|
24
|
+
example: 'GET'
|
|
25
|
+
|
|
26
|
+
url:
|
|
27
|
+
type: string
|
|
28
|
+
required: true
|
|
29
|
+
description: Full request URL (can contain {variables})
|
|
30
|
+
example: 'https://api.example.com/users/{user_id}'
|
|
31
|
+
|
|
32
|
+
headers:
|
|
33
|
+
type: object
|
|
34
|
+
required: false
|
|
35
|
+
description: HTTP headers as key-value pairs
|
|
36
|
+
example:
|
|
37
|
+
Content-Type: 'application/json'
|
|
38
|
+
Authorization: 'Bearer {api_token}'
|
|
39
|
+
|
|
40
|
+
body:
|
|
41
|
+
type: string
|
|
42
|
+
required: false
|
|
43
|
+
description: Request body (JSON or raw text)
|
|
44
|
+
example: '{"name": "John", "email": "john@example.com"}'
|
|
45
|
+
|
|
46
|
+
tests:
|
|
47
|
+
type: string
|
|
48
|
+
required: false
|
|
49
|
+
description: Bruno test script (JavaScript assertions)
|
|
50
|
+
example: |
|
|
51
|
+
test("Status is 200", function() {
|
|
52
|
+
expect(res.getStatus()).to.equal(200);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
documentation:
|
|
56
|
+
type: string
|
|
57
|
+
required: false
|
|
58
|
+
description: Request documentation/description
|
|
59
|
+
example: 'Fetch list of all users from the system'
|
|
60
|
+
|
|
61
|
+
execution:
|
|
62
|
+
type: function
|
|
63
|
+
code: executor.py
|
|
64
|
+
timeout: 10000
|
|
65
|
+
|
|
66
|
+
output_schema:
|
|
67
|
+
type: object
|
|
68
|
+
properties:
|
|
69
|
+
success:
|
|
70
|
+
type: boolean
|
|
71
|
+
description: Whether request was created successfully
|
|
72
|
+
request_path:
|
|
73
|
+
type: string
|
|
74
|
+
description: Full path to created .bru file
|
|
75
|
+
request_name:
|
|
76
|
+
type: string
|
|
77
|
+
description: Request name
|
|
78
|
+
message:
|
|
79
|
+
type: string
|
|
80
|
+
description: Success or error message
|
|
81
|
+
|
|
82
|
+
examples:
|
|
83
|
+
- name: "Add GET request with headers"
|
|
84
|
+
params:
|
|
85
|
+
collection_path: "./api-tests/payment-api"
|
|
86
|
+
request_name: "get-transactions"
|
|
87
|
+
method: "GET"
|
|
88
|
+
url: "https://api.payment.com/v1/transactions"
|
|
89
|
+
headers:
|
|
90
|
+
Authorization: "Bearer {api_token}"
|
|
91
|
+
Accept: "application/json"
|
|
92
|
+
|
|
93
|
+
- name: "Add POST request with body and tests"
|
|
94
|
+
params:
|
|
95
|
+
collection_path: "./api-tests/payment-api"
|
|
96
|
+
request_name: "create-payment"
|
|
97
|
+
method: "POST"
|
|
98
|
+
url: "https://api.payment.com/v1/payments"
|
|
99
|
+
headers:
|
|
100
|
+
Content-Type: "application/json"
|
|
101
|
+
Authorization: "Bearer {api_token}"
|
|
102
|
+
body: '{"amount": 100, "currency": "USD", "description": "Payment for order"}'
|
|
103
|
+
tests: |
|
|
104
|
+
test("Payment created with 201", function() {
|
|
105
|
+
expect(res.getStatus()).to.equal(201);
|
|
106
|
+
expect(res.getBody().id).to.exist;
|
|
107
|
+
});
|
|
108
|
+
documentation: "Create a new payment transaction"
|