Exemplo n.º 1
0
        public void VaultExecutionTest()
        {
            GrimoireScriptBlock script = TestHelper.GetSingleTestScript();

            script.ExtractResult = new PatternRange()
            {
                Start = "", End = ""
            };
            business.SaveScriptBlock(script).Wait();
            GrimoireScriptBlock result = TestHelper.GetCreatedScript(config, "Test_Script.json");

            result.Should().NotBeNull();
            savedVault.Itens = new List <VaultItem>();
            savedVault.Itens.Add(new VaultItem(true, "Key 1", "value 1"));
            savedVault.Itens.Add(new VaultItem(true, "Key 2", "value 2"));
            savedVault.Itens.Add(new VaultItem(true, "Key 3", "value 3"));
            business.LoadVault();
            business.LoadScriptRunners().Wait();
            ScriptResult scriptResult = business.ScriptRunners.First().Run().Result;

            scriptResult.Should().NotBeNull();
            scriptResult.ResultType.Should().Be(ResultType.Success);
            scriptResult.FilteredResult.Should()
            .Contain("Single line multiple keys: value 1 - value 2")
            .And
            .Contain("Single key: value 3");
            savedVault.Itens = new List <VaultItem>();
        }
Exemplo n.º 2
0
        public void SaveScriptBlockTest()
        {
            GrimoireScriptBlock script = TestHelper.GetSingleTestScript();

            business.SaveScriptBlock(script).Wait();
            GrimoireScriptBlock result = TestHelper.GetCreatedScript(config, "Test_Script.json");

            result.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public void SaveScriptTest()
        {
            GrimoireScriptBlock script = TestHelper.GetSingleTestScript();

            service.SaveScriptBlocks(script);
            GrimoireScriptBlock result = TestHelper.GetCreatedScript(config, "Test_Script.json");

            result.Should().NotBeNull();
            TestHelper.CheckCreatedScript(config, result.Name, result.Script).Should().BeTrue();
        }
Exemplo n.º 4
0
        public void RemoveScriptTest()
        {
            GrimoireScriptBlock script = TestHelper.GetSingleTestScript();

            service.SaveScriptBlocks(script);
            GrimoireScriptBlock inserted = TestHelper.GetCreatedScript(config, "Test_Script.json");

            inserted.Should().NotBeNull();
            service.RemoveScriptBlock(inserted.Name);
            GrimoireScriptBlock result = TestHelper.GetCreatedScript(config, "Test_Script.json");

            result.Should().BeNull();
        }
Exemplo n.º 5
0
        public void ScriptExecutionDefaultWarningTest()
        {
            GrimoireScriptBlock script = TestHelper.GetDefaultWarningTestScript();

            business.SaveScriptBlock(script).Wait();
            GrimoireScriptBlock result = TestHelper.GetCreatedScript(config, "Test_Script_Warning.json");

            result.Should().NotBeNull();
            business.LoadScriptRunners().Wait();
            business.LoadVault().Wait();
            ScriptResult scriptResult = business.ScriptRunners.First().Run().Result;

            scriptResult.Should().NotBeNull();
            scriptResult.ResultType.Should().Be(ResultType.Warning);
        }
Exemplo n.º 6
0
        public void ScriptExecutionSoftErrorTest()
        {
            GrimoireScriptBlock script = TestHelper.GetSingleTestScript();

            script.AlertLevel    = AlertLevel.Error;
            script.SuccessPatern = "Soft Error";
            business.SaveScriptBlock(script).Wait();
            GrimoireScriptBlock result = TestHelper.GetCreatedScript(config, "Test_Script.json");

            result.Should().NotBeNull();
            business.LoadScriptRunners().Wait();
            business.LoadVault().Wait();
            ScriptResult scriptResult = business.ScriptRunners.First().Run().Result;

            scriptResult.Should().NotBeNull();
            scriptResult.ResultType.Should().Be(ResultType.Error);
        }
Exemplo n.º 7
0
        public void VerifyKeysTest()
        {
            GrimoireScriptBlock script = TestHelper.GetSingleTestScript();

            business.SaveScriptBlock(script).Wait();
            GrimoireScriptBlock result = TestHelper.GetCreatedScript(config, "Test_Script.json");

            result.Should().NotBeNull();
            business.LoadVault();
            business.VerifyKeys(script).Wait();
            savedVault.Itens.Should().HaveCount(3);
            savedVault.Itens.Should()
            .Contain(item => item.Key.Equals("Key 1"))
            .And
            .Contain(item => item.Key.Equals("Key 2"))
            .And
            .Contain(item => item.Key.Equals("Key 3"));
            savedVault.Itens = new List <VaultItem>();
        }
Exemplo n.º 8
0
        public void ScriptExecutionSuccessTest()
        {
            GrimoireScriptBlock script = TestHelper.GetSingleTestScript();

            business.SaveScriptBlock(script).Wait();
            GrimoireScriptBlock result = TestHelper.GetCreatedScript(config, "Test_Script.json");

            result.Should().NotBeNull();
            business.LoadScriptRunners().Wait();
            business.LoadVault().Wait();
            ScriptResult scriptResult = business.ScriptRunners.First().Run().Result;

            scriptResult.Should().NotBeNull();
            scriptResult.ResultType.Should().Be(ResultType.Success);
            scriptResult.FilteredResult.Should()
            .Contain("Result 1")
            .And
            .Contain("Result 2")
            .And
            .Contain("Result 3")
            .And
            .Contain("Result 4");
        }