Skip to content

Commit 38558ad

Browse files
Merge branch 'main' into cal-6307
2 parents 8fd3a01 + d2f8076 commit 38558ad

File tree

57 files changed

+2769
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2769
-286
lines changed

.changeset/shiny-jokes-matter.md

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

.changeset/stale-tires-report.md

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

.changeset/tough-dingos-own.md

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

.github/workflows/all-checks.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ jobs:
7474
uses: ./.github/workflows/e2e-embed-react.yml
7575
secrets: inherit
7676

77+
e2e-atoms:
78+
name: Tests
79+
needs: [lint, build, build-atoms, build-api-v2]
80+
uses: ./.github/workflows/e2e-atoms.yml
81+
secrets: inherit
82+
7783
required:
78-
needs: [lint, type-check, unit-test, integration-test, build, build-api-v1, build-api-v2, e2e, e2e-embed, e2e-embed-react, e2e-app-store]
84+
needs: [lint, type-check, unit-test, integration-test, build, build-api-v1, build-api-v2, e2e, e2e-embed, e2e-embed-react, e2e-app-store, e2e-atoms]
7985
if: always()
8086
runs-on: buildjet-2vcpu-ubuntu-2204
8187
steps:
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
name: Atoms E2E Tests
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
7-
paths:
8-
- 'packages/platform/atoms/**'
9-
- 'packages/platform/examples/base/**'
10-
- 'apps/api/v2/**'
11-
- '.github/workflows/atoms-e2e.yml'
12-
4+
workflow_call:
135
permissions:
146
actions: write
157
contents: read
@@ -25,7 +17,7 @@ env:
2517
DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}
2618

2719
jobs:
28-
atoms-e2e:
20+
e2e-atoms:
2921
timeout-minutes: 15
3022
name: Atoms E2E Tests
3123
runs-on: buildjet-4vcpu-ubuntu-2204
@@ -45,13 +37,13 @@ jobs:
4537
uses: actions/upload-artifact@v4
4638
if: always()
4739
with:
48-
name: atoms-e2e-test-results
40+
name: e2e-atoms-test-results
4941
path: test-results
5042
retention-days: 7
5143
- name: Upload Playwright Report
5244
uses: actions/upload-artifact@v4
5345
if: always()
5446
with:
55-
name: atoms-e2e-playwright-report
47+
name: e2e-atoms-playwright-report
5648
path: playwright-report
5749
retention-days: 7

.github/workflows/pr.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ jobs:
195195
uses: ./.github/workflows/e2e-embed-react.yml
196196
secrets: inherit
197197

