Skip to content

Commit a826188

Browse files
authored
chore: Split up API install integration test file (#2439)
split api install integration test
1 parent 5ad7436 commit a826188

File tree

14 files changed

+3189
-3031
lines changed

14 files changed

+3189
-3031
lines changed

api/integration/assets/embed.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package assets
2+
3+
import _ "embed"
4+
5+
//go:embed license.yaml
6+
var LicenseData []byte

api/integration/auth/controller.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package auth
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/replicatedhq/embedded-cluster/api/controllers/auth"
8+
)
9+
10+
var _ auth.Controller = &StaticAuthController{}
11+
12+
type StaticAuthController struct {
13+
token string
14+
}
15+
16+
// NewStaticAuthController creates a new StaticAuthController with the given token
17+
func NewStaticAuthController(token string) *StaticAuthController {
18+
return &StaticAuthController{token: token}
19+
}
20+
21+
func (s *StaticAuthController) Authenticate(ctx context.Context, password string) (string, error) {
22+
return s.token, nil
23+
}
24+
25+
func (s *StaticAuthController) ValidateToken(ctx context.Context, token string) error {
26+
if token != s.token {
27+
return fmt.Errorf("invalid token")
28+
}
29+
return nil
30+
}

api/integration/auth_controller_test.go renamed to api/integration/auth/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package integration
1+
package auth
22

33
import (
44
"bytes"

api/integration/auth_controller.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

api/integration/console_test.go renamed to api/integration/console/controller_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/gorilla/mux"
1010
"github.com/replicatedhq/embedded-cluster/api"
1111
"github.com/replicatedhq/embedded-cluster/api/controllers/console"
12+
"github.com/replicatedhq/embedded-cluster/api/integration/auth"
1213
"github.com/replicatedhq/embedded-cluster/api/internal/utils"
1314
"github.com/replicatedhq/embedded-cluster/api/pkg/logger"
1415
"github.com/replicatedhq/embedded-cluster/api/types"
@@ -32,7 +33,7 @@ func TestConsoleListAvailableNetworkInterfaces(t *testing.T) {
3233
Password: "password",
3334
},
3435
api.WithConsoleController(consoleController),
35-
api.WithAuthController(&staticAuthController{"TOKEN"}),
36+
api.WithAuthController(auth.NewStaticAuthController("TOKEN")),
3637
api.WithLogger(logger.NewDiscardLogger()),
3738
)
3839
require.NoError(t, err)
@@ -80,7 +81,7 @@ func TestConsoleListAvailableNetworkInterfacesUnauthorized(t *testing.T) {
8081
Password: "password",
8182
},
8283
api.WithConsoleController(consoleController),
83-
api.WithAuthController(&staticAuthController{"VALID_TOKEN"}),
84+
api.WithAuthController(auth.NewStaticAuthController("VALID_TOKEN")),
8485
api.WithLogger(logger.NewDiscardLogger()),
8586
)
8687
require.NoError(t, err)
@@ -124,7 +125,7 @@ func TestConsoleListAvailableNetworkInterfacesError(t *testing.T) {
124125
Password: "password",
125126
},
126127
api.WithConsoleController(consoleController),
127-
api.WithAuthController(&staticAuthController{"TOKEN"}),
128+
api.WithAuthController(auth.NewStaticAuthController("TOKEN")),
128129
api.WithLogger(logger.NewDiscardLogger()),
129130
)
130131
require.NoError(t, err)

0 commit comments

Comments
 (0)