-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div> | ||
<NuxtPage /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default defineNuxtConfig({ | ||
modules: [ | ||
'../../../src/module' | ||
], | ||
security: { | ||
rateLimiter: { | ||
tokensPerInterval: 3, | ||
interval: 1000000, | ||
driver: { | ||
name: 'fsLite', | ||
options: { | ||
base: './test/fixtures/storageOptions/.nuxt/test/.data/db' | ||
} | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"private": true, | ||
"name": "basic", | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<div>basic</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import { fileURLToPath } from 'node:url' | ||
import { rm } from 'node:fs/promises' | ||
import { setup, fetch } from '@nuxt/test-utils' | ||
|
||
describe('[nuxt-security] Storage options', async () => { | ||
await setup({ | ||
rootDir: fileURLToPath(new URL('./fixtures/storageOptions', import.meta.url)), | ||
}) | ||
|
||
const dbPath = './test/fixtures/storageOptions/.nuxt/test/.data/db' | ||
await rm(dbPath, { recursive: true, force: true }) | ||
|
||
it('should pass options to a custom driver', async () => { | ||
const res1 = await fetch('/') | ||
const res2 = await fetch('/') | ||
|
||
expect(res1).toBeDefined() | ||
expect(res1).toBeTruthy() | ||
expect(res2.status).toBe(200) | ||
expect(res2.statusText).toBe('OK') | ||
}) | ||
|
||
it('should return 429 with the custom driver', async () => { | ||
const res1 = await fetch('/') | ||
await fetch('/') | ||
await fetch('/') | ||
await fetch('/') | ||
const res5 = await fetch('/') | ||
|
||
expect(res1).toBeDefined() | ||
expect(res1).toBeTruthy() | ||
expect(res5.status).toBe(429) | ||
expect(res5.statusText).toBe('Too Many Requests') | ||
}) | ||
}) |