198+
e2e-atoms:
199+
name: Tests
200+
needs: [changes, check-label, build, build-atoms, build-api-v2]
201+
if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
202+
uses: ./.github/workflows/e2e-atoms.yml
203+
secrets: inherit
204+
198205
analyze:
199206
name: Analyze Build
200207
needs: [build]
@@ -204,7 +211,7 @@ jobs:
204211
merge-reports:
205212
name: Merge reports
206213
if: ${{ !cancelled() && needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
207-
needs: [changes, check-label, e2e, e2e-embed, e2e-embed-react, e2e-app-store]
214+
needs: [changes, check-label, e2e, e2e-embed, e2e-embed-react, e2e-app-store, e2e-atoms]
208215
uses: ./.github/workflows/merge-reports.yml
209216
secrets: inherit
210217

@@ -249,6 +256,7 @@ jobs:
249256
e2e-embed,
250257
e2e-embed-react,
251258
e2e-app-store,
259+
e2e-atoms,
252260
]
253261
if: always()
254262
runs-on: buildjet-2vcpu-ubuntu-2204

apps/api/v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@axiomhq/winston": "^1.2.0",
3939
"@calcom/platform-constants": "*",
4040
"@calcom/platform-enums": "*",
41-
"@calcom/platform-libraries": "npm:@calcom/[email protected].320",
41+
"@calcom/platform-libraries": "npm:@calcom/[email protected].321",
4242
"@calcom/platform-types": "*",
4343
"@calcom/platform-utils": "*",
4444
"@calcom/prisma": "*",

apps/api/v2/src/ee/bookings/2024-08-13/bookings.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { BookingSeatModule } from "@/modules/booking-seat/booking-seat.module";
2222
import { BookingSeatRepository } from "@/modules/booking-seat/booking-seat.repository";
2323
import { CredentialsRepository } from "@/modules/credentials/credentials.repository";
2424
import { KyselyModule } from "@/modules/kysely/kysely.module";
25+
import { MembershipsModule } from "@/modules/memberships/memberships.module";
2526
import { OAuthClientRepository } from "@/modules/oauth-clients/oauth-client.repository";
2627
import { OAuthClientUsersService } from "@/modules/oauth-clients/services/oauth-clients-users.service";
2728
import { OAuthFlowService } from "@/modules/oauth-clients/services/oauth-flow.service";
@@ -53,6 +54,7 @@ import { Module } from "@nestjs/common";
5354
StripeModule,
5455
TeamsModule,
5556
TeamsEventTypesModule,
57+
MembershipsModule,
5658
],
5759
providers: [
5860
TokensRepository,

apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ import { CalVideoService } from "@/ee/bookings/2024-08-13/services/cal-video.ser
1313
import { VERSION_2024_08_13_VALUE, VERSION_2024_08_13 } from "@/lib/api-versions";
1414
import { API_KEY_OR_ACCESS_TOKEN_HEADER } from "@/lib/docs/headers";
1515
import { PlatformPlan } from "@/modules/auth/decorators/billing/platform-plan.decorator";
16+
import {
17+
AuthOptionalUser,
18+
GetOptionalUser,
19+
} from "@/modules/auth/decorators/get-optional-user/get-optional-user.decorator";
1620
import { GetUser } from "@/modules/auth/decorators/get-user/get-user.decorator";
1721
import { Permissions } from "@/modules/auth/decorators/permissions/permissions.decorator";
18-
import { Roles } from "@/modules/auth/decorators/roles/roles.decorator";
1922
import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard";
23+
import { OptionalApiAuthGuard } from "@/modules/auth/guards/optional-api-auth/optional-api-auth.guard";
2024
import { PermissionsGuard } from "@/modules/auth/guards/permissions/permissions.guard";
2125
import { UsersService } from "@/modules/users/services/users.service";
2226
import { UserWithProfile } from "@/modules/users/users.repository";
@@ -96,6 +100,7 @@ export class BookingsController_2024_08_13 {
96100
) {}
97101

98102
@Post("/")
103+
@UseGuards(OptionalApiAuthGuard)
99104
@ApiOperation({
100105
summary: "Create a booking",
101106
description: `
@@ -138,9 +143,10 @@ export class BookingsController_2024_08_13 {
138143
async createBooking(
139144
@Body(new CreateBookingInputPipe())
140145
body: CreateBookingInput,
141-
@Req() request: Request
146+
@Req() request: Request,
147+
@GetOptionalUser() user: AuthOptionalUser
142148
): Promise<CreateBookingOutput_2024_08_13> {
143-
const booking = await this.bookingsService.createBooking(request, body);
149+
const booking = await this.bookingsService.createBooking(request, body, user);
144150

145151
if (Array.isArray(booking)) {
146152
await this.bookingsService.billBookings(booking);

apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/managed-user-bookings.e2e-spec.ts

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AppModule } from "@/app.module";
33
import { HttpExceptionFilter } from "@/filters/http-exception.filter";
44
import { PrismaExceptionFilter } from "@/filters/prisma-exception.filter";
55
import { Locales } from "@/lib/enums/locales";
6+
import { MembershipsModule } from "@/modules/memberships/memberships.module";
67
import {
78
CreateManagedUserData,
89
CreateManagedUserOutput,
@@ -80,7 +81,7 @@ describe("Managed user bookings 2024-08-13", () => {
8081
beforeAll(async () => {
8182
const moduleRef = await Test.createTestingModule({
8283
providers: [PrismaExceptionFilter, HttpExceptionFilter],
83-
imports: [AppModule, UsersModule],
84+
imports: [AppModule, UsersModule, MembershipsModule],
8485
}).compile();
8586

8687
app = moduleRef.createNestApplication();
@@ -772,6 +773,77 @@ describe("Managed user bookings 2024-08-13", () => {
772773
});
773774
});
774775

776+
describe("event type booking requires authentication", () => {
777+
let eventTypeRequiringAuthenticationId: number;
778+
779+
let body: CreateBookingInput_2024_08_13;
780+
781+
beforeAll(async () => {
782+
const eventTypeRequiringAuthentication = await eventTypesRepositoryFixture.create(
783+
{
784+
title: `event-type-requiring-authentication-${randomString()}`,
785+
slug: `event-type-requiring-authentication-${randomString()}`,
786+
length: 60,
787+
requiresConfirmation: true,
788+
bookingRequiresAuthentication: true,
789+
},
790+
secondManagedUser.user.id
791+
);
792+
eventTypeRequiringAuthenticationId = eventTypeRequiringAuthentication.id;
793+
794+
body = {
795+
start: new Date(Date.UTC(2030, 0, 9, 15, 0, 0)).toISOString(),
796+
eventTypeId: eventTypeRequiringAuthenticationId,
797+
attendee: {
798+
799+
name: "External Attendee",
800+
timeZone: "Europe/Rome",
801+
},
802+
};
803+
});
804+
805+
it("can't be booked without credentials", async () => {
806+
await request(app.getHttpServer())
807+
.post(`/v2/bookings`)
808+
.send(body)
809+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
810+
.expect(401);
811+
});
812+
813+
it("can't be booked with managed user credentials who is not admin and not event type owner", async () => {
814+
await request(app.getHttpServer())
815+
.post(`/v2/bookings`)
816+
.send(body)
817+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
818+
.set("Authorization", `Bearer ${firstManagedUser.accessToken}`)
819+
.expect(403);
820+
});
821+
822+
it("can be booked with managed user credentials who is event type owner", async () => {
823+
const response = await request(app.getHttpServer())
824+
.post(`/v2/bookings`)
825+
.send(body)
826+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
827+
.set("Authorization", `Bearer ${secondManagedUser.accessToken}`)
828+
.expect(201);
829+
830+
const bookingId = response.body.data.id;
831+
await bookingsRepositoryFixture.deleteById(bookingId);
832+
});
833+
834+
it("can be booked with managed user credentials who is admin", async () => {
835+
const response = await request(app.getHttpServer())
836+
.post(`/v2/bookings`)
837+
.send(body)
838+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
839+
.set("Authorization", `Bearer ${orgAdminManagedUser.accessToken}`)
840+
.expect(201);
841+
842+
const bookingId = response.body.data.id;
843+
await bookingsRepositoryFixture.deleteById(bookingId);
844+
});
845+
});
846+
775847
afterAll(async () => {
776848
await userRepositoryFixture.delete(firstManagedUser.user.id);
777849
await userRepositoryFixture.delete(secondManagedUser.user.id);

0 commit comments

Comments
 (0)