Skip to content
Open
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
8 changes: 4 additions & 4 deletions src/api.authz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('API authz tests', () => {
jest.spyOn(otomiStack, 'editUser').mockResolvedValue(mockUser as any)

await agent
.put('/v1/users/user1')
.put('/v1/users/6383AB9D-3C42-4650-B8D8-4E58D0E97FEE')
.send({ ...userData })
.set('Authorization', `Bearer ${platformAdminToken}`)
.expect(200)
Expand All @@ -259,8 +259,8 @@ describe('API authz tests', () => {
jest.spyOn(otomiStack, 'deleteUser').mockResolvedValue({} as any)

await agent
.delete('/v1/users/user1')
.send({ id: 'user1' })
.delete('/v1/users/6383AB9D-3C42-4650-B8D8-4E58D0E97FEE')
.send({ id: '6383AB9D-3C42-4650-B8D8-4E58D0E97FEE' })
.set('Authorization', `Bearer ${platformAdminToken}`)
.expect(200)
})
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('API authz tests', () => {
test('team admin cannot delete users', async () => {
await agent
.delete('/v1/users/user1')
.send({ id: 'user1' })
.send({ id: 'A4E3926E-19AA-464D-B631-02B85609E91F' })
.set('Authorization', `Bearer ${teamAdminToken}`)
.expect(403)
})
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2146,7 +2146,7 @@ components:
description: ID of the user
required: true
schema:
$ref: 'definitions.yaml#/idName'
$ref: 'definitions.yaml#/uuid'
catalogParams:
name: catalogId
in: path
Expand Down
5 changes: 5 additions & 0 deletions src/openapi/definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@ idName:
type: string
x-message: a valid name that consists of lowercase letters, dashes
example: team-name
uuid:
pattern: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
type: string
x-message: a valid UUID
example: 8dd15e48-e30e-4788-9709-724f8ba625c7
settingsName:
pattern: '^[a-z](?:[-a-zA-Z0-9]{0,61}[a-zA-Z0-9])?$'
maxLength: 63
Expand Down
23 changes: 23 additions & 0 deletions src/patterns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ const redosCases: Record<string, string[]> = {

url: [`https://${'a.'.repeat(50_000)}!`, `https://example.com/${'a/'.repeat(50_000)}!`],

uuid: [`${'0'.repeat(100_000)}!`, `${'0-'.repeat(50_000)}!`],

wildcardDomainOrIp: [`${'a.'.repeat(50_000)}!`, `${'a:'.repeat(50_000)}!`],

imageRegistry: [`${'a.'.repeat(50_000)}!`, `${'a/'.repeat(50_000)}!`],
Expand Down Expand Up @@ -387,6 +389,27 @@ describe('OpenAPI definition regex patterns', () => {
})
})

describe('uuid', () => {
it('accepts valid UUIDs', () => {
expectValid('uuid', [
'8dd15e48-e30e-4788-9709-724f8ba625c7',
'00000000-0000-0000-0000-000000000000',
'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF',
])
})

it('rejects malformed UUIDs', () => {
expectInvalid('uuid', [
'',
'8dd15e48e30e47889709724f8ba625c7',
'8dd15e48-e30e-4788-9709-724f8ba625c',
'8dd15e48-e30e-4788-9709-724f8ba625c77',
'zdd15e48-e30e-4788-9709-724f8ba625c7',
'8dd15e48_e30e_4788_9709_724f8ba625c7',
])
})
})

describe('wildcardDomainOrIp', () => {
it('accepts supported domains and approximate IPv6 values', () => {
expectValid('wildcardDomainOrIp', ['example.com', '*.example.com', '2001:db8:0:0:0:0:0:1'])
Expand Down
Loading