Beispiel #1
0
        static void Main(string[] p_Args)
        {
            RuntimeParameters runtimeParameters = new RuntimeParameters();

            var optionSet = new OptionSet {
                { "d|directory-path=", "Absolute path to the repository to update.", value => runtimeParameters.DirectoryPath = value },
                { "u|hosting-username="******"Username used with the hosting platform.", value => runtimeParameters.Username = value },
                { "p|hosting-password="******"Password used with the hosting platform.", value => runtimeParameters.Password = value },
                { "h|help", "Show this message", value => runtimeParameters.Help = value != null }
            };

            try {
                optionSet.Parse(p_Args);
            } catch (OptionException e) {
                s_Logger.Error(e.Message);
                s_Logger.Info("Try `--help` for more information.");
                return;
            }

            if (runtimeParameters.Help)
            {
                ShowHelp(optionSet);
                return;
            }

            if (!runtimeParameters.Validate())
            {
                s_Logger.Error("Invalid arguments.");
                s_Logger.Info("Try `--help` for more information.");
                return;
            }

            Run(runtimeParameters);
        }
        public void MaliciousRuntimeParametersAreDenied()
        {
            RuntimeParameters maliciousConfig = new RuntimeParameters {
                DirectoryPath = "rm -rf",
                Username      = "******",
                Password      = "******"
            };

            Assert.False(maliciousConfig.Validate());
        }
Beispiel #3
0
        public void MissingRuntimeParametersAreDetected()
        {
            var missingPassword = new RuntimeParameters {
                DirectoryPath = "/bin/bash", Username = "******"
            };
            var missingPath = new RuntimeParameters {
                Username = "******", Password = "******"
            };
            var missingUser = new RuntimeParameters {
                DirectoryPath = "/bin/bash", Password = "******"
            };

            Assert.False(missingPassword.Validate());
            Assert.False(missingPath.Validate());
            Assert.False(missingUser.Validate());
        }