-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wip] feat: add http proxy support (#597)
* feat: add http proxy support * feat: enhance server command to print local IPs on startup - Added a new function `printLocalIPs` to display available local IP addresses when the server starts. - Integrated the IP printing functionality into both the mock command and the server command, improving visibility of server accessibility. This change helps users easily identify the server's available addresses for better connectivity. * feat: support to set proxy on ui * update the test suite page * test pass with the http proxy mode * update grpc files * update grpc files * support insecure during testing * fix the unit tests * add more unit testing --------- Co-authored-by: rick <[email protected]>
- Loading branch information
1 parent
7b25fa3
commit c827476
Showing
28 changed files
with
4,331 additions
and
3,752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Copyright 2025 API Testing Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"context" | ||
"github.com/linuxsuren/api-testing/pkg/server" | ||
fakeruntime "github.com/linuxsuren/go-fake-runtime" | ||
"github.com/stretchr/testify/assert" | ||
"io" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestMockCommand(t *testing.T) { | ||
tt := []struct { | ||
name string | ||
args []string | ||
verify func(t *testing.T, err error) | ||
}{ | ||
{ | ||
name: "mock", | ||
args: []string{"mock"}, | ||
verify: func(t *testing.T, err error) { | ||
assert.Error(t, err) | ||
}, | ||
}, | ||
{ | ||
name: "mock with file", | ||
args: []string{"mock", "testdata/stores.yaml", "--port=0"}, | ||
verify: func(t *testing.T, err error) { | ||
assert.NoError(t, err) | ||
}, | ||
}, | ||
} | ||
for _, tc := range tt { | ||
t.Run(tc.name, func(t *testing.T) { | ||
root := NewRootCmd(fakeruntime.FakeExecer{ExpectOS: "linux"}, server.NewFakeHTTPServer()) | ||
root.SetOut(io.Discard) | ||
root.SetArgs(tc.args) | ||
ctx, cancel := context.WithCancel(context.TODO()) | ||
root.SetContext(ctx) | ||
go func() { | ||
time.Sleep(time.Second * 2) | ||
cancel() | ||
}() | ||
err := root.Execute() | ||
tc.verify(t, err) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.