Beispiel #1
0
        public void ChangePassword()
        {
            var passwordDatabaseMock         = new Mock <IPasswordDatabase>();
            var passwordChangerExFactoryMock = new Mock <IPasswordChangerExFactory>();
            var passwordChangerExMock        = new Mock <IPasswordChangerEx>();

            passwordChangerExFactoryMock.Setup(x => x.Create(It.IsAny <HostType>())).Returns(passwordChangerExMock.Object);
            var hostTypeMapperMock = new Mock <IHostTypeMapper>();

            hostTypeMapperMock.Setup(x => x.Get(It.IsAny <IHostPwEntry>())).Returns(HostType.Unknown);

            var passwordChangerService = new PasswordChangerService(
                passwordDatabaseMock.Object,
                passwordChangerExFactoryMock.Object,
                hostTypeMapperMock.Object
                );

            var hostPwEntry = new InMemoryHostPwEntry()
            {
                IPAddress = "localhost",
                Username  = "******",
                Password  = "******"
            };

            passwordChangerService.ChangePassword(hostPwEntry, "newPassword");

            Assert.AreEqual("newPassword", hostPwEntry.Password);
            passwordChangerExFactoryMock.Verify(v => v.Create(HostType.Unknown), Times.Once);
            hostTypeMapperMock.Verify(v => v.Get(hostPwEntry), Times.Once);
            passwordChangerExMock.Verify(v => v.ChangePassword(hostPwEntry, "newPassword"), Times.Once);
            passwordDatabaseMock.Verify(v => v.Save(), Times.Never);
        }
        public void Format()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "127.0.0.1"
            };

            WinScpArgumentsFormatter argumentsFormatter = new WinScpArgumentsFormatter("WinSCP.exe");

            Assert.AreEqual("\"WinSCP.exe\" scp://root:\"12345678\"@127.0.0.1", argumentsFormatter.Format(pwEntry));
        }
        public void FormatWithSpecialCharsInPassword()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "127.0.0.1:2222"
            };

            WinScpArgumentsFormatter argumentsFormatter = new WinScpArgumentsFormatter("WinSCP.exe");

            Assert.AreEqual("\"WinSCP.exe\" scp://root:\"%23m%2By%2Fp%40ssw0rd\"@127.0.0.1:2222", argumentsFormatter.Format(pwEntry));
        }
        public void FormatWithKeyFile()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username          = "******",
                Password          = "******",
                IPAddress         = "127.0.0.1",
                AdditionalOptions = "key:\"C:\\Key Files\\PrivateKey.ppk\""
            };

            WinScpArgumentsFormatter argumentsFormatter = new WinScpArgumentsFormatter("WinSCP.exe");

            Assert.AreEqual("\"WinSCP.exe\" scp://[email protected] -privatekey=\"C:\\Key Files\\PrivateKey.ppk\" -passphrase=\"12345678\"", argumentsFormatter.Format(pwEntry));
        }
Beispiel #5
0
        public void Format()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "127.0.0.1"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.RemoteDesktop);

            RemoteDesktopArgumentsFormatter argumentsFormatter = new RemoteDesktopArgumentsFormatter();

            Assert.AreEqual(String.Format("\"{0}\" /v:127.0.0.1", RemoteDesktopArgumentsFormatter.RemoteDesktopClientPath), argumentsFormatter.Format(pwEntry));
        }
        public void Format()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "127.0.0.1"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.RemoteDesktop);

            CmdKeyUnregisterArgumentsFormatter argumentsFormatter = new CmdKeyUnregisterArgumentsFormatter();

            Assert.AreEqual("/delete:TERMSRV/127.0.0.1", argumentsFormatter.Format(pwEntry));
        }
        public void Format()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "127.0.0.1"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.vSphereClient);

            VSphereClientArgumentsFormatter argumentsFormatter = new VSphereClientArgumentsFormatter("VpxClient.exe");

            Assert.AreEqual("\"VpxClient.exe\" -s 127.0.0.1 -u root -p 12345678", argumentsFormatter.Format(pwEntry));
        }
        public void FormatWithTelnetConnection()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "127.0.0.1"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.PuttyTelnet);

            FakePuttySessionFinder sessionFinder = new FakePuttySessionFinder();

            PuttyArgumentsFormatter argumentsFormatter = new PuttyArgumentsFormatter("putty.exe", sessionFinder, true);

            Assert.AreEqual("\"putty.exe\" -telnet [email protected]", argumentsFormatter.Format(pwEntry));
        }
        public void FormatWithPath()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "127.0.0.1"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.RemoteDesktop);

            CmdKeyUnregisterArgumentsFormatter argumentsFormatter = new CmdKeyUnregisterArgumentsFormatter()
            {
                IncludePath = true
            };

            Assert.AreEqual(String.Format("\"{0}\" /delete:TERMSRV/127.0.0.1", CmdKeyRegisterArgumentsFormatter.CmdKeyPath), argumentsFormatter.Format(pwEntry));
        }
        public void FormatWithSSHConnectionAndSessionNotFound()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username          = "******",
                Password          = "******",
                IPAddress         = "127.0.0.1",
                AdditionalOptions = "session:MySession1"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.PuttySSH);

            FakePuttySessionFinder sessionFinder = new FakePuttySessionFinder();

            PuttyArgumentsFormatter argumentsFormatter = new PuttyArgumentsFormatter("putty.exe", sessionFinder, true);

            Assert.AreEqual("\"putty.exe\" -ssh [email protected] -pw \"12345678\"", argumentsFormatter.Format(pwEntry));
        }
        public void FormatWithNoPassword()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "127.0.0.1:2222"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.PuttySSH);

            var mock = new Mock <IPuttySessionFinder>();

            mock.Setup(m => m.Find(It.IsAny <String>())).Returns(new Collection <String>());
            PuttyArgumentsFormatter argumentsFormatter = new PuttyArgumentsFormatter("putty.exe", mock.Object, false);

            Assert.AreEqual("\"putty.exe\" -P 2222 -ssh [email protected]", argumentsFormatter.Format(pwEntry));
        }
        public void FormatWithCommandContainingPort(bool appendPassword)
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username          = "******",
                Password          = "******",
                IPAddress         = "127.0.0.1",
                AdditionalOptions = "ssh;command:-L 5555:127.0.0.1:5432 -pw \"123456\""
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.PuttySSH);

            var mock = new Mock <IPuttySessionFinder>();

            mock.Setup(m => m.Find(It.IsAny <String>())).Returns(new Collection <String>());
            PuttyArgumentsFormatter argumentsFormatter = new PuttyArgumentsFormatter("putty.exe", mock.Object, appendPassword);

            Assert.AreEqual("\"putty.exe\" -ssh [email protected] -L 5555:127.0.0.1:5432 -pw \"123456\"", argumentsFormatter.Format(pwEntry));
        }
