Exemplo n.º 1
0
        public void WebGetIfNotExist_Local()
        {
            string tempSrc  = CommandHashTests.SampleText();
            string tempDest = Path.GetTempFileName();

            try
            {
                Uri         fileUri = new Uri(tempSrc);
                string      rawCode = $"WebGetIfNotExist,\"{fileUri.AbsoluteUri}\",\"{tempDest}\"";
                EngineState s       = EngineTests.Eval(rawCode, CodeType.WebGetIfNotExist, ErrorCheck.Warning);

                // WebGet should have been ignored
                FileInfo info = new FileInfo(tempDest);
                Assert.IsTrue(info.Length == 0);
            }
            finally
            {
                if (File.Exists(tempSrc))
                {
                    File.Delete(tempSrc);
                }
                if (File.Exists(tempDest))
                {
                    File.Delete(tempDest);
                }
            }
        }
Exemplo n.º 2
0
        public void WebGet_MD5(EngineState s)
        {
            string tempSrc  = CommandHashTests.SampleText();
            string tempDest = Path.GetTempFileName();

            File.Delete(tempDest);

            try
            {
                Uri    fileUri = new Uri(tempSrc);
                string rawCode = $"WebGet,\"{fileUri.AbsoluteUri}\",\"{tempDest}\",MD5,1179cf94187d2d2f94010a8d39099543";
                EngineTests.Eval(s, rawCode, CodeType.WebGet, ErrorCheck.Success);

                Assert.IsTrue(File.Exists(tempSrc));
            }
            finally
            {
                if (File.Exists(tempSrc))
                {
                    File.Delete(tempSrc);
                }
                if (File.Exists(tempDest))
                {
                    File.Delete(tempDest);
                }
            }
        }
Exemplo n.º 3
0
        public void WebGet_HashError(EngineState s)
        {
            string tempSrc  = CommandHashTests.SampleText();
            string tempDest = Path.GetTempFileName();

            File.Delete(tempDest);

            try
            {
                Uri    fileUri = new Uri(tempSrc);
                string rawCode = $"WebGet,\"{fileUri.AbsoluteUri}\",\"{tempDest}\",MD5,00000000000000000000000000000000";
                EngineTests.Eval(s, rawCode, CodeType.WebGet, ErrorCheck.Error);
            }
            finally
            {
                if (File.Exists(tempSrc))
                {
                    File.Delete(tempSrc);
                }
                if (File.Exists(tempDest))
                {
                    File.Delete(tempDest);
                }
            }
        }
Exemplo n.º 4
0
        public void WebGet_SHA512(EngineState s)
        {
            string tempSrc  = CommandHashTests.SampleText();
            string tempDest = Path.GetTempFileName();

            File.Delete(tempDest);

            try
            {
                Uri    fileUri = new Uri(tempSrc);
                string rawCode = $"WebGet,\"{fileUri.AbsoluteUri}\",\"{tempDest}\",SHA512,f5829cb5e052ab5ef6820630fd992acabb798512d21b5c5295fb81b88b74f3812863c0804e730f26e166b51d77eb5f1de200fd75913278522da78fbb269600cc";
                EngineTests.Eval(s, rawCode, CodeType.WebGet, ErrorCheck.Success);

                Assert.IsTrue(File.Exists(tempDest));
            }
            finally
            {
                if (File.Exists(tempSrc))
                {
                    File.Delete(tempSrc);
                }
                if (File.Exists(tempDest))
                {
                    File.Delete(tempDest);
                }
            }
        }
Exemplo n.º 5
0
        public void WebGet_SHA384(EngineState s)
        {
            string tempSrc  = CommandHashTests.SampleText();
            string tempDest = Path.GetTempFileName();

            File.Delete(tempDest);

            try
            {
                Uri    fileUri = new Uri(tempSrc);
                string rawCode = $"WebGet,\"{fileUri.AbsoluteUri}\",\"{tempDest}\",SHA384,e068a3ac0b4ab4b37306dc354af6b8a4c89ef3fbbf1db969ec6d6a4281f1ab1f472fcd7bc2f16c0cf41c1991056846a6";
                EngineTests.Eval(s, rawCode, CodeType.WebGet, ErrorCheck.Success);

                Assert.IsTrue(File.Exists(tempDest));
            }
            finally
            {
                if (File.Exists(tempSrc))
                {
                    File.Delete(tempSrc);
                }
                if (File.Exists(tempDest))
                {
                    File.Delete(tempDest);
                }
            }
        }
