@@ -733,11 +733,11 @@ func TestHttpRun_WithAssertions(t *testing.T) {
733733 httpID := f .createHttpWithUrl (t , ws , "test-http" , testServer .URL , "GET" )
734734
735735 // Add assertions
736- f .createHttpAssertion (t , httpID , "status_code" , " 200" , "Status code should be 200" )
737- f .createHttpAssertion (t , httpID , "header.content_type" , " application/json" , "Content-Type should be application/json" )
738- f .createHttpAssertion (t , httpID , "header. x-custom-header" , " test-value" , "Custom header should match" )
739- f .createHttpAssertion (t , httpID , "body_json_path" , "$. status" , "Response should have success status" )
740- f .createHttpAssertion (t , httpID , "body_contains" , " success" , "Response should contain success" )
736+ f .createHttpAssertion (t , httpID , "response.status == 200" , "Status code should be 200" )
737+ f .createHttpAssertion (t , httpID , "response.headers['content-type'] == ' application/json' " , "Content-Type should be application/json" )
738+ f .createHttpAssertion (t , httpID , "response.headers[' x-custom-header'] == ' test-value' " , "Custom header should match" )
739+ f .createHttpAssertion (t , httpID , "response.body. status == 'success' " , "Response should have success status" )
740+ f .createHttpAssertion (t , httpID , "contains(string(response.body), ' success') " , "Response should contain success" )
741741
742742 req := connect .NewRequest (& httpv1.HttpRunRequest {
743743 HttpId : httpID .Bytes (),
@@ -984,7 +984,7 @@ func TestHttpRun_Assertions_StatusCode(t *testing.T) {
984984 ws := f .createWorkspace (t , "test-workspace" )
985985 httpID := f .createHttpWithUrl (t , ws , "test-http" , testServer .URL , "GET" )
986986
987- f .createHttpAssertion (t , httpID , "status_code " , tt .assertionValue , fmt .Sprintf ("Status should be %s" , tt .assertionValue ))
987+ f .createHttpAssertion (t , httpID , fmt . Sprintf ( "response.status == %s " , tt .assertionValue ) , fmt .Sprintf ("Status should be %s" , tt .assertionValue ))
988988
989989 req := connect .NewRequest (& httpv1.HttpRunRequest {
990990 HttpId : httpID .Bytes (),
@@ -1186,7 +1186,7 @@ func TestHttpRun_Assertions_CustomExpressions(t *testing.T) {
11861186 ws := f .createWorkspace (t , "test-workspace" )
11871187 httpID := f .createHttpWithUrl (t , ws , "test-http" , testServer .URL , "GET" )
11881188
1189- f .createHttpAssertion (t , httpID , "" , tt .expression , fmt .Sprintf ("Custom expression: %s" , tt .expression ))
1189+ f .createHttpAssertion (t , httpID , tt .expression , fmt .Sprintf ("Custom expression: %s" , tt .expression ))
11901190
11911191 req := connect .NewRequest (& httpv1.HttpRunRequest {
11921192 HttpId : httpID .Bytes (),
@@ -1217,20 +1217,19 @@ func TestHttpRun_Assertions_MultipleAssertions(t *testing.T) {
12171217
12181218 // Add multiple assertions
12191219 assertions := []struct {
1220- key string
1221- value string
1222- desc string
1220+ expression string
1221+ desc string
12231222 }{
1224- {"status_code" , " 200" , "Status should be 200" },
1225- {"header.content_type" , " application/json" , "Content-Type should be JSON" },
1226- {"header. x-api-version" , " v1.2.3" , "API version should match" },
1227- {"body_contains" , " success" , "Response should contain success" },
1228- {"body_json_path" , "$. data.id" , "Product ID should exist" },
1229- {"" , `response.status == "success" && response.data.price > 25` , "Complex validation" },
1223+ {"response.status == 200" , "Status should be 200" },
1224+ {"response.headers['content-type'] == ' application/json' " , "Content-Type should be JSON" },
1225+ {"response.headers[' x-api-version'] == ' v1.2.3' " , "API version should match" },
1226+ {"contains(string(response.body), ' success') " , "Response should contain success" },
1227+ {"has(response.body. data.id) " , "Product ID should exist" },
1228+ {`response.status == "success" && response.data.price > 25` , "Complex validation" },
12301229 }
12311230
12321231 for _ , assertion := range assertions {
1233- f .createHttpAssertion (t , httpID , assertion .key , assertion . value , assertion .desc )
1232+ f .createHttpAssertion (t , httpID , assertion .expression , assertion .desc )
12341233 }
12351234
12361235 req := connect .NewRequest (& httpv1.HttpRunRequest {
@@ -1251,35 +1250,32 @@ func TestHttpRun_Assertions_ErrorResponses(t *testing.T) {
12511250 responseStatus int
12521251 responseBody string
12531252 assertions []struct {
1254- key string
1255- value string
1256- desc string
1253+ expression string
1254+ desc string
12571255 }
12581256 }{
12591257 {
12601258 name : "404 not found" ,
12611259 responseStatus : 404 ,
12621260 responseBody : `{"error":"Not Found","message":"Resource not found"}` ,
12631261 assertions : []struct {
1264- key string
1265- value string
1266- desc string
1262+ expression string
1263+ desc string
12671264 }{
1268- {"status_code" , " 404" , "Status should be 404" },
1269- {"body_contains" , " Not Found" , "Body should contain error message" },
1265+ {"response.status == 404" , "Status should be 404" },
1266+ {"contains(string(response.body), ' Not Found') " , "Body should contain error message" },
12701267 },
12711268 },
12721269 {
12731270 name : "500 server error" ,
12741271 responseStatus : 500 ,
12751272 responseBody : `{"error":"Internal Server Error","message":"Something went wrong"}` ,
12761273 assertions : []struct {
1277- key string
1278- value string
1279- desc string
1274+ expression string
1275+ desc string
12801276 }{
1281- {"status_code" , " 500" , "Status should be 500" },
1282- {"body_contains" , " Internal Server Error" , "Body should contain error" },
1277+ {"response.status == 500" , "Status should be 500" },
1278+ {"contains(string(response.body), ' Internal Server Error') " , "Body should contain error" },
12831279 },
12841280 },
12851281 }
@@ -1300,7 +1296,7 @@ func TestHttpRun_Assertions_ErrorResponses(t *testing.T) {
13001296 httpID := f .createHttpWithUrl (t , ws , "test-http" , testServer .URL , "GET" )
13011297
13021298 for _ , assertion := range tt .assertions {
1303- f .createHttpAssertion (t , httpID , assertion .key , assertion . value , assertion .desc )
1299+ f .createHttpAssertion (t , httpID , assertion .expression , assertion .desc )
13041300 }
13051301
13061302 req := connect .NewRequest (& httpv1.HttpRunRequest {
@@ -1605,11 +1601,11 @@ func TestHttpRun_ConcurrentWithDifferentRequests(t *testing.T) {
16051601
16061602 // Add assertions for each
16071603 if i == 0 {
1608- f .createHttpAssertion (t , httpIDs [i ], "status_code" , " 200" , "Status should be 200" )
1604+ f .createHttpAssertion (t , httpIDs [i ], "response.status == 200" , "Status should be 200" )
16091605 } else if i == 1 {
1610- f .createHttpAssertion (t , httpIDs [i ], "header. x-api-version" , " v2.0" , "API version should match" )
1606+ f .createHttpAssertion (t , httpIDs [i ], "response.headers[' x-api-version'] == ' v2.0' " , "API version should match" )
16111607 } else {
1612- f .createHttpAssertion (t , httpIDs [i ], "status_code" , " 404" , "Status should be 404" )
1608+ f .createHttpAssertion (t , httpIDs [i ], "response.status == 404" , "Status should be 404" )
16131609 }
16141610 }
16151611
@@ -2074,7 +2070,7 @@ func TestHttpRun_ComplexVariableSubstitution(t *testing.T) {
20742070 f .createHttpSearchParam (t , httpID , "debug" , "{{debugMode}}" )
20752071
20762072 // Add assertions that use variables in expected values
2077- f .createHttpAssertion (t , httpID , "status_code" , " 200" , "Status code should be 200" )
2073+ f .createHttpAssertion (t , httpID , "response.status == 200" , "Status code should be 200" )
20782074 // The server returns the raw "{{userId}}" string, but our assertion logic resolves the expected value "12345".
20792075 // So "12345" will NOT be found in `... "userId":"{{userId}}"`.
20802076 // We need to relax this assertion or update the server.
@@ -2139,14 +2135,14 @@ func TestHttpRun_VariableSubstitutionChaining_Simulated(t *testing.T) {
21392135
21402136 // First HTTP request that would "generate" variables
21412137 firstHttpID := f .createHttpWithUrl (t , ws , "first-request" , firstServer .URL , "GET" )
2142- f .createHttpAssertion (t , firstHttpID , "status_code" , " 200" , "First request should succeed" )
2143- f .createHttpAssertion (t , firstHttpID , "body_contains" , " userId" , "Response should contain userId" )
2138+ f .createHttpAssertion (t , firstHttpID , "response.status == 200" , "First request should succeed" )
2139+ f .createHttpAssertion (t , firstHttpID , "contains(string(response.body), ' userId') " , "Response should contain userId" )
21442140
21452141 // Second HTTP request that would use variables from first request
21462142 secondHttpID := f .createHttpWithUrl (t , ws , "second-request" , secondServer .URL + "?data={{response.userId}}" , "GET" )
21472143 f .createHttpHeader (t , secondHttpID , "Authorization" , "Bearer {{response.token}}" )
2148- f .createHttpAssertion (t , secondHttpID , "status_code" , " 200" , "Second request should succeed" )
2149- f .createHttpAssertion (t , secondHttpID , "body_contains" , " chainedData" , "Response should contain chained data" )
2144+ f .createHttpAssertion (t , secondHttpID , "response.status == 200" , "Second request should succeed" )
2145+ f .createHttpAssertion (t , secondHttpID , "contains(string(response.body), ' chainedData') " , "Response should contain chained data" )
21502146
21512147 // Execute first request
21522148 firstReq := connect .NewRequest (& httpv1.HttpRunRequest {
0 commit comments