public void Login_SocketKeepAliveFail_ReturnsFalse() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.When(x => x.WaitFor("Password:"******"[c")).Do(x => { throw new InvalidOperationException(); }); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_InvalidAixLoginUsername_ReturnsFalse() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c"); socketMock.Read().Returns("invalid login"); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_SocketWriteFail_ReturnsFalse() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WhenForAnyArgs(x => x.Write(new byte[] { })) .Do(x => { throw new NetworkInformationException(); }); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_SocketWriteFail_HasError() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WhenForAnyArgs(x => x.Write(new byte[] { })) .Do(x => { throw new NetworkInformationException(); }); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole"); session.Error.Should().Contain("Telnet communication failed"); }
public void Login_InvalidSymLogin_ReturnsFalse() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand().Returns(new SymCommand("SymLogonInvalidUser")); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_InvalidAixLoginPassword_HasErrorMessage() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******"invalid login"); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole"); session.Error.Should().Contain("Invalid AIX Login"); }
private void Login() { while (!_session.LoggedIn) { _session.Disconnect(); _session.Connect("symitar", 23); _session.Login("jdeering", "h3dd0#mon", "083ch#ckb00k"); if (_session.LoggedIn) { responseBox.Text += @"Logged in"; responseBox.Text += "\n\n"; } } }
public void Login_CommandPromptNoWait_ReturnsTrue() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******"[c"); socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary <string, string> { { "HelpCode", "10025" } })); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeTrue(); }
public void Login_SocketKeepAliveException_ReturnsFalse() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary <string, string> { { "HelpCode", "10025" } })); socketMock.When(x => x.KeepAliveStart()).Do(x => { throw new Exception(); }); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_Successful_StartsKeepAliveOnSocket() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary <string, string> { { "HelpCode", "10025" } })); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole"); socketMock.Received().KeepAliveStart(); }
public void Login_LocksDuringLogin_ReturnsFalse() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand() .Returns(new SymCommand("SymLogonError", new Dictionary <string, string> { { "Text", "Too Many Invalid Password Attempts" } })); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_InputHasHelpCode_CallsHostSyncWrite() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand() .Returns( new SymCommand("Request"), new SymCommand("Input", new Dictionary <string, string> { { "HelpCode", "10025" } }) ); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole"); socketMock.Received().Write("$WinHostSync$\r"); }
//======================================================================== public bool Connect() { if (Connection != null) { if (Connection.isLoggedIn) { return(true); } } Connection = new SymSession(); if (!Connection.Connect(Parent.IP, Parent.Port)) { return(false); } if (Connection.Login(Parent.AixUsr, Parent.AixPwd, SymDir, SymId) == false) { Connection.Disconnect(); Connection = null; return(false); } return(true); }
//======================================================================== // sym Connections //======================================================================== public static SymSession TrySymNewConnect(SymInst inst) { SymSession session = new SymSession(); bool prompt = false; string user = inst.Parent.AixUsr; string pass = inst.Parent.AixPwd; string id = inst.SymId; if (user == "") { prompt = true; } if (pass == "") { prompt = true; } if (id == "") { prompt = true; } bool success = false; if (!prompt) { success = session.Connect(inst.Parent.IP, inst.Parent.Port); if (success) { success = session.Login(user, pass, inst.SymDir, id); } while (!success) { if (MessageBox.Show("Error Connecting to Sym\nRetry?", "PwrIDE", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No) { break; } success = session.Connect(inst.Parent.IP, inst.Parent.Port); if (success) { success = session.Login(user, pass, inst.SymDir, id); } } if (!success) { return(null); } return(session); } while (!success) { frmLogin login = new frmLogin(inst.Parent.IP, inst.SymDir, user, pass, id); if (login.ShowDialog(MainForm) == DialogResult.Cancel) { break; } inst.Parent.AixUsr = user = login.User; inst.Parent.AixPwd = pass = login.Pass; inst.SymId = id = login.ID; login.Dispose(); success = inst.Connect(); if (success) { success = session.Login(user, pass, inst.SymDir, id); } if (!success) { if (MessageBox.Show("Error Connecting to Sym\nRetry?", "PwrIDE", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No) { break; } } } if (!success) { return(null); } return(session); }
public void Login_CommandPromptNoWait_ReturnsTrue() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******"[c"); socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary<string, string> { { "HelpCode", "10025" } })); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeTrue(); }
public void Login_InputHasHelpCode_CallsHostSyncWrite() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand() .Returns( new SymCommand("Request"), new SymCommand("Input", new Dictionary<string, string> {{"HelpCode", "10025"}}) ); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole"); socketMock.Received().Write("$WinHostSync$\r"); }
public void Login_InvalidAixLoginPassword_HasErrorMessage() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******"invalid login"); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole"); session.Error.Should().Contain("Invalid AIX Login"); }
public void Login_SocketKeepAliveException_ReturnsFalse() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary<string, string> { { "HelpCode", "10025" } })); socketMock.When(x => x.KeepAliveStart()).Do(x => { throw new Exception(); }); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_InvalidSymLogin_ReturnsFalse() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand().Returns(new SymCommand("SymLogonInvalidUser")); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_1000SymDir_ThrowsArgumentOutOfRangeException() { AfterConnect(); Assert.Throws <ArgumentOutOfRangeException>( () => _session.Login("bob", "dole", 1000, "bobdole")); }
public void Login_Successful_StartsKeepAliveOnSocket() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand().Returns(new SymCommand("Input", new Dictionary<string, string> {{"HelpCode", "10025"}})); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole"); socketMock.Received().KeepAliveStart(); }
//------------------------------------------------------------------------ private void btnTest_Click(object sender, EventArgs e) { SymSession test = new SymSession(); try { if (!test.Connect(Server.IP, Server.Port)) { MessageBox.Show(test.error, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string aixPwd = Server.AixPwd; if (aixPwd.Trim().Length == 0) { InputBox inp = new InputBox("Test Sym Connection", "Please Enter AIX Password for Server \"" + Server.Alias + "\".", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } aixPwd = inp.Input; inp.Dispose(); } bool retry = true; bool result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text); while (retry && (!result)) { retry = false; if (result == false) { if (test.error == "Invalid AIX Login") { InputBox inp = new InputBox("Test Sym Connection", "Invalid AIX Login.\nPlease Re-Enter or Cancel (ESC).", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } aixPwd = inp.Input; inp.Dispose(); result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text, 1); retry = true; } else if (test.error == "Invalid Sym User") { InputBox inp = new InputBox("Test Sym Connection", "Invalid Sym User ID.\nPlease Re-Enter or Cancel (ESC).", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } txtID.Text = inp.Input; inp.Dispose(); result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text, 2); retry = true; } else { retry = (MessageBox.Show("Error Connecting to Sym\nError: " + test.error + "\n\nRetry?", "Sym Connection Test", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes); } if ((!retry) && (!result)) { test.Disconnect(); return; } } } } catch (Exception ex) { MessageBox.Show("Error During Login Test\n" + ex.Message, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } test.Disconnect(); MessageBox.Show("Sym Connected Okay!", "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.None); }
public void Login_SocketWriteFail_HasError() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WhenForAnyArgs(x => x.Write(new byte[] { })) .Do(x => { throw new NetworkInformationException(); }); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole"); session.Error.Should().Contain("Telnet communication failed"); }
public void Login_SocketKeepAliveFail_ReturnsFalse() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.When(x => x.WaitFor("Password:"******"[c")).Do(x => { throw new InvalidOperationException(); }); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_InvalidAixLoginUsername_ReturnsFalse() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c"); socketMock.Read().Returns("invalid login"); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_SocketWriteFail_ReturnsFalse() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WhenForAnyArgs(x => x.Write(new byte[] { })) .Do(x => { throw new NetworkInformationException(); }); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }
public void Login_LocksDuringLogin_ReturnsFalse() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connected.Returns(true); socketMock.WaitFor("Password:"******"[c").Returns(0); socketMock.WaitFor(":").Returns(0); socketMock.Read().Returns("Password:"******":"); socketMock.ReadCommand() .Returns(new SymCommand("SymLogonError", new Dictionary<string, string> { {"Text", "Too Many Invalid Password Attempts"} })); var session = new SymSession(socketMock, 10); session.Login("bob", "dole", "bobdole").Should().BeFalse(); }