Example #1
0
        public void CanGetSessionsList()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                RemoteAppManagementClient client = GetRemoteAppManagementClient();

                CollectionSessionListResult sessionsResponse = client.Collections.ListSessions("testd112");
                RemoteAppSession            session          = null;

                Assert.NotNull(sessionsResponse);
                Assert.NotNull(sessionsResponse.Sessions);
                Assert.True(sessionsResponse.StatusCode == HttpStatusCode.OK);
                Assert.Empty(sessionsResponse.Sessions);

                // verify the serialization of the response with one item
                sessionsResponse = client.Collections.ListSessions("simple");
                Assert.NotNull(sessionsResponse);
                Assert.NotNull(sessionsResponse.Sessions);
                Assert.True(sessionsResponse.StatusCode == HttpStatusCode.OK);
                Assert.NotEmpty(sessionsResponse.Sessions);
                Assert.True(sessionsResponse.Sessions.Count == 1, "There must be only 1 session here.");

                session = sessionsResponse.Sessions[0];

                // these data are validated from the recorded json file
                Assert.NotNull(session);
                Assert.True(session.State == SessionState.Connected);
            }
        }
        public override void ExecuteCmdlet()
        {
            CollectionSessionListResult response = null;
            List <RemoteAppSession>     sessions = new List <RemoteAppSession>();

            if (!string.IsNullOrWhiteSpace(UserUpn))
            {
                CreateWildcardPattern(UserUpn);
            }

            response = CallClient(() => Client.Collections.ListSessions(CollectionName), Client.Collections);

            if (ExactMatch)
            {
                foreach (RemoteAppSession session in response.Sessions)
                {
                    if (string.Equals(session.UserUpn, UserUpn))
                    {
                        sessions.Add(session);
                        break;
                    }
                }

                if (sessions.Count == 0)
                {
                    WriteErrorWithTimestamp("No session found matching " + UserUpn);
                }
            }
            else
            {
                if (UseWildcard)
                {
                    foreach (RemoteAppSession session in response.Sessions)
                    {
                        if (Wildcard.IsMatch(session.UserUpn))
                        {
                            sessions.Add(session);
                        }
                    }
                }
                else
                {
                    sessions.AddRange(response.Sessions);
                }

                if (response.Sessions.Count == 0)
                {
                    WriteVerboseWithTimestamp("No sessions found in collection.");
                }
                else
                {
                    WriteObject(response.Sessions, true);
                }
            }
        }
Example #3
0
        public void CanSendMessageToASessionInACollection()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                RemoteAppManagementClient client = GetRemoteAppManagementClient();

                SessionSendMessageCommandParameter parameter = new SessionSendMessageCommandParameter
                {
                    UserUpn = "*****@*****.**",
                    Message = "Hello there!"
                };

                // testing the web fault
                OperationResultWithTrackingId response = null;

                response = client.Collections.SendMessageToSession("simple", parameter);


                Assert.NotNull(response);
                Assert.NotNull(response.TrackingId);
                Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);

                AssertLongrunningOperation(client, RemoteAppOperationStatus.Success, response.TrackingId);

                CollectionSessionListResult sessionList = client.Collections.ListSessions("simple");

                Assert.NotNull(sessionList);
                Assert.NotNull(sessionList.Sessions);
                Assert.True(sessionList.StatusCode == HttpStatusCode.OK);
                Assert.NotEmpty(sessionList.Sessions);

                RemoteAppSession session = null;

                foreach (var s in sessionList.Sessions)
                {
                    if (s.UserUpn == parameter.UserUpn)
                    {
                        session = s;
                        break;
                    }
                }

                Assert.NotNull(session);
                Assert.True(session.State == SessionState.Connected);
            }
        }
Example #4
0
        public void CanLogOffASessionFromACollection()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                RemoteAppManagementClient client = GetRemoteAppManagementClient();

                SessionCommandParameter parameter = new SessionCommandParameter
                {
                    UserUpn = "*****@*****.**"
                };

                // testing the web fault
                OperationResultWithTrackingId response = null;

                response = client.Collections.LogoffSession("simple", parameter);

                Assert.NotNull(response);
                Assert.NotNull(response.TrackingId);
                Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);

                AssertLongrunningOperation(client, RemoteAppOperationStatus.Success, response.TrackingId);

                TestUtilities.Wait(20000); //wait a little bit

                CollectionSessionListResult sessionList = client.Collections.ListSessions("simple");

                Assert.NotNull(sessionList);
                Assert.NotNull(sessionList.Sessions);
                Assert.True(sessionList.StatusCode == HttpStatusCode.OK);

                RemoteAppSession session = null;

                foreach (var s in sessionList.Sessions)
                {
                    if (s.UserUpn == parameter.UserUpn)
                    {
                        session = s;
                        break;
                    }
                }

                Assert.Null(session);
            }
        }