Skip to content

Commit 4dc884f

Browse files
committed
Fix test failures after depfinder minimum length change
The depfinder was updated to require 8+ character substrings to avoid false positives. Update test HAR data to use longer tokens (abc-12345-xyz instead of abc-123) so dependency detection works correctly. Also fix: - Add missing HttpAssertService to rexportv2 integration test fixture - Fix URL comparison in delta E2E test to handle domain variable templating
1 parent bbf483a commit 4dc884f

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

packages/server/internal/api/rexportv2/integration_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import (
3131
"the-dev-tools/server/pkg/service/suser"
3232
"the-dev-tools/server/pkg/service/sworkspace"
3333
"the-dev-tools/server/pkg/service/sworkspacesusers"
34+
"the-dev-tools/server/pkg/service/senv"
35+
"the-dev-tools/server/pkg/service/svar"
3436
"the-dev-tools/server/pkg/testutil"
3537
exportv1 "the-dev-tools/spec/dist/buf/go/api/export/v1"
3638

@@ -63,12 +65,15 @@ type BaseTestServices struct {
6365
HttpBodyFormService *shttp.HttpBodyFormService
6466
HttpBodyUrlEncodedService *shttp.HttpBodyUrlEncodedService
6567
BodyService *shttp.HttpBodyRawService
68+
HttpAssertService *shttp.HttpAssertService
6669

6770
// Flow related services
6871
NodeService *snode.NodeService
6972
NodeRequestService *snoderequest.NodeRequestService
7073
NodeNoopService *snodenoop.NodeNoopService
7174
EdgeService *sedge.EdgeService
75+
EnvService senv.EnvironmentService
76+
VarService svar.VarService
7277
}
7378

7479
// newIntegrationTestFixture creates a complete test environment for integration tests
@@ -93,11 +98,14 @@ func newIntegrationTestFixture(t *testing.T) *integrationTestFixture {
9398
httpBodyFormService := shttp.NewHttpBodyFormService(base.Queries)
9499
httpBodyUrlEncodedService := shttp.NewHttpBodyUrlEncodedService(base.Queries)
95100
bodyService := shttp.NewHttpBodyRawService(base.Queries)
101+
httpAssertService := shttp.NewHttpAssertService(base.Queries)
96102

97103
nodeService := snode.New(base.Queries)
98104
nodeRequestService := snoderequest.New(base.Queries)
99105
nodeNoopService := snodenoop.New(base.Queries)
100106
edgeService := sedge.New(base.Queries)
107+
envService := senv.New(base.Queries, logger)
108+
varService := svar.New(base.Queries, logger)
101109

102110
// Create user and workspace
103111
userID := idwrap.NewNow()
@@ -156,10 +164,13 @@ func newIntegrationTestFixture(t *testing.T) *integrationTestFixture {
156164
HttpBodyFormService: httpBodyFormService,
157165
HttpBodyUrlEncodedService: httpBodyUrlEncodedService,
158166
BodyService: bodyService,
167+
HttpAssertService: httpAssertService,
159168
NodeService: &nodeService,
160169
NodeRequestService: &nodeRequestService,
161170
NodeNoopService: &nodeNoopService,
162171
EdgeService: &edgeService,
172+
EnvService: envService,
173+
VarService: varService,
163174
}
164175

165176
return &integrationTestFixture{
@@ -580,10 +591,13 @@ func createImportService(t *testing.T, fixture *integrationTestFixture) *rimport
580591
fixture.services.HttpBodyFormService,
581592
fixture.services.HttpBodyUrlEncodedService,
582593
fixture.services.BodyService,
594+
fixture.services.HttpAssertService,
583595
fixture.services.NodeService,
584596
fixture.services.NodeRequestService,
585597
fixture.services.NodeNoopService,
586598
fixture.services.EdgeService,
599+
fixture.services.EnvService,
600+
fixture.services.VarService,
587601
)
588602
validator := rimportv2.NewValidator(&fixture.services.Us)
589603

packages/server/internal/api/rimportv2/rimportv2_delta_e2e_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package rimportv2
22

33
import (
4+
"strings"
45
"testing"
56
"time"
67

@@ -22,7 +23,7 @@ func TestImportV2_DeltaE2E(t *testing.T) {
2223
fixture := newIntegrationTestFixture(t)
2324

2425
// 1. Create HAR with Dependency
25-
// Request A: Returns token
26+
// Request A: Returns token (>= 8 chars for depfinder matching)
2627
// Request B: Uses token
2728
harData := []byte(`{
2829
"log": {
@@ -44,7 +45,7 @@ func TestImportV2_DeltaE2E(t *testing.T) {
4445
"headers": [{"name": "Content-Type", "value": "application/json"}],
4546
"content": {
4647
"mimeType": "application/json",
47-
"text": "{\"token\": \"abc-123\"}"
48+
"text": "{\"token\": \"abc-12345-xyz\"}"
4849
}
4950
}
5051
},
@@ -55,7 +56,7 @@ func TestImportV2_DeltaE2E(t *testing.T) {
5556
"url": "https://api.com/profile",
5657
"httpVersion": "HTTP/1.1",
5758
"headers": [
58-
{"name": "Authorization", "value": "Bearer abc-123"}
59+
{"name": "Authorization", "value": "Bearer abc-12345-xyz"}
5960
]
6061
},
6162
"response": {
@@ -171,7 +172,8 @@ func TestImportV2_DeltaE2E(t *testing.T) {
171172
select {
172173
case evt := <-httpSub:
173174
httpEvents++
174-
if evt.Payload.Http.Url == "https://api.com/profile" {
175+
// After import with domain variable, URL becomes {{API_HOST}}/profile
176+
if strings.Contains(evt.Payload.Http.Url, "profile") {
175177
if evt.Payload.IsDelta {
176178
deltaB_ID = evt.Payload.Http.HttpId
177179
} else {

packages/server/test/har_import_dep_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
)
2222

2323
// HAR with Dependency
24-
// Request 1: Login returns token "abc-123"
25-
// Request 2: Profile uses "Bearer abc-123"
24+
// Request 1: Login returns token "abc-12345-xyz" (>= 8 chars for depfinder matching)
25+
// Request 2: Profile uses "Bearer abc-12345-xyz"
2626
const harWithDeps = `{
2727
"log": {
2828
"version": "1.2",
@@ -40,7 +40,7 @@ const harWithDeps = `{
4040
"status": 200,
4141
"content": {
4242
"mimeType": "application/json",
43-
"text": "{\"token\": \"abc-123\", \"userId\": 99}"
43+
"text": "{\"token\": \"abc-12345-xyz\", \"userId\": 99}"
4444
}
4545
}
4646
},
@@ -53,7 +53,7 @@ const harWithDeps = `{
5353
"headers": [
5454
{
5555
"name": "Authorization",
56-
"value": "Bearer abc-123"
56+
"value": "Bearer abc-12345-xyz"
5757
},
5858
{
5959
"name": "X-Static",
@@ -126,10 +126,10 @@ func TestHARImport_DependencyDetection(t *testing.T) {
126126
require.NotNil(t, authHeaderEvent, "Should find a Delta Authorization header")
127127

128128
// The value should be templated, e.g., "Bearer {{...}}"
129-
// It should NOT be "Bearer abc-123"
129+
// It should NOT be "Bearer abc-12345-xyz"
130130
t.Logf("Found Delta Authorization Header in Sync: %s", authHeaderEvent.HttpHeader.Value)
131131
assert.Contains(t, authHeaderEvent.HttpHeader.Value, "{{", "Value should contain variable template")
132-
assert.NotContains(t, authHeaderEvent.HttpHeader.Value, "abc-123", "Value should NOT contain raw secret")
132+
assert.NotContains(t, authHeaderEvent.HttpHeader.Value, "abc-12345-xyz", "Value should NOT contain raw secret")
133133
assert.Contains(t, authHeaderEvent.HttpHeader.Value, "Bearer ", "Value should preserve prefix")
134134

135135
// 4. Verify Collection Consistency

0 commit comments

Comments
 (0)