Esempio n. 1
0
        public async Task Get_Event_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var events = await client.Event.GetAllAsync <EventStorage, Profile>();

            var @event = await client.Event.GetAsync <EventStorage, Profile>(events.List.First().Id);
        }
Esempio n. 2
0
        public async Task Create_User_Create_Event_Get_Events_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user        = Factory.GenerateCreateUser(Random);
            var createdUser = await client.User.CreateAsync(user);

            await client.Event.CreateAsync <EventStorage, Profile>(new CreateEvent <EventStorage> {
                UserId = createdUser.Id, Name = "Purchased Ticket 1", Details = new EventStorage {
                    TickedId = Guid.NewGuid()
                }
            });

            await client.Event.CreateAsync <EventStorage, Profile>(new CreateEvent <EventStorage> {
                UserId = createdUser.Id, Name = "Purchased Ticket 2", Details = new EventStorage {
                    TickedId = Guid.NewGuid()
                }
            });

            await client.Event.CreateAsync <EventStorage, Profile>(new CreateEvent <EventStorage> {
                UserId = createdUser.Id, Name = "Purchased Ticket 3", Details = new EventStorage {
                    TickedId = Guid.NewGuid()
                }
            });

            var events = await client.Event.GetAllAsync <EventStorage, Profile>(userId : createdUser.Id, expand : new[] { "user" });

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(events.List.Count == 4);             // This includes the "user created" event, so it will be one more than the number of events we create
        }
Esempio n. 3
0
        public async Task Create_Validate_And_Delete_Session_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var session = await client.Session.CreateAsync <SessionStorage, Profile>(new CreateSession <SessionStorage> {
                UserId = user.Id
            });

            var validateValidSession = await client.Session.ValidateAsync(session);

            var sessionDeletionResponse = await client.Session.DeleteAsync(session.Id);

            try
            {
                await client.Session.ValidateAsync(session);
            }
            catch (LunoApiException ex)
            {
                Assert.True(ex.Code == "session_not_found");
                Assert.True(validateValidSession.User.Id == user.Id);
            }
            finally
            {
                await client.User.DeactivateAsync(user.Id);
            }
        }
        public async Task Get_User_Analytics_Test_Async()
        {
            var client        = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var userAnalytics = await client.Analytics.GetUserAnalyticsAsync(new[] { "total", "4" });

            Assert.True(userAnalytics.ContainsKey("total"));
            Assert.True(userAnalytics.ContainsKey("4_days"));
        }
        public async Task Get_Session_Analytics_Test_Async()
        {
            var client           = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var sessionAnalytics = await client.Analytics.GetSessionAnalyticsAsync(new[] { "total", "5" });

            Assert.True(sessionAnalytics.ContainsKey("total"));
            Assert.True(sessionAnalytics.ContainsKey("5_days"));
        }
        public async Task Get_Events_Analytics_Test_Async()
        {
            var client         = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var eventAnalytics = await client.Analytics.GetEventAnalyticsAsync(new[] { "total", "11" });

            Assert.True(eventAnalytics.ContainsKey("total"));
            Assert.True(eventAnalytics.ContainsKey("11_days"));
        }
		public async Task Create_Annonymous_Session_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var session = await client.Session.CreateAsync<SessionStorage, Profile>();

			Assert.Null(session.User);
			Assert.NotNull(session.Id);
		}
Esempio n. 8
0
        public async Task Create_Annonymous_Session_Test_Async()
        {
            var client  = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var session = await client.Session.CreateAsync <SessionStorage, Profile>();

            Assert.Null(session.User);
            Assert.NotNull(session.Id);
        }
		public async Task Get_User_Analytics_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var userAnalytics = await client.Analytics.GetUserAnalyticsAsync(new[] { "total", "4" });

			Assert.True(userAnalytics.ContainsKey("total"));
			Assert.True(userAnalytics.ContainsKey("4_days"));
		}
		public async Task Get_Session_Analytics_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var sessionAnalytics = await client.Analytics.GetSessionAnalyticsAsync(new[] { "total", "5" });

			Assert.True(sessionAnalytics.ContainsKey("total"));
			Assert.True(sessionAnalytics.ContainsKey("5_days"));
		}
		public async Task Get_Events_Analytics_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var eventAnalytics = await client.Analytics.GetEventAnalyticsAsync(new[] { "total", "11" });

			Assert.True(eventAnalytics.ContainsKey("total"));
			Assert.True(eventAnalytics.ContainsKey("11_days"));
		}