Beispiel #13
0
        public void FormatWithSSHConnectionAndOverrideDefaultPort()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username          = "******",
                Password          = "******",
                IPAddress         = "127.0.0.1",
                AdditionalOptions = "session:MySession1;port:50000"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.PuttySSH);
            FakePuttySessionFinder sessionFinder = new FakePuttySessionFinder();

            sessionFinder.Sessions.Add("MySession");

            PuttyArgumentsFormatter argumentsFormatter = new PuttyArgumentsFormatter("putty.exe", sessionFinder);

            Assert.AreEqual("\"putty.exe\" -load \"MySession\" -P 50000 -ssh [email protected] -pw \"12345678\"", argumentsFormatter.Format(pwEntry));
        }
        public void FormatWithKeyFile()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username          = "******",
                Password          = "******",
                IPAddress         = "127.0.0.1",
                AdditionalOptions = "key:\"C:\\Key Files\\PrivateKey.ppk\""
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.PuttySSH);

            var mock = new Mock <IPuttySessionFinder>();

            mock.Setup(m => m.Find(It.IsAny <String>())).Returns(new Collection <String>());

            PuttyArgumentsFormatter argumentsFormatter = new PuttyArgumentsFormatter("putty.exe", mock.Object, true);

            Assert.AreEqual("\"putty.exe\" -i \"C:\\Key Files\\PrivateKey.ppk\" -ssh [email protected] -pw \"12345678\"", argumentsFormatter.Format(pwEntry));
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var pwDatabase  = new FakePasswordDatabase();
            var hostPwEntry = new InMemoryHostPwEntry()
            {
                Username  = "******",
                Password  = "******",
                IPAddress = "host",
            };

            hostPwEntry.ConnectionMethods.Add(ConnectionMethodType.RemoteDesktop);
            var pwChanger = new FakePasswordChanger(HostType.Windows)
            {
                ThreadSleepDuration = 20000
            };
            var pwChangerService   = new PasswordChangerServiceWrapper(pwDatabase, pwChanger, new SystemClock());
            var formPasswordChange = new FormPasswordChanger(hostPwEntry, pwChangerService);

            Application.Run(formPasswordChange);
        }
        public void FormatWithPortFromHostAddressTakePrecedence()
        {
            InMemoryHostPwEntry pwEntry = new InMemoryHostPwEntry()
            {
                Username          = "******",
                Password          = "******",
                IPAddress         = "127.0.0.1:2222",
                AdditionalOptions = "session:MySession1;port:50000"
            };

            pwEntry.ConnectionMethods.Add(ConnectionMethodType.PuttySSH);

            var mock = new Mock <IPuttySessionFinder>();

            mock.Setup(m => m.Find(It.IsAny <String>())).Returns(new Collection <String>()
            {
                "MySession"
            });

            PuttyArgumentsFormatter argumentsFormatter = new PuttyArgumentsFormatter("putty.exe", mock.Object, true);

            Assert.AreEqual("\"putty.exe\" -load \"MySession\" -P 2222 -ssh [email protected] -pw \"12345678\"", argumentsFormatter.Format(pwEntry));
        }