Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ test("cannot read keys from a different workspace", async (t) => {
const h = await IntegrationHarness.init(t);

const workspaceId = newId("workspace");
const name = randomUUID();
await h.db.primary.insert(schema.workspaces).values({
id: workspaceId,
orgId: randomUUID(),
name: randomUUID(),
name: name,
slug: name,
features: {},
betaFeatures: {},
});
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/app/(app)/gateway-new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* 4. The user is redirected to create their API
*/

import { randomInt } from "node:crypto";
import { getAuth } from "@/lib/auth";
import { db, schema } from "@/lib/db";
import { freeTierQuotas } from "@/lib/quotas";
Expand All @@ -28,6 +29,7 @@ export default async function Page() {
await db.insert(schema.workspaces).values({
id,
name: "Personal Workspace",
slug: `personal-workspace-${randomInt(100000)}`,
orgId,
betaFeatures: {},
features: {},
Expand Down
2 changes: 2 additions & 0 deletions deployment/04-seed-workspace.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ INSERT INTO workspaces (
id,
org_id,
name,
slug,
created_at_m,
beta_features,
features
) VALUES (
'ws_local_root',
'user_REPLACE_ME',
'Unkey',
'unkey',
UNIX_TIMESTAMP() * 1000,
'{}',
'{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func TestSuccess(t *testing.T) {
err = db.Query.InsertWorkspace(ctx, tx, db.InsertWorkspaceParams{
ID: singleWorkspaceID,
Name: "Single Identity Workspace",
Slug: uid.New("slug"),
OrgID: uid.New(uid.OrgPrefix),
CreatedAt: time.Now().UnixMilli(),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handler_test

import (
"fmt"
"maps"
"net/http"
"strings"
"testing"
Expand Down Expand Up @@ -80,9 +81,7 @@ func TestBadRequests(t *testing.T) {

t.Run("malformed JSON body", func(t *testing.T) {
customHeaders := make(http.Header)
for k, v := range headers {
customHeaders[k] = v
}
maps.Copy(customHeaders, headers)
customHeaders.Set("Content-Type", "application/json")

// Create a malformed JSON string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestCrossWorkspaceForbidden(t *testing.T) {
err = db.Query.InsertWorkspace(ctx, tx, db.InsertWorkspaceParams{
ID: workspaceB,
Name: "Test Workspace B",
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
OrgID: uid.New("org"),
})
Expand Down
1 change: 1 addition & 0 deletions go/apps/api/routes/v2_keys_add_permissions/404_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestNotFoundErrors(t *testing.T) {
ID: otherWorkspaceID,
OrgID: uid.New("test_org"),
Name: "Other Workspace",
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
})
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func TestAuthorizationErrors(t *testing.T) {
ID: otherWorkspaceID,
OrgID: uid.New("test_org"),
Name: "Other Workspace",
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
})
require.NoError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions go/apps/api/routes/v2_keys_remove_permissions/404_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func TestNotFoundErrors(t *testing.T) {
ID: otherWorkspaceID,
OrgID: uid.New("test_org"),
Name: "Other Workspace",
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
})
require.NoError(t, err)
Expand Down Expand Up @@ -189,6 +190,7 @@ func TestNotFoundErrors(t *testing.T) {
ID: otherWorkspaceID,
OrgID: uid.New("test_org"),
Name: "Other Workspace",
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
})
require.NoError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions go/apps/api/routes/v2_keys_set_roles/404_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func TestNotFoundErrors(t *testing.T) {
ID: otherWorkspaceID,
OrgID: uid.New("test_org"),
Name: uid.New("test_name"),
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
})
require.NoError(t, err)
Expand Down Expand Up @@ -215,6 +216,7 @@ func TestNotFoundErrors(t *testing.T) {
ID: otherWorkspaceID,
OrgID: uid.New("test_org"),
Name: uid.New("test_name"),
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
})
require.NoError(t, err)
Expand Down
5 changes: 3 additions & 2 deletions go/pkg/db/bulk_workspace_insert.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/pkg/db/models_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion go/pkg/db/querier_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion go/pkg/db/queries/workspace_insert.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ INSERT INTO `workspaces` (
id,
org_id,
name,
slug,
created_at_m,
tier,
beta_features,
Expand All @@ -14,7 +15,8 @@ VALUES (
sqlc.arg(id),
sqlc.arg(org_id),
sqlc.arg(name),
sqlc.arg(created_at),
sqlc.arg(slug),
sqlc.arg(created_at),
'Free',
'{}',
'{}',
Expand Down
1 change: 1 addition & 0 deletions go/pkg/db/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func TestWithRetry_Integration(t *testing.T) {
ID: workspaceID,
OrgID: workspaceID,
Name: "Test Workspace",
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
})
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion go/pkg/db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ CREATE TABLE `workspaces` (
`id` varchar(256) NOT NULL,
`org_id` varchar(256) NOT NULL,
`name` varchar(256) NOT NULL,
`slug` varchar(64),
`slug` varchar(64) NOT NULL,
`partition_id` varchar(256),
`plan` enum('free','pro','enterprise') DEFAULT 'free',
`tier` varchar(256) DEFAULT 'Free',
Expand Down
10 changes: 8 additions & 2 deletions go/pkg/db/workspace_insert.sql_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/pkg/testutil/seed/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *Seeder) CreateWorkspace(ctx context.Context) db.Workspace {
ID: uid.New("test_ws"),
OrgID: uid.New("test_org"),
Name: uid.New("test_name"),
Slug: uid.New("slug"),
CreatedAt: time.Now().UnixMilli(),
}

Expand Down
2 changes: 1 addition & 1 deletion internal/db/src/schema/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const workspaces = mysqlTable("workspaces", {
name: varchar("name", { length: 256 }).notNull(),

// slug is used for the workspace URL
slug: varchar("slug", { length: 64 }).unique(),
slug: varchar("slug", { length: 64 }).notNull().unique(),

// Deployment platform - which partition this workspace deploys to
partitionId: varchar("partition_id", { length: 256 }),
Expand Down
6 changes: 5 additions & 1 deletion internal/resend/emails/api_v1_migration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export type Props = {
deprecatedEndpoints: string[];
};

export function ApiV1Migration({ username, workspaceName, deprecatedEndpoints }: Props) {
export function ApiV1Migration({
username = "User",
workspaceName = "Your Workspace",
deprecatedEndpoints = [],
}: Props) {
return (
<Layout>
<Heading className="font-sans text-3xl text-semibold text-center">
Expand Down