Skip to content

Commit

Permalink
Test more bad configurations.
Browse files Browse the repository at this point in the history
And while we're at it, rename "ext-pub-port" to "ext-port".
  • Loading branch information
NullHypothesis committed Dec 12, 2024
1 parent 9f0901c commit 51003a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/veil/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func parseFlags(out io.Writer, args []string) (*config.Config, error) {
"the enclave application's source code",
)
extPort := fs.Int(
"ext-pub-port",
"ext-port",
defaultExtPort,
"external public port",
"external port",
)
fqdn := fs.String(
"fqdn",
Expand Down
27 changes: 23 additions & 4 deletions cmd/veil/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,29 @@ func errFromBody(t *testing.T, resp *http.Response) string {
}

func TestBadConfig(t *testing.T) {
require.Error(t, run(context.Background(), io.Discard, []string{
// Provide an invalid port, which should cause the service to fail.
"-ext-pub-port", "foo",
}))
cases := []struct {
name string
args []string
}{
{
name: "bad external port",
args: []string{"-ext-port", "foo"},
},
{
name: "bad internal port",
args: []string{"-int-port", "65536"},
},
{
name: "bad application url",
args: []string{"-app-web-srv", "http://localhost:foo"},
},
}

for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
require.Error(t, run(context.Background(), io.Discard, c.args))
})
}
}

func TestHelp(t *testing.T) {
Expand Down

0 comments on commit 51003a7

Please sign in to comment.