Esempio n. 12
0
		public async Task Create_Get_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var createdUser = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var queriedUser = await client.User.GetAsync<Profile>(createdUser.Id);
			await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(queriedUser.Id == createdUser.Id);
		}
Esempio n. 13
0
		public async Task Create_Get_By_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var createdUser = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var gottenByIdUser = await client.User.GetByAsync<Profile>(UserSearchField.Id, createdUser.Id);
			var gottenByEmailUser = await client.User.GetByAsync<Profile>(UserSearchField.Email, createdUser.Email);
			var gottenByUsernameUser = await client.User.GetByAsync<Profile>(UserSearchField.Username, createdUser.Username);
			await client.User.DeactivateAsync(createdUser.Id);
		}
		public async Task Create_And_Delete_Api_Authentication_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var apiAuth = await client.ApiAuthentication.CreateAsync<ApiAuthenticationStorage, Profile>(new CreateApiAuthentication<ApiAuthenticationStorage> { UserId = user.Id, Details = new ApiAuthenticationStorage { Access = "full" } });
			var deletedApiAuth = await client.ApiAuthentication.DeleteAsync(apiAuth.Key);
			await client.User.DeactivateAsync(user.Id);

			Assert.True(deletedApiAuth.Success);
		}
Esempio n. 15
0
		public async Task Create_And_Delete_Session_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var session = await client.Session.CreateAsync<SessionStorage, Profile>(new CreateSession<SessionStorage> { UserId = user.Id });
			var sessionDeletionResponse = await client.Session.DeleteAsync(session.Id);
			await client.User.DeactivateAsync(user.Id);

			Assert.True(sessionDeletionResponse.Success);
		}
Esempio n. 16
0
		public async Task Get_Session_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var sessionA = await client.Session.CreateAsync<SessionStorage, Profile>(new CreateSession<SessionStorage> { UserId = user.Id });
			var sessionB = await client.Session.GetAsync<SessionStorage, Profile>(sessionA.Id);
			await client.User.DeactivateAsync(user.Id);

			Assert.True(sessionA.Key == sessionB.Key);
		}
Esempio n. 17
0
		public async Task Create_And_Delete_Event_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var @event = await client.Event.CreateAsync<EventStorage, Profile>(new CreateEvent<EventStorage> { UserId = user.Id, Name = "Unit Test Example Event" });
			var deletedEvent = await client.Event.DeleteAsync(@event.Id);
			await client.User.DeactivateAsync(user.Id);

			Assert.True(deletedEvent.Success);
		}
Esempio n. 18
0
        public async Task Create_Get_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var createdUser = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var queriedUser = await client.User.GetAsync <Profile>(createdUser.Id);

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(queriedUser.Id == createdUser.Id);
        }
		public async Task Create_User_Api_Authentication_And_Get_Api_Authentication_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var apiAuth = await client.ApiAuthentication.CreateAsync<ApiAuthenticationStorage, Profile>(new CreateApiAuthentication<ApiAuthenticationStorage> { UserId = user.Id });
			var gottenApiAuth = await client.ApiAuthentication.GetAsync<ApiAuthenticationStorage, Profile>(apiAuth.Key);
			await client.ApiAuthentication.DeleteAsync(apiAuth.Key);

			Assert.True(user.Id == gottenApiAuth.User.Id);
			Assert.True(apiAuth.Key == gottenApiAuth.Key);
		}
Esempio n. 20
0
		public async Task Create_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = Factory.GenerateCreateUser(Random);
			var createdUser = await client.User.CreateAsync(user);
			var deletionResponse = await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(createdUser.FirstName == user.FirstName);
			Assert.True(createdUser.LastName == user.LastName);
			Assert.True(deletionResponse.Success);
		}
