Skip to content

Commit 0f992d6

Browse files
committed
tests
1 parent a50b848 commit 0f992d6

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

enterprise/cli/provisionerkeys_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"strings"
55
"testing"
66

7-
"github.com/google/uuid"
87
"github.com/stretchr/testify/require"
98

109
"github.com/coder/coder/v2/cli/clitest"
1110
"github.com/coder/coder/v2/coderd/coderdtest"
11+
"github.com/coder/coder/v2/coderd/provisionerkey"
1212
"github.com/coder/coder/v2/coderd/rbac"
1313
"github.com/coder/coder/v2/codersdk"
1414
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
@@ -58,10 +58,7 @@ func TestProvisionerKeys(t *testing.T) {
5858
_ = pty.ReadLine(ctx)
5959
key := pty.ReadLine(ctx)
6060
require.NotEmpty(t, key)
61-
parts := strings.Split(key, ":")
62-
require.Len(t, parts, 2, "expected 2 parts")
63-
_, err = uuid.Parse(parts[0])
64-
require.NoError(t, err, "expected token to be a uuid")
61+
require.NoError(t, provisionerkey.Validate(key))
6562

6663
inv, conf = newCLI(
6764
t,

enterprise/coderd/provisionerdaemons_test.go

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"io"
88
"net/http"
9-
"strings"
109
"testing"
1110

1211
"github.com/google/uuid"
@@ -612,36 +611,12 @@ func TestProvisionerDaemonServe(t *testing.T) {
612611
errStatusCode: http.StatusUnauthorized,
613612
},
614613
{
615-
name: "WrongKey",
614+
name: "InvalidKey",
616615
multiOrgFeatureEnabled: true,
617616
multiOrgExperimentEnabled: true,
618617
insertParams: insertParams,
619618
requestProvisionerKey: "provisionersftw",
620-
errStatusCode: http.StatusUnauthorized,
621-
},
622-
{
623-
name: "IdOKKeyValueWrong",
624-
multiOrgFeatureEnabled: true,
625-
multiOrgExperimentEnabled: true,
626-
insertParams: insertParams,
627-
requestProvisionerKey: insertParams.ID.String() + ":" + "wrong",
628-
errStatusCode: http.StatusUnauthorized,
629-
},
630-
{
631-
name: "IdWrongKeyValueOK",
632-
multiOrgFeatureEnabled: true,
633-
multiOrgExperimentEnabled: true,
634-
insertParams: insertParams,
635-
requestProvisionerKey: uuid.NewString() + ":" + token,
636-
errStatusCode: http.StatusUnauthorized,
637-
},
638-
{
639-
name: "KeyValueOnly",
640-
multiOrgFeatureEnabled: true,
641-
multiOrgExperimentEnabled: true,
642-
insertParams: insertParams,
643-
requestProvisionerKey: strings.Split(token, ":")[1],
644-
errStatusCode: http.StatusUnauthorized,
619+
errStatusCode: http.StatusBadRequest,
645620
},
646621
{
647622
name: "KeyAndPSK",

0 commit comments

Comments
 (0)