Exemplo n.º 6
0
        public void WebGet_SHA256(EngineState s)
        {
            string tempSrc  = CommandHashTests.SampleText();
            string tempDest = Path.GetTempFileName();

            File.Delete(tempDest);

            try
            {
                Uri    fileUri = new Uri(tempSrc);
                string rawCode = $"WebGet,\"{fileUri.AbsoluteUri}\",\"{tempDest}\",SHA256,3596bc5a263736c9d5b9a06e85a66ed2a866b457a44e5ed8548e504ca5599772";
                EngineTests.Eval(s, rawCode, CodeType.WebGet, ErrorCheck.Success);

                Assert.IsTrue(File.Exists(tempDest));
            }
            finally
            {
                if (File.Exists(tempSrc))
                {
                    File.Delete(tempSrc);
                }
                if (File.Exists(tempDest))
                {
                    File.Delete(tempDest);
                }
            }
        }
Exemplo n.º 7
0
        public void WebGet_SHA1(EngineState s)
        {
            string tempSrc  = CommandHashTests.SampleText();
            string tempDest = Path.GetTempFileName();

            File.Delete(tempDest);

            try
            {
                Uri    fileUri = new Uri(tempSrc);
                string rawCode = $"WebGet,\"{fileUri.AbsoluteUri}\",\"{tempDest}\",SHA1,0aaac8883f1c8dd48dbf974299a9422f1ab437ee";
                EngineTests.Eval(s, rawCode, CodeType.WebGet, ErrorCheck.Success);

                Assert.IsTrue(File.Exists(tempDest));
            }
            finally
            {
                if (File.Exists(tempSrc))
                {
                    File.Delete(tempSrc);
                }
                if (File.Exists(tempDest))
                {
                    File.Delete(tempDest);
                }
            }
        }
Exemplo n.º 8
0
        public void Hash_SHA384()
        { // Hash,<HashType>,<FilePath>,<DestVar>
            string tempFile = CommandHashTests.SampleText();

            string      rawCode = $"Hash,SHA384,{tempFile},%Dest%";
            EngineState s       = EngineTests.Eval(rawCode, CodeType.Hash, ErrorCheck.Success);

            string dest = s.Variables["Dest"];
            string comp = "e068a3ac0b4ab4b37306dc354af6b8a4c89ef3fbbf1db969ec6d6a4281f1ab1f472fcd7bc2f16c0cf41c1991056846a6";

            Assert.IsTrue(dest.Equals(comp, StringComparison.Ordinal));

            File.Delete(tempFile);
        }
Exemplo n.º 9
0
        public void Hash_SHA256()
        { // Hash,<HashType>,<FilePath>,<DestVar>
            string tempFile = CommandHashTests.SampleText();

            string      rawCode = $"Hash,SHA256,{tempFile},%Dest%";
            EngineState s       = EngineTests.Eval(rawCode, CodeType.Hash, ErrorCheck.Success);

            string dest = s.Variables["Dest"];
            string comp = "3596bc5a263736c9d5b9a06e85a66ed2a866b457a44e5ed8548e504ca5599772";

            Assert.IsTrue(dest.Equals(comp, StringComparison.Ordinal));

            File.Delete(tempFile);
        }
Exemplo n.º 10
0
        public void Hash_SHA1()
        { // Hash,<HashType>,<FilePath>,<DestVar>
            string tempFile = CommandHashTests.SampleText();

            string      rawCode = $"Hash,SHA1,{tempFile},%Dest%";
            EngineState s       = EngineTests.Eval(rawCode, CodeType.Hash, ErrorCheck.Success);

            string dest = s.Variables["Dest"];
            string comp = "0aaac8883f1c8dd48dbf974299a9422f1ab437ee";

            Assert.IsTrue(dest.Equals(comp, StringComparison.Ordinal));

            File.Delete(tempFile);
        }
Exemplo n.º 11
0
        public void Hash_MD5()
        { // Hash,<HashType>,<FilePath>,<DestVar>
            string tempFile = CommandHashTests.SampleText();

            string      rawCode = $"Hash,MD5,{tempFile},%Dest%";
            EngineState s       = EngineTests.Eval(rawCode, CodeType.Hash, ErrorCheck.Success);

            string dest = s.Variables["Dest"];
            string comp = "1179cf94187d2d2f94010a8d39099543";

            Assert.IsTrue(dest.Equals(comp, StringComparison.Ordinal));

            File.Delete(tempFile);
        }
Exemplo n.º 12
0
        public void Hash_SHA512()
        { // Hash,<HashType>,<FilePath>,<DestVar>
            string tempFile = CommandHashTests.SampleText();

            string      rawCode = $"Hash,SHA512,{tempFile},%Dest%";
            EngineState s       = EngineTests.Eval(rawCode, CodeType.Hash, ErrorCheck.Success);

            string dest = s.Variables["Dest"];
            string comp = "f5829cb5e052ab5ef6820630fd992acabb798512d21b5c5295fb81b88b74f3812863c0804e730f26e166b51d77eb5f1de200fd75913278522da78fbb269600cc";

            Assert.IsTrue(dest.Equals(comp, StringComparison.Ordinal));

            File.Delete(tempFile);
        }