Esempio n. 21
0
        public async Task Create_Login_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user        = Factory.GenerateCreateUser(Random);
            var createdUser = await client.User.CreateAsync(user);

            var loginResponse = await client.User.LoginAsync <Profile, SessionStorage>(user.Email, user.Password);

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(loginResponse.Session.User.Id == createdUser.Id);
        }
Esempio n. 22
0
        public async Task Create_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user        = Factory.GenerateCreateUser(Random);
            var createdUser = await client.User.CreateAsync(user);

            var deletionResponse = await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(createdUser.FirstName == user.FirstName);
            Assert.True(createdUser.LastName == user.LastName);
            Assert.True(deletionResponse.Success);
        }
Esempio n. 23
0
		public async Task Create_Update_And_Delete_Event_Destructive_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var @event = await client.Event.CreateAsync<EventStorage, Profile>(new CreateEvent<EventStorage> { UserId = user.Id, Name = "Unit Test Example Event", Details = new EventStorage { SecondField = "sample" } });
			await client.Event.UpdateAsync(@event.Id, new EventStorage { TickedId = Guid.NewGuid() }, destructive: true);
			var updatedEvent = await client.Event.GetAsync<EventStorage, Profile>(@event.Id);
			var deletedEvent = await client.Event.DeleteAsync(@event.Id);
			await client.User.DeactivateAsync(user.Id);

			Assert.Null(updatedEvent.Details.SecondField);
		}
Esempio n. 24
0
        public async Task Create_User_Validate_Password_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user        = Factory.GenerateCreateUser(Random);
            var createdUser = await client.User.CreateAsync(user);

            var validatePasswordResponse = await client.User.ValidatePasswordAsync(createdUser.Id, user.Password);

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(validatePasswordResponse.Success);
        }
		public async Task Create_Update_And_Delete_Api_Authentication_Destructive_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var apiAuth = await client.ApiAuthentication.CreateAsync<ApiAuthenticationStorage, Profile>(new CreateApiAuthentication<ApiAuthenticationStorage> { UserId = user.Id, Details = new ApiAuthenticationStorage { Access = "full" } });
			await client.ApiAuthentication.UpdateAsync(apiAuth.Key, new ApiAuthenticationStorage { SecondaryAccess = "full" }, destructive: true);
			var updatedApiAuth = await client.ApiAuthentication.GetAsync<ApiAuthenticationStorage, Profile>(apiAuth.Key);
			await client.ApiAuthentication.DeleteAsync(apiAuth.Key);
			await client.User.DeactivateAsync(user.Id);

			Assert.Null(updatedApiAuth.Details.Access);
			Assert.True(updatedApiAuth.Details.SecondaryAccess == "full");
		}
Esempio n. 26
0
		public async Task Create_Session_And_Update_Session_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var session = await client.Session.CreateAsync<SessionStorage, Profile>(new CreateSession<SessionStorage> { UserId = user.Id, Details = new SessionStorage { Test1 = "swag" } });
			session.Details = new SessionStorage { Test2 = "sample" };
			await client.Session.UpdateAsync(session.Id, session);
			var updatedSession = await client.Session.GetAsync<SessionStorage, Profile>(session.Id);
			await client.User.DeactivateAsync(user.Id);

			Assert.Null(session.Details.Test1);
			Assert.True(updatedSession.Details.Test2 == "sample");
		}
Esempio n. 27
0
        public async Task Create_Get_By_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var createdUser = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var gottenByIdUser = await client.User.GetByAsync <Profile>(UserSearchField.Id, createdUser.Id);

            var gottenByEmailUser = await client.User.GetByAsync <Profile>(UserSearchField.Email, createdUser.Email);

            var gottenByUsernameUser = await client.User.GetByAsync <Profile>(UserSearchField.Username, createdUser.Username);

            await client.User.DeactivateAsync(createdUser.Id);
        }
