Beispiel #1
0
        public void CanTestParams()
        {
            OptionalParameters op = new OptionalParameters();

            // Optimization
            op.RenameLocal = RenameLocal.Enabled;

            // Other
            op.NamePrefix = "my_";
            op.IgnoreFiles.AddRange(new List <string>()
            {
                "file1.js", "file2.js"
            });
            op.ExceptionsList.AddRange(new List <string>()
            {
                "test", "equal"
            });
            op.AssertsElimination.AddRange(new List <string>()
            {
                "test", "equal"
            });
            op.DebuggingCodeElimination.AddRange(new List <string>()
            {
                "DEBUG_FUNC_A", "DEBUG_FUNC_B"
            });

            var parameters = op.GetParameters();

            Assert.NotNull(op);
        }
Beispiel #2
0
        public void CanDownloadProject()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List <string>()
                {
                    "test.html", "test.js"
                },
                DomainLock     = "example.com",
                ExpirationDate = DateTime.Now.AddDays(20)
            };

            OptionalParameters op = new OptionalParameters();

            op.DeadCode = DeadCode.Enabled;
            op.DictionaryCompression  = DictionaryCompression.Enabled;
            op.RenameAll              = RenameAll.Enabled;
            op.FunctionOutlining      = FunctionOutlining.Enabled;
            op.DotNotationElimination = DotNotationElimination.Enabled;
            op.DictionaryCompression  = DictionaryCompression.Enabled;
            op.FunctionReorder        = FunctionReorder.Enabled;

            var uploadResponse = jscrambler.UploadCode(uploadRequest, op.GetParameters());

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);

            var  retries    = 5;
            bool downloaded = false;

            while (retries > 0)
            {
                Thread.Sleep(5 * 1000);
                downloaded = jscrambler.DownloadProject(uploadResponse.Id);
                retries--;

                if (downloaded)
                {
                    break;
                }
            }

            Assert.True(downloaded);
        }
Beispiel #3
0
        public void CanUpload_DotNotationElimination()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List <string>()
                {
                    "test.html", "test.js", "Scripts\\app\\app.js"
                },
            };

            OptionalParameters op = new OptionalParameters();

            op.DotNotationElimination = DotNotationElimination.Enabled;

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
Beispiel #4
0
        public void CanUpload_NamePrefix()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List <string>()
                {
                    "test.html", "test.js", "Scripts\\app\\app.js"
                },
            };

            OptionalParameters op = new OptionalParameters();

            op.NamePrefix = "prefix_";

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
        public void CanDownloadProject()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List<string>() { "test.html", "test.js" },
                DomainLock = "example.com",
                ExpirationDate = DateTime.Now.AddDays(20)
            };

            OptionalParameters op = new OptionalParameters();
            op.DeadCode = DeadCode.Enabled;
            op.DictionaryCompression = DictionaryCompression.Enabled;
            op.RenameAll = RenameAll.Enabled;
            op.FunctionOutlining = FunctionOutlining.Enabled;
            op.DotNotationElimination = DotNotationElimination.Enabled;
            op.DictionaryCompression = DictionaryCompression.Enabled;
            op.FunctionReorder = FunctionReorder.Enabled;

            var uploadResponse = jscrambler.UploadCode(uploadRequest, op.GetParameters());

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);

            var retries = 5;
            bool downloaded = false;

            while (retries > 0)
            {
                Thread.Sleep(5 * 1000);
                downloaded = jscrambler.DownloadProject(uploadResponse.Id);
                retries--;

                if (downloaded)
                {
                    break;
                }
            }

            Assert.True(downloaded);
        }
Beispiel #6
0
        public void CanUpload_DebuggingCodeElimination_Multiple()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List <string>()
                {
                    "test.html", "test.js", "Scripts\\app\\app.js"
                },
            };

            OptionalParameters op = new OptionalParameters();

            op.DebuggingCodeElimination.Add("DEBUG");
            op.DebuggingCodeElimination.Add("DEBUG_FUNC_A");

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
Beispiel #7
0
        public void CanUpload_LiteralHooking()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List <string>()
                {
                    "test.html", "test.js", "Scripts\\app\\app.js"
                },
            };

            OptionalParameters op = new OptionalParameters();

            op.LiteralHooking           = LiteralHooking.Custom;
            op.LiteralHookingPredicates = new LiteralHookingPredicates(1, 2, .8);

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
Beispiel #8
0
        public void CanUpload_AssertsElimination_Multiple()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List <string>()
                {
                    "test.html", "test.js", "Scripts\\app\\app.js"
                },
            };

            OptionalParameters op = new OptionalParameters();

            op.AssertsElimination.AddRange(new List <string>()
            {
                "test", "assertTrue", "equal"
            });

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
        public void CanUpload_Whitespace()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List<string>() { "test.html", "test.js", "Scripts\\app\\app.js" },
            };

            OptionalParameters op = new OptionalParameters();
            op.WhitespaceRemoval = WhitespaceRemoval.Enabled;

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
        public void CanUpload_LiteralHooking()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List<string>() { "test.html", "test.js", "Scripts\\app\\app.js" },
            };

            OptionalParameters op = new OptionalParameters();
            op.LiteralHooking = LiteralHooking.Custom;
            op.LiteralHookingPredicates = new LiteralHookingPredicates(1, 2, .8);

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
        public void CanUpload_DebuggingCodeElimination_Multiple()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List<string>() { "test.html", "test.js", "Scripts\\app\\app.js" },
            };

            OptionalParameters op = new OptionalParameters();
            op.DebuggingCodeElimination.Add("DEBUG");
            op.DebuggingCodeElimination.Add("DEBUG_FUNC_A");

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
        public void CanUpload_AssertsElimination_Multiple()
        {
            var uploadRequest = new UploadCodeRequest()
            {
                Files = new List<string>() { "test.html", "test.js", "Scripts\\app\\app.js" },
            };

            OptionalParameters op = new OptionalParameters();
            op.AssertsElimination.AddRange(new List<string>() { "test", "assertTrue", "equal" });

            var parameters = op.GetParameters();

            var uploadResponse = jscrambler.UploadCode(uploadRequest, parameters);

            Assert.NotNull(uploadResponse);
            Assert.IsNotNullOrEmpty(uploadResponse.Id);
        }
        public void CanTestParams()
        {
            OptionalParameters op = new OptionalParameters();

            // Optimization
            op.RenameLocal = RenameLocal.Enabled;

            // Other
            op.NamePrefix = "my_";
            op.IgnoreFiles.AddRange(new List<string>() { "file1.js", "file2.js" });
            op.ExceptionsList.AddRange(new List<string>() { "test", "equal" });
            op.AssertsElimination.AddRange(new List<string>() { "test", "equal" });
            op.DebuggingCodeElimination.AddRange(new List<string>() { "DEBUG_FUNC_A", "DEBUG_FUNC_B" });

            var parameters = op.GetParameters();

            Assert.NotNull(op);
        }