(&Method::GET, ["api", "v1"]) => *apifunc = Some(rustweb::apiDiscoveryV1),
(&Method::GET, ["api"]) => *apifunc = Some(rustweb::apiDiscovery),
(&Method::GET, ["metrics"]) => *rawfunc = Some(rustweb::prometheusMetrics),
- (&Method::GET, ["api", "v1", "servers", "localhost", "otconditions"]) => {
+ (&Method::GET, ["api", "v1", "servers", "localhost", "ottraceconditions"]) => {
*apifunc = Some(rustweb::apiServerOTConditionsGET);
}
- (&Method::GET, ["api", "v1", "servers", "localhost", "otconditions", acl]) => {
+ (&Method::GET, ["api", "v1", "servers", "localhost", "ottraceconditions", acl]) => {
let decoded = form_urlencoded::parse(acl.as_bytes());
// decoded should contain a single key without value
if let Some(kv) = decoded.last() {
}
*apifunc = Some(rustweb::apiServerOTConditionDetailGET)
}
- (&Method::DELETE, ["api", "v1", "servers", "localhost", "otconditions", acl]) => {
+ (&Method::DELETE, ["api", "v1", "servers", "localhost", "ottraceconditions", acl]) => {
let decoded = form_urlencoded::parse(acl.as_bytes());
// decoded should contain a single key without value
if let Some(kv) = decoded.last() {
}
*apifunc = Some(rustweb::apiServerOTConditionDetailDELETE)
}
- (&Method::POST, ["api", "v1", "servers", "localhost", "otconditions"]) => {
+ (&Method::POST, ["api", "v1", "servers", "localhost", "ottraceconditions"]) => {
*apifunc = Some(rustweb::apiServerOTConditionDetailPOST)
}
_ => *filefunc = Some(file),
def test_basic_ot_conditions(self):
# initial list is empty
r = self.session.get(
- self.url("/api/v1/servers/localhost/otconditions"),
+ self.url("/api/v1/servers/localhost/ottraceconditions"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 200)
self.assertEqual(r.json(), [])
# nonexistent condition
r = self.session.get(
- self.url("/api/v1/servers/localhost/otconditions/1.2.3.4%2F32"),
+ self.url("/api/v1/servers/localhost/ottraceconditions/1.2.3.4%2F32"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 422)
self.assert_in_json_error('Could not find otcondition', r.json())
# malformed netmask
r = self.session.get(
- self.url("/api/v1/servers/localhost/otconditions/1.2.3%2F32"),
+ self.url("/api/v1/servers/localhost/ottraceconditions/1.2.3%2F32"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 422)
self.assert_in_json_error('Could not parse netmask', r.json())
# deleting non-existent netmask
r = self.session.delete(
- self.url("/api/v1/servers/localhost/otconditions/1.2.3.4%2F32"),
+ self.url("/api/v1/servers/localhost/ottraceconditions/1.2.3.4%2F32"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 422)
self.assert_in_json_error('Could not find otcondition', r.json())
"acl": "1.2.3.4"
}
r = self.session.post(
- self.url("/api/v1/servers/localhost/otconditions"),
+ self.url("/api/v1/servers/localhost/ottraceconditions"),
data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 201)
self.assertIn('acl', data)
self.assertIn('edns_option_required', data)
self.assertIn('traceid_only', data)
+ self.assertIn('type', data)
self.assertEqual(data['acl'], '1.2.3.4/32')
+ self.assertEqual(data['type'], 'OpenTelemetryTraceCondition')
self.assertFalse(data['edns_option_required'])
self.assertFalse(data['traceid_only'])
"acl": "1.2.3.4"
}
r = self.session.post(
- self.url("/api/v1/servers/localhost/otconditions"),
+ self.url("/api/v1/servers/localhost/ottraceconditions"),
data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 422)
# list has one element
r = self.session.get(
- self.url("/api/v1/servers/localhost/otconditions"),
+ self.url("/api/v1/servers/localhost/ottraceconditions"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 200)
self.assertEqual(len(r.json()), 1)
"acl": "1.2.3.0/24"
}
r = self.session.post(
- self.url("/api/v1/servers/localhost/otconditions"),
+ self.url("/api/v1/servers/localhost/ottraceconditions"),
data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 201)
# list has two elements
r = self.session.get(
- self.url("/api/v1/servers/localhost/otconditions"),
+ self.url("/api/v1/servers/localhost/ottraceconditions"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 200)
self.assertEqual(len(r.json()), 2)
# querying by more specific key
r = self.session.get(
- self.url("/api/v1/servers/localhost/otconditions/1.2.3.4%2F31"),
+ self.url("/api/v1/servers/localhost/ottraceconditions/1.2.3.4%2F31"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 422)
self.assert_in_json_error('Could not find otcondition', r.json())
# deleting specific netmask
r = self.session.delete(
- self.url("/api/v1/servers/localhost/otconditions/1.2.3.4%2F32"),
+ self.url("/api/v1/servers/localhost/ottraceconditions/1.2.3.4%2F32"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 204)
# list has one elements
r = self.session.get(
- self.url("/api/v1/servers/localhost/otconditions"),
+ self.url("/api/v1/servers/localhost/ottraceconditions"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 200)
self.assertEqual(len(r.json()), 1)
"edns_option_required": True
}
r = self.session.post(
- self.url("/api/v1/servers/localhost/otconditions"),
+ self.url("/api/v1/servers/localhost/ottraceconditions"),
data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 201)
self.assertIn('qtypes', data)
self.assertIn('traceid_only', data)
self.assertIn('edns_option_required', data)
+ self.assertIn('type', data)
self.assertEqual(data['acl'], '::/0')
self.assertEqual(data['qid'], 99)
self.assertEqual(len(data['qnames']), 3)
self.assertEqual(len(data['qtypes']), 2)
+ self.assertEqual(data['type'], 'OpenTelemetryTraceCondition')
self.assertTrue(data['edns_option_required'])
self.assertTrue(data['traceid_only'])
# and GET the newly created one in a separate call
r = self.session.get(
- self.url("/api/v1/servers/localhost/otconditions/::1%2F0"),
+ self.url("/api/v1/servers/localhost/ottraceconditions/::1%2F0"),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 200)
data = r.json()
self.assertIn('qtypes', data)
self.assertIn('traceid_only', data)
self.assertIn('edns_option_required', data)
+ self.assertIn('type', data)
self.assertEqual(data['acl'], '::/0')
self.assertEqual(data['qid'], 99)
self.assertEqual(len(data['qnames']), 3)
self.assertEqual(len(data['qtypes']), 2)
+ self.assertEqual(data['type'], 'OpenTelemetryTraceCondition')
self.assertTrue(data['edns_option_required'])
self.assertTrue(data['traceid_only'])