-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests-only] e2eTest. Api step. create folder in personal space (#8176)
* create folder in personal space
- Loading branch information
1 parent
a4e9e53
commit 207fa58
Showing
8 changed files
with
87 additions
and
18 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
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 @@ | ||
export { createFolder } from './spaces' |
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,39 @@ | ||
import { checkResponseStatus, request } from '../http' | ||
import { User } from '../../types' | ||
import join from 'join-path' | ||
import { getPersonalSpaceId } from '../graph' | ||
import { config } from '../../../config' | ||
|
||
export const createFolder = async ({ | ||
user, | ||
folder | ||
}: { | ||
user: User | ||
folder: string | ||
}): Promise<void> => { | ||
const paths = folder.split('/') | ||
|
||
let subFolder = '' | ||
for (const resource of paths) { | ||
const oc10Path = join('remote.php', 'dav', 'files', user.id, subFolder, resource) | ||
|
||
const response = await request({ | ||
method: 'MKCOL', | ||
path: config.ocis | ||
? join( | ||
'remote.php', | ||
'dav', | ||
'spaces', | ||
await getPersonalSpaceId({ user }), | ||
subFolder, | ||
resource | ||
) | ||
: oc10Path, | ||
user: user, | ||
formatJson: false | ||
}) | ||
|
||
checkResponseStatus(response, 'Failed while creating folder') | ||
subFolder += resource | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ export { | |
deleteGroup, | ||
addUserToGroup | ||
} from './userManagement' | ||
export { getPersonalSpaceId } from './spaces' |
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 @@ | ||
import { checkResponseStatus, request } from '../http' | ||
import { User } from '../../types' | ||
import join from 'join-path' | ||
|
||
export const getPersonalSpaceId = async ({ user }: { user: User }): Promise<string> => { | ||
const response = await request({ | ||
method: 'GET', | ||
path: join('graph', 'v1.0', 'me', 'drives', "?$filter=driveType eq 'personal'"), | ||
user: user, | ||
formatJson: false | ||
}) | ||
|
||
checkResponseStatus(response, 'Failed while geting personal space') | ||
|
||
const result = await response.json() | ||
return result.value[0].id | ||
} |
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