Exemple #1
0
        public async Task TestAssignAndUnassignGroup()
        {
            var groupNew = new GroupNew().SetDefaults();

            groupNew.Name        = "api.test.group." + new Guid().ToString();
            groupNew.Description = "This is a test group for the API tests.";

            var createGroupRequest  = new CreateGroupRequest(groupNew);
            var createGroupResponse = await SkyManager.ApiClient.ExecuteRequestAsync(createGroupRequest);

            var groupId = createGroupResponse.Content.Id;

            await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Authentication.V1.GroupsRequests.AssignUserGroupRequest(TestUserId, groupId));

            var group = await SkyManager.ApiClient.ExecuteRequestAsync(new GetGroupRequest(groupId));

            Assert.Single(group.Content.Members.FindAll(m => { return(m.Id.Equals(TestUserId)); }));
            await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Authentication.V1.GroupsRequests.UnassignUserGroupRequest(TestUserId, groupId));


            await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Authentication.V1.UsersRequests.AssignUserGroupRequest(TestUserId, groupId));

            var userGroups = await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Authentication.V1.UsersRequests.GetUserGroupsRequest(TestUserId));

            Assert.Single(userGroups.Content);
            userGroups = await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Authentication.V1.GroupsRequests.GetUserGroupsRequest(TestUserId));

            Assert.Single(userGroups.Content);
            await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Authentication.V1.UsersRequests.UnassignUserGroupRequest(TestUserId, groupId));

            var deleteGroupRequest = new DeleteGroupRequest(groupId);
            await SkyManager.ApiClient.ExecuteRequestAsync(deleteGroupRequest);
        }
Exemple #2
0
        public async Task TestUpdateGroup()
        {
            var groupNew = new GroupNew().SetDefaults();

            groupNew.Name        = "api.test.group." + new Guid().ToString();
            groupNew.Description = "This is a test group for the API tests.";

            var createGroupRequest  = new CreateGroupRequest(groupNew);
            var createGroupResponse = await SkyManager.ApiClient.ExecuteRequestAsync(createGroupRequest);

            var groupId = createGroupResponse.Content.Id;

            var groupUpdate = new GroupUpdate().SetDefaults();

            groupUpdate.Description = "Updated decsription";
            groupUpdate.Name        = "Update group name";
            Assert.NotNull(groupUpdate.ToJson());
            Assert.NotNull(groupUpdate.ToString());

            var updateGroupRequest  = new UpdateGroupRequest(groupUpdate, groupId);
            var updateGroupResponse = await SkyManager.ApiClient.ExecuteRequestAsync(updateGroupRequest);

            var deleteGroupRequest = new DeleteGroupRequest(groupId);
            await SkyManager.ApiClient.ExecuteRequestAsync(deleteGroupRequest);
        }