Esempio n. 28
0
        public async Task Create_And_Delete_Event_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var @event = await client.Event.CreateAsync <EventStorage, Profile>(new CreateEvent <EventStorage> {
                UserId = user.Id, Name = "Unit Test Example Event"
            });

            var deletedEvent = await client.Event.DeleteAsync(@event.Id);

            await client.User.DeactivateAsync(user.Id);

            Assert.True(deletedEvent.Success);
        }
Esempio n. 29
0
        public async Task Get_Session_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var sessionA = await client.Session.CreateAsync <SessionStorage, Profile>(new CreateSession <SessionStorage> {
                UserId = user.Id
            });

            var sessionB = await client.Session.GetAsync <SessionStorage, Profile>(sessionA.Id);

            await client.User.DeactivateAsync(user.Id);

            Assert.True(sessionA.Key == sessionB.Key);
        }
Esempio n. 30
0
		public async Task Create_Update_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var createdUser = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			createdUser.FirstName = "UpdatedAlex";
			createdUser.LastName = "UpdatedForbes-Reed";
			createdUser.Profile = new Profile { Field3 = "swag" };
			await client.User.UpdateAsync(createdUser.Id, createdUser, false);
			var updatedUser = await client.User.GetAsync<Profile>(createdUser.Id);
			await client.User.DeactivateAsync(updatedUser.Id);

			Assert.True(updatedUser.FirstName == createdUser.FirstName);
			Assert.True(updatedUser.LastName == createdUser.LastName);
			Assert.True(updatedUser.Profile.Field3 == createdUser.Profile.Field3);
		}
Esempio n. 31
0
        public async Task Create_User_Create_Session_Deactivate_Session_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var createdUser = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var session = await client.Session.CreateAsync <SessionStorage, Profile>(new CreateSession <SessionStorage> {
                UserId = createdUser.Id
            }, expand : new[] { "user" });

            var sessionDeletionResponse = await client.User.DeleteSessionsAsync(createdUser.Id);

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(sessionDeletionResponse.Count == 1);
        }
Esempio n. 32
0
        public async Task Create_User_Change_And_Validate_Password_And_Deactivate_User_2_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user        = Factory.GenerateCreateUser(Random);
            var createdUser = await client.User.CreateAsync(user);

            var newPassword            = "******";
            var changePasswordResponse = await client.User.ChangePasswordAsync(createdUser.Id, newPassword);

            changePasswordResponse = await client.User.ChangePasswordAsync(createdUser.Id, "67890uiop[]@~", currentPassword : newPassword);

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(changePasswordResponse.Success);
        }
Esempio n. 33
0
        public async Task Create_And_Delete_Session_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var session = await client.Session.CreateAsync <SessionStorage, Profile>(new CreateSession <SessionStorage> {
                UserId = user.Id
            });

            var sessionDeletionResponse = await client.Session.DeleteAsync(session.Id);

            await client.User.DeactivateAsync(user.Id);

            Assert.True(sessionDeletionResponse.Success);
        }
        public async Task Create_User_Api_Authentication_And_Get_Api_Authentication_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var apiAuth = await client.ApiAuthentication.CreateAsync <ApiAuthenticationStorage, Profile>(new CreateApiAuthentication <ApiAuthenticationStorage> {
                UserId = user.Id
            });

            var gottenApiAuth = await client.ApiAuthentication.GetAsync <ApiAuthenticationStorage, Profile>(apiAuth.Key);

            await client.ApiAuthentication.DeleteAsync(apiAuth.Key);

            Assert.True(user.Id == gottenApiAuth.User.Id);
            Assert.True(apiAuth.Key == gottenApiAuth.Key);
        }
        public async Task Create_And_Delete_Api_Authentication_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var apiAuth = await client.ApiAuthentication.CreateAsync <ApiAuthenticationStorage, Profile>(new CreateApiAuthentication <ApiAuthenticationStorage> {
                UserId = user.Id, Details = new ApiAuthenticationStorage {
                    Access = "full"
                }
            });

            var deletedApiAuth = await client.ApiAuthentication.DeleteAsync(apiAuth.Key);

            await client.User.DeactivateAsync(user.Id);

            Assert.True(deletedApiAuth.Success);
        }
