Skip to content

Commit

Permalink
#2 Поправил работу с ролями
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryGhost committed Dec 11, 2019
1 parent 23b9216 commit 887f146
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Idone/Idone.Tests/Helpers/IdoneApiHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ module IdoneApiHelper =
gridUser.Rows

let getRoles (links : PermRoleLink list) : Role list =
List.fold (fun acc link -> link.Role :: acc) [] links
List.map (fun link -> link.Role) links

let getPerms (links : PermRoleLink list) : Perm list =
List.fold (fun acc link -> link.Perm :: acc) [] links
List.map (fun link -> link.Perm) links

let fillGridQueryUser (searchName : string) : DtoGridQueryUser =
let filter = new DtoUserFilter(searchName)
Expand Down
4 changes: 3 additions & 1 deletion Idone/Idone.Tests/Helpers/IdoneApiWrapper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ type SecurityModuleWrapper(servicesProvider : ServiceProvider) =
})
|> reduceAllRights
|> Seq.fold (fun acc role -> role.Id :: acc) []
|> List.toSeq
|> List.toSeq

member __.SetPermissionsForRole()
9 changes: 7 additions & 2 deletions Idone/Idone.Tests/Sample.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,17 @@ module Tests =
//2. Назначить права для ролей
//3. Получить права ролей
//4. Получить роли из всех назначенных прав

let startRoles = PERMS_ROLES_LINKS |> getRoles
let startPerms = PERMS_ROLES_LINKS |> getPerms
let foundRoles : Either<Error, DtoGridRole> = either {
let! createdRoles =
let createdRoles =
startRoles |> _security.CreateRoles
Expect.isRight createdRoles "Не удалось создать роли"
Expect.isNonEmpty createdRoles "Не удалось создать роли"

let! createdPerms =
startPerms |> _security.CreatePermissions
Expect.isRight createdPerms "Не удалось создать права"

let! result =
_security.SetPermissionsForRole(PERMS_ROLES_LINKS)
Expand Down

0 comments on commit 887f146

Please sign in to comment.