internal async Tasks.Task <bool> CheckUserLogin(string userName, string password) { var config = botConfigurations.First(); var driver = new RocketChatDriver(config.RocketServerUrl, config.UseSsl, logger); return(await driver.CheckLogin(userName, password)); }
public async Task Run() { const string username = "******"; const string password = "******"; const string rocketServerUrl = "demo.rocket.chat:3000"; const bool useSsl = false; ILoginOption loginOption = new LdapLoginOption { Username = username, Password = password }; IRocketChatDriver driver = new RocketChatDriver(rocketServerUrl, useSsl); await driver.ConnectAsync(); // Connect to server await driver.LoginAsync(loginOption); // Login via LDAP await driver.SubscribeToRoomAsync(); // Listen on all rooms driver.MessageReceived += Console.WriteLine; var generalRoomIdResult = await driver.GetRoomIdAsync("general"); if (generalRoomIdResult.HasError) { throw new Exception("Could not find room by name."); } var generalRoomId = generalRoomIdResult.Result; await driver.SendMessageAsync("message", generalRoomId); }
public async Task Version_should_be_compatible() { // This isn't really a test. // It's here for my own record keeping, // if something breaks I'll know the last good version from // test/git history var supportedVersions = new[] { //"0.22.0", //"0.25.0", //"0.26.0", //"0.27.0", //"0.28.0", // Broken at 0.29.0 //"0.29.0", //"0.30.0", //"0.31.0", // Pin messages broken, different return room lookup "0.32.0", "0.33.0", "0.34.0", "0.35.0", }; await DefaultAccountLoginAsync(); // Act var results = await RocketChatDriver.GetStatisticsAsync(); // Assert supportedVersions.Should().Contain(results.Result.Version); }
public void Connecting_multiple_times_should_throw() { // Act Action action = () => RocketChatDriver.ConnectAsync().Wait(); // Assert action.ShouldThrow <Exception>(); }
public void Unknown_login_option_should_throw() { // Act Action action = () => RocketChatDriver.LoginAsync(new DummyLoginOption()).Wait(); // Assert action.ShouldThrow <NotSupportedException>(); }
public async Task Ping_should_send_keep_alive() { await DefaultAccountLoginAsync(); // Act await RocketChatDriver.PingAsync(); // Assert }
public async Task Can_login_with_username() { // Act var loginResult = await RocketChatDriver.LoginWithUsernameAsync(Constants.OneUsername, Constants.OnePassword); // Assert loginResult.Should().NotBeNull(); loginResult.HasError.Should().BeFalse(); loginResult.Result.Token.Should().NotBeNull(); }
public async Task List_channel_should_return_list_of_channels() { await DefaultAccountLoginAsync(); // Act var result = await RocketChatDriver.ChannelListAsync(); // Assert result.HasError.Should().BeFalse(); result.Result.Channels.Should().Contain(x => x.Name == "general" && x.Id == "GENERAL"); }
public async Task FullUserData_returns_user_data() { await DefaultAccountLoginAsync(); // Act var userData = await RocketChatDriver.GetFullUserDataAsync(Constants.TwoUsername); // Assert userData.Username.Should().Be(Constants.TwoUsername); userData.Emails.Should().Contain(x => x.Address.Contains(Constants.TwoEmail)); }
private static async Task <IRocketChatDriver> ComposeAsync() { var driver = new RocketChatDriver(Constants.RocketServer, false); await driver.ConnectAsync(); await driver.LoginWithEmailAsync(Constants.OneEmail, Constants.OnePassword); await driver.SubscribeToRoomListAsync(); return(driver); }
public async Task Bad_login_should_have_error_data() { // Act var loginResult = await RocketChatDriver.LoginWithUsernameAsync(Constants.OneUsername, AutoFixture.Create <string>()); // Assert loginResult.Should().NotBeNull(); loginResult.HasError.Should().BeTrue(); loginResult.Error.Message.Should().Be("Incorrect password [403]"); }
public async Task When_logging_in_with_a_non_existing_user_return_error() { // Act var loginResult = await RocketChatDriver.LoginWithUsernameAsync(AutoFixture.Create <string>(), AutoFixture.Create <string>()); // Assert loginResult.Should().NotBeNull(); loginResult.HasError.Should().BeTrue(); loginResult.Error.Message.Should().Be("User not found [403]"); }
public async Task FullUserData_returns_null_when_doesnt_exist() { var username = AutoFixture.Create <string>(); await DefaultAccountLoginAsync(); // Act var userData = await RocketChatDriver.GetFullUserDataAsync(username); // Assert userData.Should().BeNull(); }
public async Task Room_subscription_should_contain_general_room() { await DefaultAccountLoginAsync(); // Act await RocketChatDriver.SubscribeToRoomListAsync(); // Assert var collection = RocketChatDriver.GetRooms().ToList(); collection.Should().ContainSingle(x => x.RoomId == "GENERAL") .Which.Type.Should().Be(RoomType.Channel); }
public async Task Create_direct_message_that_does_not_exist_should_create_room() { var roomName = $"{Constants.TwoUsername}"; RoomsCreatedByName.Add(roomName); await DefaultAccountLoginAsync(); // Act var result = await RocketChatDriver.CreatePrivateMessageAsync(roomName); // Assert result.HasError.Should().BeFalse(); }
public async Task Room_should_contain_general_room_with_info() { await DefaultAccountLoginAsync(); // Act await RocketChatDriver.SubscribeToRoomListAsync(); var collection = RocketChatDriver.Rooms; // Assert var room = collection.FirstOrDefault(x => x.Id == "GENERAL"); room.Should().NotBeNull(); }
public async Task Lookup_of_valid_room_returns_roomId() { // GENERAL -> GENERAL const string roomName = "GENERAL"; const string roomId = "GENERAL"; await DefaultAccountLoginAsync(); // Act var result = await RocketChatDriver.GetRoomIdAsync(roomName); // Assert result.Result.Should().Be(roomId); }
public async Task Create_group_that_does_not_exist_should_create_group() { var roomName = AutoFixture.Create <string>(); RoomsCreatedByName.Add(roomName); await DefaultAccountLoginAsync(); // Act var result = await RocketChatDriver.CreateGroupAsync(roomName); // Assert result.HasError.Should().BeFalse(); }
public async Task Room_subscription_should_contain_general_room_info() { await DefaultAccountLoginAsync(); // Act await RocketChatDriver.SubscribeToRoomListAsync(); var collection = RocketChatDriver.GetRoomInfoCollection(); // Assert var room = collection.GetById("GENERAL"); room.Should().NotBeNull(); }
public async Task Delete_room_that_does_not_exists_should_return_error() { var roomId = AutoFixture.Create <string>(); await DefaultAccountLoginAsync(); // Act var result = await RocketChatDriver.EraseRoomAsync(roomId); // Assert result.HasError.Should().BeTrue(); // Currently any issues returns 500, this will hopefully change later result.Error.Error.Should().Be("500"); }
public async Task Should_do_something_on_bad_creds() { const string userName = "******"; const string password = "******"; var driver = new RocketChatDriver("dev0:3000", false, new XUnitLogger(_helper)); await driver.ConnectAsync(); var loginResult = await driver.LoginWithEmailAsync(userName, password); Assert.Equal("403", loginResult.error.error.ToString()); driver.Dispose(); }
public async Task Message_history() { const string userName = "******"; const string password = "******"; IRocketChatDriver driver = new RocketChatDriver("dev0:3000", false, new XUnitLogger(_helper)); await driver.ConnectAsync(); var loginResult = await driver.LoginWithEmailAsync(userName, password); var result = await driver.LoadMessagesAsync("GENERAL"); driver.Dispose(); }
public async Task Lookup_of_non_existing_room_returns_null() { // Used to return room id, now throws a 500 as room is null var roomName = AutoFixture.Create <string>(); await DefaultAccountLoginAsync(); // Act var result = await RocketChatDriver.GetRoomIdAsync(roomName); // Assert result.HasError.Should().BeTrue(); result.Result.Should().BeNull(); result.Error.Reason.Should().Be("Not allowed"); }
public async Task Create_room_that_does_exist_should_return_error() { var roomName = AutoFixture.Create <string>(); RoomsCreatedByName.Add(roomName); await DefaultAccountLoginAsync(); await RocketChatDriver.CreateChannelAsync(roomName); // Act var result = await RocketChatDriver.CreateChannelAsync(roomName); // Assert result.HasError.Should().BeTrue(); result.Error.Error.Should().Be("error-duplicate-channel-name"); }
public async Task Send_attachments() { //const string password = "******"; //var driver = new RocketChatDriver("demo.rocket.chat", true, _xUnitLogger); var userName = Constants.OneEmail; var password = Constants.OnePassword; var driver = new RocketChatDriver(Constants.RocketServer, false, _xUnitLogger); await driver.ConnectAsync(); await driver.LoginWithEmailAsync(userName, password); var roomId = await driver.GetRoomIdAsync("GENERAL"); //var a = await driver.SendCustomMessageAsync("test mesage", "name", roomId.Result); driver.Dispose(); }
public static async void Initialise(ChatContext context) { ILoginOption loginOption = new LdapLoginOption { Username = context.Username, Password = context.Password }; IRocketChatDriver driver = new RocketChatDriver(context.RocketServerUrl, context.UseSSL); await driver.ConnectAsync(); // Connect to server await driver.LoginAsync(loginOption); // Login via LDAP await driver.SubscribeToRoomAsync(); // Listen on all rooms driver.MessageReceived += message => { context.MessageRead?.Invoke(message); }; }
public async Task Can_login() { const string userName = "******"; const string password = "******"; var driver = new RocketChatDriver("dev0:3000", false, new XUnitLogger(_helper)); await driver.ConnectAsync(); var loginResult = await driver.LoginWithEmailAsync(userName, password); var roomId = await driver.GetRoomIdAsync("GENERAL"); await driver.JoinRoomAsync(roomId); await driver.SubscribeToRoomAsync(roomId); await driver.SendMessageAsync("hello world", roomId); driver.Dispose(); }
public async Task Delete_room_that_exists_should_delete_room() { var roomName = AutoFixture.Create <string>(); RoomsCreatedByName.Add(roomName); await DefaultAccountLoginAsync(); var room = await RocketChatDriver.CreateChannelAsync(roomName); // Act var result = await RocketChatDriver.EraseRoomAsync(room.Result.RoomId); // Assert result.HasError.Should().BeFalse(); result.Result.Should().Be(1); var rooms = await RocketChatDriver.ChannelListAsync(); rooms.Result.Channels.Should().NotContain(x => x.Id == room.Id); }
public async Task Can_login() { //const string password = "******"; //var driver = new RocketChatDriver("demo.rocket.chat", true, _xUnitLogger); var driver = new RocketChatDriver(Constants.RocketServer, false, _xUnitLogger); await driver.ConnectAsync(); var loginResult = await driver.LoginWithEmailAsync(Constants.OneEmail, Constants.OnePassword); var roomId = await driver.GetRoomIdAsync("GENERAL"); await driver.JoinRoomAsync(roomId.Result); await driver.SubscribeToRoomAsync(roomId.Result); var messages = await driver.SendMessageAsync("", roomId.Result); driver.Dispose(); }
public LoginFacts(ITestOutputHelper helper) : base(helper) { RocketChatDriver.ConnectAsync().Wait(); }