public void OnDependencyDetectorUrl_IsDependency()
        {
            var dep = new DependencyDetector();

            Assert.IsTrue(dep.IsDependency("http://localhost:59635/api/UserCrud/${call1.response}"));
            Assert.IsTrue(dep.IsDependency("http://localhost:59635/api/UserCrud/${call2.request}/resource"));
        }
        public void OnDependencyDetector_GetDependencyNameFromUrl()
        {
            var dep = new DependencyDetector();

            Assert.AreEqual("call1", dep.GetDependencyName("http://localhost:59635/api/UserCrud/${call1.response}"));
            Assert.AreEqual("call2", dep.GetDependencyName("http://localhost:59635/api/UserCrud/${call2.request}/resource"));
        }
 public JsonObjectDependecyReplacer(
     DependencyDetector dependencyDetector,
     Dictionary <string, Task <TestResult> > dict)
 {
     _dependencyDetector = dependencyDetector;
     _dict = dict;
 }
예제 #4
0
 public ReplaceDependencyUrl(
     DependencyDetector dependencyDetector,
     Dictionary <string, Task <TestResult> > dict)
 {
     _dependencyDetector = dependencyDetector;
     _dict = dict;
 }
예제 #5
0
 public ReplaceDependencyQueryString(
     DependencyDetector dependencyDetector,
     Dictionary <string, Task <TestResult> > dict)
 {
     _dependencyDetector = dependencyDetector;
     _dict = dict;
     _jsonObjectDependecyReplacer = new JsonObjectDependecyReplacer(_dependencyDetector, _dict);
 }
        public void OnDependencyDetector_IsDependency()
        {
            var dep = new DependencyDetector();

            Assert.IsTrue(dep.IsDependency("${call1.response}"));
            Assert.IsTrue(dep.IsDependency("${call2.request}"));
            Assert.IsFalse(dep.IsDependency("${ANY}"));
            Assert.IsFalse(dep.IsDependency("${NUMBER}"));
        }
예제 #7
0
        static void Main(string[] args)
        {
            try
            {
                var logger = new ConsoleLogger();


                var options = new Options();
                var res     = CommandLine.Parser.Default.ParseArguments(args, options);

                logger.Info("Starting dependency detection");

                _dumpOptions(logger, options);

                // See #4, even a start without params should provide the minimum configuration setup, which is config and dependency walker
                var config = _readConfig(options.Config);

                var pathOfDependsRoot = _getDependencyWalkerIfMissing(logger, options.ProxyUser, options.ProxyPassword);


                if (res == false)
                {
                    Environment.Exit(1);
                }

                var dd = new DependencyDetector(pathOfDependsRoot);

                IDependencyProvider dependencyProvider = _getDependencyProvider(options);


                var p = new ProcessPipeline(logger, dd, dependencyProvider);

                ;

                // Fail fast: Check if configuration is available
                config.GetConfigurationSet(options.ConfigurationSetName ?? Config.DefaultSetName);

                p.ExecutePipeline(options, config);

                logger.Info("Dependency detection finished");
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
        public void Setup()
        {
            _dependsRoot    = Path.Combine(TestDataExtracted, "Depends");
            _dependencyRoot = Path.Combine(TestDataExtracted, "x64");

            _defaultConfig = Config.CreateDefaultConfig();
            _defaultConfig.HowManyIterations = 2; // Manually control sweeps, always at least 2 required

            // Create scenarios where executable is missing a dependency
            DirectoryOfExeWithMissingDep = Path.Combine(TestDataOwn, "only_exe");


            _defaultOptions = new Options {
                InputDirectory = DirectoryOfExeWithMissingDep, RecurseInput = false, Config = "config.json", DependencyDirectory = _dependencyRoot
            };

            TearDown();

            // DepA
            {
                DirectoryOfDepAMissingDepB = Path.Combine(TestDataOwn, "depA");
                CreateDir(DirectoryOfDepAMissingDepB);
                File.Copy(GetExtractedFiles("x64", "*A.dll").First(), Path.Combine(DirectoryOfDepAMissingDepB, "dlla.dll"));
            }


            CreateDir(DirectoryOfExeWithMissingDep);

            var file = GetExtractedFiles("x64", "*.exe").First();

            File.Copy(file, Path.Combine(DirectoryOfExeWithMissingDep, "executable.exe"));

            // Create nested executable
            {
                var nestedDir = Path.Combine(DirectoryOfExeWithMissingDep, "inner");
                CreateDir(nestedDir);
                File.Copy(file, Path.Combine(nestedDir, "executable.exe"));
            }


            var mock = NSubstitute.Substitute.For <ILogger>();

            var dd = new DependencyDetector(_dependsRoot);

            _pipeline = new ProcessPipeline(mock, dd, new FileCopyDependencyProvider());
        }
        public void OnEvaluateDependency()
        {
            var dep        = new DependencyDetector();
            var jsonReader = new JsonReader.JsonReaderBody();

            var testResult = new Entity.Test.TestResult("call1",
                                                        new Validation(),
                                                        new Response(200, jsonReader.Read("{ id: 1314, name: \"Robson\", childrens: { name: \"Cleyton\", age: 14 } }"),
                                                                     new Cookies(),
                                                                     new Header()));

            Assert.AreEqual("1314", dep.Evaluate("${call1.response.body.id}", testResult));
            Assert.AreEqual("Robson", dep.Evaluate("${call1.response.body.name}", testResult));

            Assert.AreEqual("Cleyton", dep.Evaluate("${call1.response.body.childrens.name}", testResult));
            Assert.AreEqual("14", dep.Evaluate("${call1.response.body.childrens.age}", testResult));
        }
예제 #10
0
        public void OnDependencyDetector_GetDependencyName()
        {
            var dep = new DependencyDetector();

            Assert.AreEqual("call1", dep.GetDependencyName("${call1.response}"));
            Assert.AreEqual("call2", dep.GetDependencyName("${call2.response}"));

            try
            {
                // throw exception on not recognized a dependency
                dep.GetDependencyName("${ANY}");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("value is not a dependency", ex.Message);
                return;
            }
            Assert.Fail();
        }
 public void SetUpOnce()
 {
     detector = new DependencyDetector(Path.Combine(TestDataExtracted, "Depends"));
 }