Exemple #3
0
    public void CreateGroup(string adminUsername, string password, string groupName)
    {
        var loginWithPlayFabRequest = new LoginWithPlayFabRequest {
            Username = adminUsername, Password = password
        };

        PlayFabClientAPI.LoginWithPlayFab(loginWithPlayFabRequest,
                                          delegate(LoginResult loginResult)
        {
            PlayFabAuthenticationAPI.GetEntityToken(new PlayFab.AuthenticationModels.GetEntityTokenRequest(),
                                                    delegate(GetEntityTokenResponse getEntityTokenResponse)
            {
                var createGroupRequest = new CreateGroupRequest {
                    GroupName = groupName,
                    Entity    = ConvertEntityKey(getEntityTokenResponse.Entity)
                };

                PlayFabGroupsAPI.CreateGroup(createGroupRequest,
                                             delegate(CreateGroupResponse response)
                {
                    Debug.Log("Group was successfully created: " + response.GroupName + " -  " + response.Group.Id);
                },
                                             SharedError.OnSharedError);
            },
                                                    SharedError.OnSharedError);
        },
                                          SharedError.OnSharedError);
    }
        private static async Task <StringContent> GenerateStringContent(CreateGroupRequest request, List <User> owners, List <User> members)
        {
            string mailNickName = await GetUniqueMailAlias(request);

            dynamic group = new ExpandoObject();

            group.displayName  = GetDisplayName(request);
            group.description  = request.Description;
            group.mailNickname = mailNickName;
            group.mailEnabled  = true;
            var resourceBehaviorOptions = new List <string>();

            if (request.WelcomeEmailDisabled)
            {
                resourceBehaviorOptions.Add("WelcomeEmailDisabled");
            }
            group.resourceBehaviorOptions = resourceBehaviorOptions.ToArray();
            group.securityEnabled         = false;
            group.visibility = request.Public ? "Public" : "Private";
            group.groupTypes = new[] { "Unified" };
            if (owners.Count > 0)
            {
                ((IDictionary <string, object>)group)["*****@*****.**"] = owners.Select(user => $"https://graph.microsoft.com/v1.0/users/{user.Id}").ToArray();
            }
            if (members.Count > 0)
            {
                ((IDictionary <string, object>)group)["*****@*****.**"] = members.Select(user => $"https://graph.microsoft.com/v1.0/users/{user.Id}").ToArray();
            }
            return(new StringContent(JsonConvert.SerializeObject(group), Encoding.UTF8, "application/json"));
        }
Exemple #5
0
        public async Task <IActionResult> Create([FromBody] CreateGroupRequest request)
        {
            var command = new CreateGroupCommand(request.Name, request.Code, request.CreatorId);
            var result  = await _mediator.Send(command);

            return(result != null?Ok(result) : BadRequest());
        }
