mirror of
https://github.com/zen-browser/rices.git
synced 2025-07-07 17:05:40 +02:00
- Changed create and update method. Headers+body instead of DTO
- Added token validation for `update` and `remove` operations to ensure it matches the record in the database. - Ensured `name` and `author` from headers in `update` are validated against the existing record. - Improved error handling for mismatched or missing tokens, returning appropriate HTTP status codes.
This commit is contained in:
parent
c8ce6e7637
commit
121ccadf57
8 changed files with 328 additions and 151 deletions
|
@ -87,7 +87,7 @@ describe('Rices API E2E', () => {
|
|||
|
||||
const updateResponse = await request(app.getHttpServer())
|
||||
.put(`/rices/${slug}`)
|
||||
.set('x-rices-token', token)
|
||||
.set('x-zen-rices-token', token)
|
||||
.field('name', 'Updated Rice')
|
||||
.attach('file', path.join(__dirname, 'files', 'example_update.zenrice'))
|
||||
.expect(200);
|
||||
|
@ -116,7 +116,7 @@ describe('Rices API E2E', () => {
|
|||
|
||||
await request(app.getHttpServer())
|
||||
.delete(`/rices/${slug}`)
|
||||
.set('x-rices-token', token)
|
||||
.set('x-zen-rices-token', token)
|
||||
.expect(204);
|
||||
|
||||
const riceInDatabase = await supabaseService.getRiceBySlug(slug);
|
||||
|
|
|
@ -1,19 +1,74 @@
|
|||
@baseUrl = http://localhost:3000
|
||||
|
||||
# {
|
||||
# "key": "value",
|
||||
# "description": "Example content"
|
||||
# }
|
||||
|
||||
# {'key':'value','description':'Example content'}
|
||||
|
||||
POST {{baseUrl}}/rices
|
||||
Content-Type: application/json
|
||||
X-Zen-Rice-Name: cool-zenrice-aurora
|
||||
X-Zen-Rice-Author: jhon@doe.com
|
||||
User-Agent: ZenBrowser/1.0.0 (EndeavourOS x86_64)
|
||||
|
||||
{
|
||||
"name": "cool-zenrice-aurora2",
|
||||
"version": "1.0.0",
|
||||
"os": "EndeavourOS x86_64",
|
||||
"content": "{'key':'value','description':'Example content'}"
|
||||
}
|
||||
|
||||
"userChrome": "",
|
||||
"userContent": null,
|
||||
"enabledMods": [
|
||||
"5bb07b6e-c89f-4f4a-a0ed-e483cc535594"
|
||||
],
|
||||
"preferences": {
|
||||
"theme.custom_menubutton.default": "Firefox",
|
||||
"theme.custom_menubutton.custom": "url(chrome://branding/content/icon32.png)",
|
||||
"zen.view.use-single-toolbar": true,
|
||||
"zen.view.sidebar-expanded": true,
|
||||
"zen.tabs.vertical.right-side": false,
|
||||
"zen.view.experimental-no-window-controls": false,
|
||||
"zen.view.hide-window-controls": true,
|
||||
"browser.uiCustomization.state": "{\"placements\":{\"widget-overflow-fixed-list\":[],\"unified-extensions-area\":[\"ublock0_raymondhill_net-browser-action\",\"addon_darkreader_org-browser-action\",\"_7a7a4a92-a2a0-41d1-9fd7-1e92480d612d_-browser-action\",\"cookieautodelete_kennydo_com-browser-action\",\"tab-unloader-we_afnankhan-browser-action\"],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"customizableui-special-spring1\",\"urlbar-container\",\"customizableui-special-spring2\",\"wrapper-sidebar-button\",\"unified-extensions-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"TabsToolbar\":[\"tabbrowser-tabs\"],\"vertical-tabs\":[],\"PersonalToolbar\":[\"personal-bookmarks\"],\"zen-sidebar-top-buttons\":[\"zen-sidepanel-button\"],\"zen-sidebar-icons-wrapper\":[\"zen-profile-button\",\"zen-workspaces-button\",\"downloads-button\"]},\"seen\":[\"_7a7a4a92-a2a0-41d1-9fd7-1e92480d612d_-browser-action\",\"developer-button\",\"cookieautodelete_kennydo_com-browser-action\",\"tab-unloader-we_afnankhan-browser-action\",\"addon_darkreader_org-browser-action\",\"ublock0_raymondhill_net-browser-action\"],\"dirtyAreaCache\":[\"unified-extensions-area\",\"nav-bar\",\"toolbar-menubar\",\"TabsToolbar\",\"vertical-tabs\",\"PersonalToolbar\",\"zen-sidebar-top-buttons\",\"zen-sidebar-icons-wrapper\"],\"currentVersion\":20,\"newElementCount\":2}"
|
||||
},
|
||||
"workspaceThemes": [
|
||||
{
|
||||
"type": "gradient",
|
||||
"gradientColors": [
|
||||
{
|
||||
"c": [
|
||||
124,
|
||||
133,
|
||||
255
|
||||
],
|
||||
"isCustom": false
|
||||
},
|
||||
{
|
||||
"c": [
|
||||
69,
|
||||
255,
|
||||
86
|
||||
],
|
||||
"isCustom": false
|
||||
}
|
||||
],
|
||||
"opacity": 0.5,
|
||||
"rotation": 45,
|
||||
"texture": 0
|
||||
},
|
||||
{
|
||||
"type": "gradient",
|
||||
"gradientColors": [
|
||||
{
|
||||
"c": [
|
||||
255,
|
||||
133,
|
||||
65
|
||||
],
|
||||
"isCustom": false
|
||||
}
|
||||
],
|
||||
"opacity": 0.6,
|
||||
"rotation": 45,
|
||||
"texture": null
|
||||
},
|
||||
{
|
||||
"type": "gradient",
|
||||
"gradientColors": [],
|
||||
"opacity": 0.5,
|
||||
"rotation": 45,
|
||||
"texture": null
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
@baseUrl = http://localhost:3000
|
||||
@previous_slug = cool-zenrice-aurora-e99096ae-00da-4d54-9a47-53b20eb57647
|
||||
@previous_slug = cool-zenrice-aurora-249dd7f2-d669-4d1f-892c-df4caa6fcbfe
|
||||
|
||||
|
||||
GET {{baseUrl}}/rices/{{previous_slug}}
|
|
@ -1,19 +1,78 @@
|
|||
@baseUrl = http://localhost:3000
|
||||
@previous_slug = cool-zenrice-aurora-ef732cbc-fdde-4f76-b4e3-cff0ec8b6f39
|
||||
@previous_token = b406f962-5c51-43a9-8382-40e0983a46e7
|
||||
|
||||
# {
|
||||
# "key": "value",
|
||||
# "description": "Example updated content"
|
||||
# }
|
||||
|
||||
# {'key':'value','description':'Example updated content'}
|
||||
@previous_slug = cool-zenrice-aurora-249dd7f2-d669-4d1f-892c-df4caa6fcbfe
|
||||
@previous_token = 528bb297-274f-4fe1-87f1-956b9b26e0df
|
||||
|
||||
PUT {{baseUrl}}/rices/{{previous_slug}}
|
||||
Content-Type: application/json
|
||||
x-rices-token: {{previous_token}}
|
||||
x-zen-rices-token: {{previous_token}}
|
||||
X-Zen-Rice-Name: cool-zenrice-aurora
|
||||
X-Zen-Rice-Author: jhon@doe.com
|
||||
User-Agent: ZenBrowser/1.0.0 (EndeavourOS x86_64)
|
||||
|
||||
{
|
||||
"content": "{'key':'value','description':'Example updated content'}"
|
||||
}
|
||||
|
||||
"userChrome": "",
|
||||
"userContent": null,
|
||||
"enabledMods": [
|
||||
"5bb07b6e-c89f-4f4a-a0ed-e483cc535594",
|
||||
"5bb07b6e-c89f-4f4a-a0ed-e483cc535594"
|
||||
],
|
||||
"preferences": {
|
||||
"theme.custom_menubutton.default": "Firefox",
|
||||
"theme.custom_menubutton.custom": "url(chrome://branding/content/icon32.png)",
|
||||
"zen.view.use-single-toolbar": true,
|
||||
"zen.view.sidebar-expanded": true,
|
||||
"zen.tabs.vertical.right-side": false,
|
||||
"zen.view.experimental-no-window-controls": false,
|
||||
"zen.view.hide-window-controls": true,
|
||||
"browser.uiCustomization.state": "{\"placements\":{\"widget-overflow-fixed-list\":[],\"unified-extensions-area\":[\"ublock0_raymondhill_net-browser-action\",\"addon_darkreader_org-browser-action\",\"_7a7a4a92-a2a0-41d1-9fd7-1e92480d612d_-browser-action\",\"cookieautodelete_kennydo_com-browser-action\",\"tab-unloader-we_afnankhan-browser-action\"],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"customizableui-special-spring1\",\"urlbar-container\",\"customizableui-special-spring2\",\"wrapper-sidebar-button\",\"unified-extensions-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"TabsToolbar\":[\"tabbrowser-tabs\"],\"vertical-tabs\":[],\"PersonalToolbar\":[\"personal-bookmarks\"],\"zen-sidebar-top-buttons\":[\"zen-sidepanel-button\"],\"zen-sidebar-icons-wrapper\":[\"zen-profile-button\",\"zen-workspaces-button\",\"downloads-button\"]},\"seen\":[\"_7a7a4a92-a2a0-41d1-9fd7-1e92480d612d_-browser-action\",\"developer-button\",\"cookieautodelete_kennydo_com-browser-action\",\"tab-unloader-we_afnankhan-browser-action\",\"addon_darkreader_org-browser-action\",\"ublock0_raymondhill_net-browser-action\"],\"dirtyAreaCache\":[\"unified-extensions-area\",\"nav-bar\",\"toolbar-menubar\",\"TabsToolbar\",\"vertical-tabs\",\"PersonalToolbar\",\"zen-sidebar-top-buttons\",\"zen-sidebar-icons-wrapper\"],\"currentVersion\":20,\"newElementCount\":2}"
|
||||
},
|
||||
"workspaceThemes": [
|
||||
{
|
||||
"type": "gradient",
|
||||
"gradientColors": [
|
||||
{
|
||||
"c": [
|
||||
124,
|
||||
133,
|
||||
255
|
||||
],
|
||||
"isCustom": false
|
||||
},
|
||||
{
|
||||
"c": [
|
||||
69,
|
||||
255,
|
||||
86
|
||||
],
|
||||
"isCustom": false
|
||||
}
|
||||
],
|
||||
"opacity": 0.5,
|
||||
"rotation": 45,
|
||||
"texture": 0
|
||||
},
|
||||
{
|
||||
"type": "gradient",
|
||||
"gradientColors": [
|
||||
{
|
||||
"c": [
|
||||
255,
|
||||
133,
|
||||
65
|
||||
],
|
||||
"isCustom": false
|
||||
}
|
||||
],
|
||||
"opacity": 0.6,
|
||||
"rotation": 45,
|
||||
"texture": null
|
||||
},
|
||||
{
|
||||
"type": "gradient",
|
||||
"gradientColors": [],
|
||||
"opacity": 0.5,
|
||||
"rotation": 45,
|
||||
"texture": null
|
||||
}
|
||||
]
|
||||
}
|
|
@ -3,4 +3,4 @@
|
|||
@previous_token = 03fbfdb4-d3a5-4d64-8740-feac7d32e7a8
|
||||
|
||||
DELETE {{baseUrl}}/rices/{{previous_slug}}
|
||||
x-rices-token: {{previous_token}}
|
||||
x-zen-rices-token: {{previous_token}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue