Ejemplo n.º 1
0
        protected private static ConsoleKeyInfo ReadKey(CommandLineAutoReader reader)
        {
            var chr = reader.ReadKey();

            ConsoleKey key = ConvertKey(chr);

            return(new ConsoleKeyInfo(chr, key, false, false, false));
        }
        public async Task KinitExecutes()
        {
            var port = NextPort();

            using (var tmpCacheFile = new TemporaryFile())
                using (var tmpConfigFile = new TemporaryFile())
                {
                    var config = Krb5Config.Default();

                    File.WriteAllText(tmpConfigFile.File, config.Serialize());

                    using (var listener = StartTcpListener(port))
                    {
                        _ = listener.Start();

                        var reader = new CommandLineAutoReader();

                        var io = new InputControl
                        {
                            Clear      = () => { },
                            HookCtrlC  = hook => { },
                            ResetColor = () => { },
                            SetColor   = c => { },
                            Reader     = reader,
                            Writer     = new StringWriter(),
                            ReadKey    = () => ReadKey(reader)
                        };

                        var command = CreateCommand($"127.0.0.1:{port}", AdminAtCorpUserName, tmpCacheFile.File, tmpConfigFile.File, io);

                        reader.QueueNext(FakeAdminAtCorpPassword + "\n");

                        await command.Execute();

                        var output = io.Writer.ToString();

                        Assert.IsTrue(output.Contains("Ticket Count: 1"));
                        Assert.IsTrue(output.Contains("client : administrator", StringComparison.OrdinalIgnoreCase), output);
                    }
                }
        }
Ejemplo n.º 3
0
        public async Task KinitExecutes()
        {
            var port         = NextPort();
            var tmpCacheFile = Path.GetTempFileName();

            try
            {
                using (var listener = StartTcpListener(port))
                {
                    _ = listener.Start();

                    var reader = new CommandLineAutoReader();

                    var io = new InputControl
                    {
                        Clear     = () => { },
                        HookCtrlC = hook => { },
                        Reader    = reader,
                        Writer    = new StringWriter(),
                        ReadKey   = () => ReadKey(reader)
                    };

                    var command = CreateCommand($"127.0.0.1:{port}", AdminAtCorpUserName, tmpCacheFile, io);

                    reader.QueueNext(FakeAdminAtCorpPassword + "\n");

                    await command.Execute();

                    var output = io.Writer.ToString();

                    Assert.IsTrue(output.Contains("Ticket Count: 1"));
                    Assert.IsTrue(output.Contains("[email protected] @ CORP.IDENTITYINTERVENTION.COM"), output);
                }
            }
            finally
            {
                TryCleanupTmp(tmpCacheFile);
            }
        }