Esempio n. 36
0
        public async Task Create_User_Create_Event_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user        = Factory.GenerateCreateUser(Random);
            var createdUser = await client.User.CreateAsync(user);

            var @event = new CreateEvent <EventStorage> {
                UserId = createdUser.Id, Name = "Purchased Ticket", Details = new EventStorage {
                    TickedId = Guid.NewGuid()
                }
            };
            var createdEvent = await client.Event.CreateAsync <EventStorage, Profile>(@event);

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(createdEvent.Name == @event.Name);
            Assert.True(createdEvent.Details.TickedId == @event.Details.TickedId);
        }
Esempio n. 37
0
        public async Task Create_Login_Deactivate_Sessions_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user        = Factory.GenerateCreateUser(Random);
            var createdUser = await client.User.CreateAsync(user);

            await client.User.LoginAsync <Profile, SessionStorage>(user.Email, user.Password);

            await client.User.LoginAsync <Profile, SessionStorage>(user.Email, user.Password);

            var sessions = await client.Session.GetAllAsync <SessionStorage, Profile>(createdUser.Id);

            var sessionDeletionResponse = await client.User.DeleteSessionsAsync(createdUser.Id);

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(sessionDeletionResponse.Count == sessions.List.Count);
        }
Esempio n. 38
0
        public async Task Create_Update_And_Delete_Event_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var @event = await client.Event.CreateAsync <EventStorage, Profile>(new CreateEvent <EventStorage> {
                UserId = user.Id, Name = "Unit Test Example Event"
            });

            await client.Event.UpdateAsync(@event.Id, new EventStorage { TickedId = Guid.NewGuid() });

            var updatedEvent = await client.Event.GetAsync <EventStorage, Profile>(@event.Id);

            var deletedEvent = await client.Event.DeleteAsync(@event.Id);

            await client.User.DeactivateAsync(user.Id);

            Assert.True(@event.Details.TickedId != updatedEvent.Details.TickedId);
        }
Esempio n. 39
0
        public async Task Create_Update_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var createdUser = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            createdUser.FirstName = "UpdatedAlex";
            createdUser.LastName  = "UpdatedForbes-Reed";
            createdUser.Profile   = new Profile {
                Field3 = "swag"
            };
            await client.User.UpdateAsync(createdUser.Id, createdUser, false);

            var updatedUser = await client.User.GetAsync <Profile>(createdUser.Id);

            await client.User.DeactivateAsync(updatedUser.Id);

            Assert.True(updatedUser.FirstName == createdUser.FirstName);
            Assert.True(updatedUser.LastName == createdUser.LastName);
            Assert.True(updatedUser.Profile.Field3 == createdUser.Profile.Field3);
        }
Esempio n. 40
0
		public async Task Create_Validate_And_Delete_Session_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var session = await client.Session.CreateAsync<SessionStorage, Profile>(new CreateSession<SessionStorage> { UserId = user.Id });
			var validateValidSession = await client.Session.ValidateAsync(session);
			var sessionDeletionResponse = await client.Session.DeleteAsync(session.Id);
			try
			{
				await client.Session.ValidateAsync(session);
			}
			catch (LunoApiException ex)
			{
				Assert.True(ex.Code == "session_not_found");
				Assert.True(validateValidSession.User.Id == user.Id);
			}
			finally
			{
				await client.User.DeactivateAsync(user.Id);
			}
		}
        public async Task Create_Update_And_Delete_Api_Authentication_Destructive_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var apiAuth = await client.ApiAuthentication.CreateAsync <ApiAuthenticationStorage, Profile>(new CreateApiAuthentication <ApiAuthenticationStorage> {
                UserId = user.Id, Details = new ApiAuthenticationStorage {
                    Access = "full"
                }
            });

            await client.ApiAuthentication.UpdateAsync(apiAuth.Key, new ApiAuthenticationStorage { SecondaryAccess = "full" }, destructive : true);

            var updatedApiAuth = await client.ApiAuthentication.GetAsync <ApiAuthenticationStorage, Profile>(apiAuth.Key);

            await client.ApiAuthentication.DeleteAsync(apiAuth.Key);

            await client.User.DeactivateAsync(user.Id);

            Assert.Null(updatedApiAuth.Details.Access);
            Assert.True(updatedApiAuth.Details.SecondaryAccess == "full");
        }
