-
Notifications
You must be signed in to change notification settings - Fork 157
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
1 parent
22f6ca1
commit 65da4b1
Showing
17 changed files
with
426 additions
and
74 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
tests/e2e/cucumber/features/integrations/reshare.ocis.feature
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,54 @@ | ||
Feature: reshare | ||
|
||
Background: | ||
Given "Admin" disables share auto accepting | ||
|
||
Scenario: re-sharing | ||
Given "Admin" creates following users | ||
| id | | ||
| Alice | | ||
| Brian | | ||
| Carol | | ||
And "Admin" creates following group | ||
| id | | ||
| sales | | ||
| finance | | ||
And "Admin" adds user to the group | ||
| user | group | | ||
| Carol | sales | | ||
|
||
And "Alice" logs in | ||
And "Alice" opens the "files" app | ||
And "Alice" navigates to the personal space page | ||
And "Alice" creates the following resources | ||
| resource | type | | ||
| folder_to_shared | folder | | ||
When "Alice" shares the following resource using the sidebar panel | ||
| resource | user | role | | ||
| folder_to_shared | Brian | editor | | ||
And "Alice" logs out | ||
|
||
And "Brian" logs in | ||
And "Brian" opens the "files" app | ||
And "Brian" navigates to the shared with me page | ||
And "Brian" accepts the following share | ||
| name | | ||
| folder_to_shared | | ||
And "Brian" reshares the following resource | ||
| resource | user | role | | ||
| folder_to_shared | Carol | viewer | | ||
And "Brian" logs out | ||
|
||
And "Carol" logs in | ||
And "Carol" opens the "files" app | ||
And "Carol" navigates to the shared with me page | ||
And "Carol" accepts the following share | ||
| name | | ||
| folder_to_shared | | ||
And "Carol" reshares the following resource | ||
| resource | user | role | | ||
| folder_to_shared | Alice | viewer | | ||
And "Carol" logs out | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1 +1,8 @@ | ||
export { me, createUser, deleteUser } from './user' | ||
export { | ||
me, | ||
createUser, | ||
deleteUser, | ||
createGroup, | ||
deleteGroup, | ||
addUserToGroup | ||
} from './userManagement' |
This file was deleted.
Oops, something went wrong.
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,131 @@ | ||
import { checkResponseStatus, request } from '../http' | ||
import { Group, Me, User } from '../../types' | ||
import join from 'join-path' | ||
import { config } from '../../../config' | ||
|
||
export const me = async ({ user }: { user: User }): Promise<Me> => { | ||
const response = await request({ | ||
method: 'GET', | ||
path: join('graph', 'v1.0', 'me'), | ||
user | ||
}) | ||
|
||
return await response.json() | ||
} | ||
|
||
export const createUser = async ({ user, admin }: { user: User; admin: User }): Promise<User> => { | ||
const body = JSON.stringify({ | ||
displayName: user.displayName, | ||
mail: user.email, | ||
onPremisesSamAccountName: user.id, | ||
passwordProfile: { password: user.password } | ||
}) | ||
|
||
const response = await request({ | ||
method: 'POST', | ||
path: join('graph', 'v1.0', 'users'), | ||
body, | ||
user: admin | ||
}) | ||
|
||
checkResponseStatus(response, 'Failed while creating user') | ||
return user | ||
} | ||
|
||
export const deleteUser = async ({ user, admin }: { user: User; admin: User }): Promise<User> => { | ||
await request({ | ||
method: 'DELETE', | ||
path: join('graph', 'v1.0', 'users', user.id), | ||
user: admin | ||
}) | ||
|
||
return user | ||
} | ||
|
||
const getUserId = async ({ user, admin }: { user: User; admin: User }): Promise<string> => { | ||
let userId = '' | ||
const response = await request({ | ||
method: 'GET', | ||
path: join('graph', 'v1.0', 'users', user.id), | ||
user: admin | ||
}) | ||
if (response.ok) { | ||
userId = (await response.json()).id | ||
} | ||
return userId | ||
} | ||
|
||
export const createGroup = async ({ | ||
group, | ||
admin | ||
}: { | ||
group: Group | ||
admin: User | ||
}): Promise<Group> => { | ||
const body = JSON.stringify({ | ||
displayName: group.displayName | ||
}) | ||
|
||
const response = await request({ | ||
method: 'POST', | ||
path: join('graph', 'v1.0', 'groups'), | ||
body, | ||
user: admin | ||
}) | ||
|
||
checkResponseStatus(response, 'Failed while creating group') | ||
return group | ||
} | ||
|
||
const getGroupId = async ({ group, admin }: { group: Group; admin: User }): Promise<string> => { | ||
let groupId = '' | ||
const response = await request({ | ||
method: 'GET', | ||
path: join('graph', 'v1.0', 'groups', group.displayName), | ||
user: admin | ||
}) | ||
if (response.ok) { | ||
groupId = (await response.json()).id | ||
} | ||
return groupId | ||
} | ||
|
||
export const deleteGroup = async ({ | ||
group, | ||
admin | ||
}: { | ||
group: Group | ||
admin: User | ||
}): Promise<Group> => { | ||
const groupId = await getGroupId({ group, admin }) | ||
await request({ | ||
method: 'DELETE', | ||
path: join('graph', 'v1.0', 'groups', groupId), | ||
user: admin | ||
}) | ||
return group | ||
} | ||
|
||
export const addUserToGroup = async ({ | ||
user, | ||
group, | ||
admin | ||
}: { | ||
user: User | ||
group: Group | ||
admin: User | ||
}): Promise<void> => { | ||
const groupId = await getGroupId({ group, admin }) | ||
const userId = await getUserId({ user, admin }) | ||
const body = JSON.stringify({ | ||
'@odata.id': join(config.backendUrl, 'graph', 'v1.0', 'users', userId) | ||
}) | ||
|
||
const response = await request({ | ||
method: 'POST', | ||
path: join('graph', 'v1.0', 'groups', groupId, 'members', '$ref'), | ||
body: body, | ||
user: admin | ||
}) | ||
checkResponseStatus(response, 'Failed while adding an user to the group') | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * as http from './http' | ||
export * as user from './user' | ||
export * as user from './userManagement' | ||
export * as config from './config' | ||
export * as settings from './settings' | ||
export * as graph from './graph' |
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
Oops, something went wrong.