playwright-security-scan 0.0.0 → 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ import { BrowserContext, APIRequestContext, TestType } from '@playwright/test';
2
+ export { VERSION } from './rules.cjs';
3
+
4
+ /** The `security` fixture (05, chapter 3). */
5
+ interface SecurityApi {
6
+ /** Scans a context created in the test, e.g. with browser.newContext() (05-REQ-02). */
7
+ track(context: BrowserContext): Promise<void>;
8
+ /** Scans the calls of an APIRequestContext from playwright.request.newContext() (15-REQ-01). */
9
+ trackRequestContext(requestContext: APIRequestContext): void;
10
+ }
11
+ interface SecurityFixtures {
12
+ security: SecurityApi;
13
+ }
14
+ /** `base` with the `security` fixture added; other fixtures keep their types. */
15
+ type SecurityTestType<T> = T extends TestType<infer TestArgs, infer WorkerArgs> ? TestType<TestArgs & SecurityFixtures, WorkerArgs> : never;
16
+ /**
17
+ * Adds the scan fixtures to `base` (05, chapter 3). Outside scan mode only `security` is added
18
+ * (05-REQ-01). Wrapping a test object this function returned gives it back unchanged. Never
19
+ * imports @playwright/test at runtime: it works with the `base` it gets.
20
+ */
21
+ declare function withSecurityFixtures<T extends TestType<any, any>>(base: T): SecurityTestType<T>;
22
+ /**
23
+ * Registers a worker-scoped browser context (05-REQ-02): every test of a scanned project scans it.
24
+ * Call it once, right after creating the context. Does nothing outside scan mode.
25
+ */
26
+ declare function trackContext(context: BrowserContext): Promise<void>;
27
+ /**
28
+ * Scans the calls of an APIRequestContext created with playwright.request.newContext(), also in a
29
+ * worker-scoped fixture (15-REQ-01): each call made during a test of a scanned project is analysed
30
+ * by that test. Does nothing outside scan mode or with scope.api off.
31
+ */
32
+ declare function trackRequestContext(requestContext: APIRequestContext): void;
33
+
34
+ export { trackContext, trackRequestContext, withSecurityFixtures };
35
+ export type { SecurityApi, SecurityFixtures, SecurityTestType };
@@ -0,0 +1,35 @@
1
+ import { BrowserContext, APIRequestContext, TestType } from '@playwright/test';
2
+ export { VERSION } from './rules.js';
3
+
4
+ /** The `security` fixture (05, chapter 3). */
5
+ interface SecurityApi {
6
+ /** Scans a context created in the test, e.g. with browser.newContext() (05-REQ-02). */
7
+ track(context: BrowserContext): Promise<void>;
8
+ /** Scans the calls of an APIRequestContext from playwright.request.newContext() (15-REQ-01). */
9
+ trackRequestContext(requestContext: APIRequestContext): void;
10
+ }
11
+ interface SecurityFixtures {
12
+ security: SecurityApi;
13
+ }
14
+ /** `base` with the `security` fixture added; other fixtures keep their types. */
15
+ type SecurityTestType<T> = T extends TestType<infer TestArgs, infer WorkerArgs> ? TestType<TestArgs & SecurityFixtures, WorkerArgs> : never;
16
+ /**
17
+ * Adds the scan fixtures to `base` (05, chapter 3). Outside scan mode only `security` is added
18
+ * (05-REQ-01). Wrapping a test object this function returned gives it back unchanged. Never
19
+ * imports @playwright/test at runtime: it works with the `base` it gets.
20
+ */
21
+ declare function withSecurityFixtures<T extends TestType<any, any>>(base: T): SecurityTestType<T>;
22
+ /**
23
+ * Registers a worker-scoped browser context (05-REQ-02): every test of a scanned project scans it.
24
+ * Call it once, right after creating the context. Does nothing outside scan mode.
25
+ */
26
+ declare function trackContext(context: BrowserContext): Promise<void>;
27
+ /**
28
+ * Scans the calls of an APIRequestContext created with playwright.request.newContext(), also in a
29
+ * worker-scoped fixture (15-REQ-01): each call made during a test of a scanned project is analysed
30
+ * by that test. Does nothing outside scan mode or with scope.api off.
31
+ */
32
+ declare function trackRequestContext(requestContext: APIRequestContext): void;
33
+
34
+ export { trackContext, trackRequestContext, withSecurityFixtures };
35
+ export type { SecurityApi, SecurityFixtures, SecurityTestType };