Esempio n. 42
0
        public async Task Create_Login_With_Session_Details_And_Deactivate_User_Test_Async()
        {
            var client      = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user        = Factory.GenerateCreateUser(Random);
            var createdUser = await client.User.CreateAsync(user);

            var loginResponse = await client.User.LoginAsync <Profile, SessionStorage>(user.Email, user.Password, new CreateSession <SessionStorage>
            {
                Ip      = "192.168.1.69",
                Details = new SessionStorage
                {
                    Test1 = "swag"
                }
            });

            var session = await client.Session.GetAsync <SessionStorage, Profile>(loginResponse.Session.Id);

            await client.User.DeactivateAsync(createdUser.Id);

            Assert.True(loginResponse.Session.User.Id == createdUser.Id);
            Assert.True(session.Ip == "192.168.1.69");
            Assert.True(session.Details.Test1 == "swag");
        }
Esempio n. 43
0
        public async Task Create_Session_And_Update_Session_Test_Async()
        {
            var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
            var user   = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));

            var session = await client.Session.CreateAsync <SessionStorage, Profile>(new CreateSession <SessionStorage> {
                UserId = user.Id, Details = new SessionStorage {
                    Test1 = "swag"
                }
            });

            session.Details = new SessionStorage {
                Test2 = "sample"
            };
            await client.Session.UpdateAsync(session.Id, session);

            var updatedSession = await client.Session.GetAsync <SessionStorage, Profile>(session.Id);

            await client.User.DeactivateAsync(user.Id);

            Assert.Null(session.Details.Test1);
            Assert.True(updatedSession.Details.Test2 == "sample");
        }
Esempio n. 44
0
		public async Task Create_User_Create_Event_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = Factory.GenerateCreateUser(Random);
			var createdUser = await client.User.CreateAsync(user);
			var @event = new CreateEvent<EventStorage> { UserId = createdUser.Id, Name = "Purchased Ticket", Details = new EventStorage { TickedId = Guid.NewGuid() } };
			var createdEvent = await client.Event.CreateAsync<EventStorage, Profile>(@event);
			await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(createdEvent.Name == @event.Name);
			Assert.True(createdEvent.Details.TickedId == @event.Details.TickedId);
		}
Esempio n. 45
0
 public async Task Get_Sessions_Test_Async()
 {
     var client   = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
     var sessions = await client.Session.GetAllAsync <SessionStorage, Profile>();
 }
Esempio n. 46
0
		public async Task Create_User_Validate_Password_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = Factory.GenerateCreateUser(Random);
			var createdUser = await client.User.CreateAsync(user);
			var validatePasswordResponse = await client.User.ValidatePasswordAsync(createdUser.Id, user.Password);
			await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(validatePasswordResponse.Success);
		}
Esempio n. 47
0
		public async Task Create_User_Change_And_Validate_Password_And_Deactivate_User_2_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = Factory.GenerateCreateUser(Random);
			var createdUser = await client.User.CreateAsync(user);
			var newPassword = "******";
			var changePasswordResponse = await client.User.ChangePasswordAsync(createdUser.Id, newPassword);
			changePasswordResponse = await client.User.ChangePasswordAsync(createdUser.Id, "67890uiop[]@~", currentPassword: newPassword);
			await client.User.DeactivateAsync(createdUser.Id);
			
			Assert.True(changePasswordResponse.Success);
		}
