Skip to content

Commit 36dc33c

Browse files
authored
Merge pull request #7387 from LibreSign/backport/7384/stable32
[stable32] fix: interpolate sign-request uuid into account create URL
2 parents 789f547 + dd828a4 commit 36dc33c

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/tests/views/CreateAccount.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { shallowMount } from '@vue/test-utils'
88
import type { VueWrapper } from '@vue/test-utils'
99
import CreateAccount from '../../views/CreateAccount.vue'
1010
import md5 from 'blueimp-md5'
11+
import axios from '@nextcloud/axios'
12+
import { generateOcsUrl } from '@nextcloud/router'
1113

1214
type ValidationField = {
1315
$model: string
@@ -82,8 +84,12 @@ describe('CreateAccount.vue - Business Logic', () => {
8284
}
8385

8486
let wrapper!: CreateAccountWrapper
87+
const axiosPostMock = vi.mocked(axios.post)
88+
const generateOcsUrlMock = vi.mocked(generateOcsUrl)
8589

8690
beforeEach(() => {
91+
axiosPostMock.mockReset()
92+
generateOcsUrlMock.mockClear()
8793
wrapper = shallowMount(CreateAccount, {
8894
global: {
8995
mocks: {
@@ -486,5 +492,35 @@ describe('CreateAccount.vue - Business Logic', () => {
486492

487493
expect(wrapper.vm.canSave).toBe(false)
488494
})
495+
496+
it('posts create-account request with interpolated sign request uuid', async () => {
497+
axiosPostMock.mockRejectedValue({
498+
response: {
499+
data: {
500+
ocs: {
501+
data: {
502+
message: 'Invalid UUID',
503+
},
504+
},
505+
},
506+
},
507+
})
508+
509+
await wrapper.setData({
510+
email: 'test@example.com',
511+
password: 'validPassword123',
512+
passwordConfirm: 'validPassword123',
513+
})
514+
515+
await wrapper.vm.createAccount()
516+
517+
expect(generateOcsUrlMock).toHaveBeenCalledWith('/apps/libresign/api/v1/account/create/{uuid}', {
518+
uuid: 'test-uuid',
519+
})
520+
expect(axiosPostMock).toHaveBeenCalledWith('/apps/libresign/api/v1/account/create/{uuid}', {
521+
email: 'test@example.com',
522+
password: 'validPassword123',
523+
})
524+
})
489525
})
490526
})

src/views/CreateAccount.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,9 @@ onBeforeMount(() => {
241241
async function createAccount() {
242242
state.loading = true
243243
try {
244-
await axios.post(generateOcsUrl('/apps/libresign/api/v1/account/create/{uuid}'), {
244+
await axios.post(generateOcsUrl('/apps/libresign/api/v1/account/create/{uuid}', {
245245
uuid: route.value.params.uuid ?? '',
246+
}), {
246247
email: state.email,
247248
password: state.password,
248249
})

0 commit comments

Comments
 (0)