Exemple #6
0
        internal virtual CreateGroupResponse CreateGroup(CreateGroupRequest request)
        {
            var marshaller   = CreateGroupRequestMarshaller.Instance;
            var unmarshaller = CreateGroupResponseUnmarshaller.Instance;

            return(Invoke <CreateGroupRequest, CreateGroupResponse>(request, marshaller, unmarshaller));
        }
        public async Task CreatedGroupCanBeUpdated()
        {
            string groupName = GetRandomGroupName();

            var createGroupRequest = new CreateGroupRequest(groupName, groupName)
            {
                Description          = "description1",
                Visibility           = GroupsVisibility.Public,
                LfsEnabled           = true,
                RequestAccessEnabled = true
            };

            var createGroupResponse = await _sut.CreateAsync(createGroupRequest);

            _groupIdsToClean.Add(createGroupResponse.Id);

            string updateGroupName = GetRandomGroupName();

            var updateRequest = new UpdateGroupRequest()
            {
                Name                 = updateGroupName,
                Description          = "description2",
                Visibility           = GroupsVisibility.Internal,
                LfsEnabled           = false,
                RequestAccessEnabled = false
            };

            var updateGroupResponse = await _sut.UpdateAsync(createGroupResponse.Id, updateRequest);

            updateGroupResponse.Name.Should().Be(updateGroupName);
            updateGroupResponse.Description.Should().Be("description2");
            updateGroupResponse.Visibility.Should().Be(GroupsVisibility.Internal);
            updateGroupResponse.LfsEnabled.Should().BeFalse();
            updateGroupResponse.RequestAccessEnabled.Should().BeFalse();
        }
        public async stt::Task CreateGroupResourceNames4Async()
        {
            moq::Mock <GroupService.GroupServiceClient> mockGrpcClient = new moq::Mock <GroupService.GroupServiceClient>(moq::MockBehavior.Strict);
            CreateGroupRequest request = new CreateGroupRequest
            {
                Group       = new Group(),
                ProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
            };
            Group expectedResponse = new Group
            {
                GroupName   = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"),
                DisplayName = "display_name137f65c2",
                ParentName  = "parent_name91315215",
                Filter      = "filtere47ac9b2",
                IsCluster   = true,
            };

            mockGrpcClient.Setup(x => x.CreateGroupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Group>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            GroupServiceClient client  = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            Group responseCallSettings = await client.CreateGroupAsync(request.ResourceName, request.Group, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Group responseCancellationToken = await client.CreateGroupAsync(request.ResourceName, request.Group, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>
        /// Creates a new group.
        /// </summary>
        public async Task <PlayFabResult <CreateGroupResponse> > CreateGroupAsync(CreateGroupRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if ((request?.AuthenticationContext?.EntityToken ?? authenticationContext.EntityToken) == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call GetEntityToken before calling this method");
            }

            var httpResult = await PlayFabHttp.DoPost("/Group/CreateGroup", request, "X-EntityToken", authenticationContext.EntityToken, extraHeaders, requestSettings);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <CreateGroupResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <CreateGroupResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <CreateGroupResponse> {
                Result = result, CustomData = customData
            });
        }
        public void CreateGroupRequestObject()
        {
            moq::Mock <GroupService.GroupServiceClient> mockGrpcClient = new moq::Mock <GroupService.GroupServiceClient>(moq::MockBehavior.Strict);
            CreateGroupRequest request = new CreateGroupRequest
            {
                Group        = new Group(),
                ValidateOnly = true,
                ProjectName  = gagr::ProjectName.FromProject("[PROJECT]"),
            };
            Group expectedResponse = new Group
            {
                GroupName   = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"),
                DisplayName = "display_name137f65c2",
                ParentName  = "parent_name91315215",
                Filter      = "filtere47ac9b2",
                IsCluster   = true,
            };

            mockGrpcClient.Setup(x => x.CreateGroup(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            Group response            = client.CreateGroup(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemple #11
0
        public static Task <Dialog> CreateMessageGroup(string groupName, IList <UserContact> users)
        {
            var usersIds    = users.Select(user => user.Id).ToList();
            var bodyRequest = new CreateGroupRequest(groupName, usersIds);

            return(chatApi.CreateGroupDialog(bodyRequest));
        }
        /// <summary>
        /// Creates a new group.
        /// </summary>
        public static void CreateGroup(CreateGroupRequest request, Action <CreateGroupResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;


            PlayFabHttp.MakeApiCall("/Group/CreateGroup", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context);
        }
Exemple #13
0
        public void CreateGroup()
        {
            Mock <GroupService.GroupServiceClient> mockGrpcClient = new Mock <GroupService.GroupServiceClient>(MockBehavior.Strict);
            CreateGroupRequest expectedRequest = new CreateGroupRequest
            {
                ProjectName = new ProjectName("[PROJECT]"),
                Group       = new Group(),
            };
            Group expectedResponse = new Group
            {
                GroupName             = new GroupName("[PROJECT]", "[GROUP]"),
                DisplayName           = "displayName1615086568",
                ParentNameAsGroupName = new GroupName("[PROJECT]", "[GROUP]"),
                Filter    = "filter-1274492040",
                IsCluster = false,
            };

            mockGrpcClient.Setup(x => x.CreateGroup(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            ProjectName        name   = new ProjectName("[PROJECT]");
            Group group    = new Group();
            Group response = client.CreateGroup(name, group);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        private static async Task SetGroupSettings(CreateGroupRequest request, CreateGroupResponse response, TraceWriter log)
        {
            GraphServiceClient client = ConnectADAL.GetGraphClient();

            try
            {
                if (!request.AllowToAddGuests)
                {
                    var groupUnifiedGuestSetting = new GroupSetting()
                    {
                        DisplayName = "Group.Unified.Guest",
                        TemplateId  = "08d542b9-071f-4e16-94b0-74abb372e3d9",
                        Values      = new List <SettingValue> {
                            new SettingValue()
                            {
                                Name = "AllowToAddGuests", Value = "false"
                            }
                        }
                    };
                    log.Info($"Setting setting in Group.Unified.Guest (08d542b9-071f-4e16-94b0-74abb372e3d9), AllowToAddGuests = false");
                    await client.Groups[response.GroupId].Settings.Request().AddAsync(groupUnifiedGuestSetting);
                }
            }
            catch (Exception e)
            {
                log.Error($"Error setting AllowToAddGuests for group {response.GroupId}: {e.Message }\n\n{e.StackTrace}");
            }
        }
Exemple #15
0
        public async Task CreateGroup(CreateGroupRequest request)
        {
            try
            {
                var result = await _chatService.CreateGroup(request.Name, request.Users);

                ChatResponse response = new ChatResponse();
                if (result.Success)
                {
                    var group = (GroupView)result.Data;
                    foreach (string user in group.Users)
                    {
                        await GroupUserConnection(group.Id, user, true);
                    }

                    response.Type = ChatResponseType.UpdateGroup;
                    response.Data = result.Data;
                    await SendResponseToGroup(group.Id, response);
                }
                else
                {
                    response.Type = ChatResponseType.SystemErrorMessage;
                    response.Data = result.Message;
                    await SendResponseToCaller(response);
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #16
0
        public void CreateNewGroup(CreateGroupRequest request, int issuerId)
        {
            var user = GetUserForId(issuerId);

            _groupCreator.CreateNewGroup(request, user.UserId);
            _groupAssignUserHandler.AssignUserToGroup(request.GroupName, user.UserId, issuerId);
        }
Exemple #17
0
        public async Task CreateNewGroupAsyncShould_CreateGroupChatIf3UserIdsAreProvided()
        {
            const string databaseName = nameof(CreateNewGroupAsyncShould_CreateGroupChatIf3UserIdsAreProvided);

            using (var arrangeContext = new WebChatContext(TestUtils.GetOptions(databaseName)))
            {
                await arrangeContext.Users.AddAsync(new User { Id = "1", UserName = "******" });

                await arrangeContext.Users.AddAsync(new User { Id = "2", UserName = "******" });

                await arrangeContext.Users.AddAsync(new User { Id = "3", UserName = "******" });

                await arrangeContext.SaveChangesAsync();
            }

            using (var actContext = new WebChatContext(TestUtils.GetOptions(databaseName)))
            {
                GroupService       sut          = new GroupService(actContext);
                CreateGroupRequest groupRequest = new CreateGroupRequest()
                {
                    Name    = "test",
                    UserIds = { "1", "2", "3" }
                };
                var result = await sut.CreateNewGroupAsync(groupRequest, "1");

                Assert.AreEqual("test", result.Name);
                Assert.AreEqual(false, result.IsPrivateChat);
                Assert.IsTrue(DateTime.UtcNow - result.LastActivityDate < TimeSpan.FromSeconds(2));
            };
        }
Exemple #18
0
        public async Task CreateGroupAsync2()
        {
            Mock <GroupService.GroupServiceClient> mockGrpcClient = new Mock <GroupService.GroupServiceClient>(MockBehavior.Strict);
            CreateGroupRequest request = new CreateGroupRequest
            {
                ProjectName = new ProjectName("[PROJECT]"),
                Group       = new Group(),
            };
            Group expectedResponse = new Group
            {
                GroupName             = new GroupName("[PROJECT]", "[GROUP]"),
                DisplayName           = "displayName1615086568",
                ParentNameAsGroupName = new GroupName("[PROJECT]", "[GROUP]"),
                Filter    = "filter-1274492040",
                IsCluster = false,
            };

            mockGrpcClient.Setup(x => x.CreateGroupAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Group>(Task.FromResult(expectedResponse), null, null, null, null));
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            Group response            = await client.CreateGroupAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemple #19
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateGroup operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateGroup operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/resource-groups-2017-11-27/CreateGroup">REST API Reference for CreateGroup Operation</seealso>
        public virtual Task <CreateGroupResponse> CreateGroupAsync(CreateGroupRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = CreateGroupRequestMarshaller.Instance;
            var unmarshaller = CreateGroupResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateGroupRequest, CreateGroupResponse>(request, marshaller,
                                                                         unmarshaller, cancellationToken));
        }
Exemple #20
0
 public ActionResult CreateGroup([FromBody] CreateGroupRequest request)
 {
     using (var client = GetMainServiceClient())
     {
         var group = client.CreateGroup(request.GroupName, request.GroupDescription);
         return(Json(group));
     }
 }
Exemple #21
0
        public GroupEntity CreateNewGroup(CreateGroupRequest request, int userId)
        {
            VerifyGroupNameAvailability(request.GroupName);

            var groupModel  = CreateGroupModel(request, userId);
            var groupEntity = MapModelToEntity(groupModel);

            return(Create(groupEntity));
        }
Exemple #22
0
        public async Task<ActionResult> Execute(string inep, CreateGroupRequest createGroupRequest)
        {
            if (createGroupRequest.Inep != inep)
                return BadRequest();

            await _createGroupUseCase.Execute(createGroupRequest);

            return NoContent();
        }
        public async Task <CreatedActionResult <GroupResponse> > PostCreateGroupAsync(
            [FromServices] NaheulbookExecutionContext executionContext,
            CreateGroupRequest request
            )
        {
            var group = await _groupService.CreateGroupAsync(executionContext, request);

            return(_mapper.Map <GroupResponse>(group));
        }
        public async Task <IActionResult> CreateGroup(
            [FromServices] ICreateGroupUseCase createGroupUseCase,
            [FromServices] CreateGroupPresenter createGroupPresenter,
            [FromBody] CreateGroupRequest input)
        {
            await createGroupUseCase.Execute(new CreateGroupInput(input.Title, input.Curator, input.HeadMan));

            return(createGroupPresenter.ViewModel);
        }
        public async Task <GroupResponse> AddGroup(CreateGroupRequest request)
        {
            var group = Mapper.Map <CreateGroupRequest, TasksManager.Entities.Group>(request);
            await Uow.Groups.AddAsync(group);

            await Uow.CommitAsync();

            return(Mapper.Map <TasksManager.Entities.Group, GroupResponse>(group));
        }
Exemple #26
0
        public void CreateGroup(string groupName, EntityKey entityKey)
        {
            // A player-controlled entity creates a new group
            var request = new CreateGroupRequest {
                GroupName = groupName, Entity = EntityKeyMaker(PlayFabManager.Instance.CurrentEntity.Id)
            };

            PlayFabGroupsAPI.CreateGroup(request, OnCreateGroup, OnSharedError);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateGroup operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateGroup operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public virtual Task <CreateGroupResponse> CreateGroupAsync(CreateGroupRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateGroupRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateGroupResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateGroupResponse>(request, options, cancellationToken));
        }
        internal virtual CreateGroupResponse CreateGroup(CreateGroupRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateGroupRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateGroupResponseUnmarshaller.Instance;

            return(Invoke <CreateGroupResponse>(request, options));
        }
Exemple #29
0
        public async Task <IActionResult> CreateGroupAsync([FromBody] CreateGroupRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var response = await _groupService.AddGroup(request);

            return(Created(Url.RouteUrl(new { response.Id }), response));
        }
        public async Task <ActionResult <GroupWithUsers> > Post(CreateGroupRequest createGroupRequest)
        {
            string currentUserId = HttpContext.User.Claims.FirstOrDefault(x => x.Type == JwtRegisteredClaimNames.Sub)?.Value;

            createGroupRequest.UserIds.Add(currentUserId);

            GroupWithUsers newGroup = await _groupService.CreateNewGroupAsync(createGroupRequest, currentUserId);

            return(newGroup);
        }
 public CommandResult<Group> CreateGroup(CreateGroupRequest createGroupRequest)
 {
     return _createGroupCommand.ExecuteRequest(createGroupRequest);
 }