Esempio n. 48
0
		public async Task Create_Login_Deactivate_Sessions_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = Factory.GenerateCreateUser(Random);
			var createdUser = await client.User.CreateAsync(user);
			await client.User.LoginAsync<Profile, SessionStorage>(user.Email, user.Password);
			await client.User.LoginAsync<Profile, SessionStorage>(user.Email, user.Password);
			var sessions = await client.Session.GetAllAsync<SessionStorage, Profile>(createdUser.Id);
			var sessionDeletionResponse = await client.User.DeleteSessionsAsync(createdUser.Id);
			await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(sessionDeletionResponse.Count == sessions.List.Count);
		}
Esempio n. 49
0
		public async Task Create_User_Create_Session_Deactivate_Session_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var createdUser = await client.User.CreateAsync(Factory.GenerateCreateUser(Random));
			var session = await client.Session.CreateAsync<SessionStorage, Profile>(new CreateSession<SessionStorage> { UserId = createdUser.Id }, expand: new[] { "user" });
			var sessionDeletionResponse = await client.User.DeleteSessionsAsync(createdUser.Id);
			await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(sessionDeletionResponse.Count == 1);
		}
Esempio n. 50
0
		public async Task Create_Login_With_Session_Details_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = Factory.GenerateCreateUser(Random);
			var createdUser = await client.User.CreateAsync(user);
			var loginResponse = await client.User.LoginAsync<Profile, SessionStorage>(user.Email, user.Password, new CreateSession<SessionStorage>
			{
				Ip = "192.168.1.69",
				Details = new SessionStorage
				{
					Test1 = "swag"
				}
			});
			var session = await client.Session.GetAsync<SessionStorage, Profile>(loginResponse.Session.Id);
			await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(loginResponse.Session.User.Id == createdUser.Id);
			Assert.True(session.Ip == "192.168.1.69");
			Assert.True(session.Details.Test1 == "swag");
		}
Esempio n. 51
0
		public async Task Get_Sessions_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var sessions = await client.Session.GetAllAsync<SessionStorage, Profile>();
		}
Esempio n. 52
0
		public async Task Create_Login_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = Factory.GenerateCreateUser(Random);
			var createdUser = await client.User.CreateAsync(user);
			var loginResponse = await client.User.LoginAsync<Profile, SessionStorage>(user.Email, user.Password);
			await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(loginResponse.Session.User.Id == createdUser.Id);
		}
Esempio n. 53
0
		public async Task Create_User_Create_Event_Get_Events_And_Deactivate_User_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var user = Factory.GenerateCreateUser(Random);
			var createdUser = await client.User.CreateAsync(user);
			await client.Event.CreateAsync<EventStorage, Profile>(new CreateEvent<EventStorage> { UserId = createdUser.Id, Name = "Purchased Ticket 1", Details = new EventStorage { TickedId = Guid.NewGuid() } });
			await client.Event.CreateAsync<EventStorage, Profile>(new CreateEvent<EventStorage> { UserId = createdUser.Id, Name = "Purchased Ticket 2", Details = new EventStorage { TickedId = Guid.NewGuid() } });
			await client.Event.CreateAsync<EventStorage, Profile>(new CreateEvent<EventStorage> { UserId = createdUser.Id, Name = "Purchased Ticket 3", Details = new EventStorage { TickedId = Guid.NewGuid() } });
			var events = await client.Event.GetAllAsync<EventStorage, Profile>(userId: createdUser.Id, expand: new[] { "user" });
			await client.User.DeactivateAsync(createdUser.Id);

			Assert.True(events.List.Count == 4); // This includes the "user created" event, so it will be one more than the number of events we create
		}
 public async Task Get_Events_Analytics_Timeline_Test_Async()
 {
     var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
     var eventAnalyticsTimeline = await client.Analytics.GetEventAnalyticsTimelineAsync();
 }
		public async Task Get_Events_Analytics_Timeline_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var eventAnalyticsTimeline = await client.Analytics.GetEventAnalyticsTimelineAsync();
		}
Esempio n. 56
0
		public async Task Get_Event_Test_Async()
		{
			var client = new Luno.LunoClient(Factory.GenerateApiKeyConnection());
			var events = await client.Event.GetAllAsync<EventStorage, Profile>();
			var @event = await client.Event.GetAsync<EventStorage, Profile>(events.List.First().Id);
		}