Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBlockWithWhiteListingForProcedures()
        public virtual void ShouldBlockWithWhiteListingForProcedures()
        {
            Config          config     = Config.defaults(stringMap(procedure_unrestricted.name(), "test.procedure.name, test.procedure.name2", procedure_whitelist.name(), "test.procedure.name"));
            ProcedureConfig procConfig = new ProcedureConfig(config);

            assertThat(procConfig.IsWhitelisted("xyzabc"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("test.procedure.name"), equalTo(true));
            assertThat(procConfig.IsWhitelisted("test.procedure.name2"), equalTo(false));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIgnoreOddRegex()
        public virtual void ShouldIgnoreOddRegex()
        {
            Config          config     = Config.defaults(procedure_whitelist, "[\\db^a]*");
            ProcedureConfig procConfig = new ProcedureConfig(config);

            assertThat(procConfig.IsWhitelisted("123"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("b"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("a"), equalTo(false));

            config     = Config.defaults(procedure_whitelist, "(abc)");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("(abc)"), equalTo(true));

            config     = Config.defaults(procedure_whitelist, "^$");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("^$"), equalTo(true));

            config     = Config.defaults(procedure_whitelist, "\\");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("\\"), equalTo(true));

            config     = Config.defaults(procedure_whitelist, "&&");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("&&"), equalTo(true));

            config     = Config.defaults(procedure_whitelist, "\\p{Lower}");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("a"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("\\p{Lower}"), equalTo(true));

            config     = Config.defaults(procedure_whitelist, "a+");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("aaaaaa"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("a+"), equalTo(true));

            config     = Config.defaults(procedure_whitelist, "a|b");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("a"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("b"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("|"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("a|b"), equalTo(true));

            config     = Config.defaults(procedure_whitelist, "[a-c]");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("a"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("b"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("c"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("-"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("[a-c]"), equalTo(true));

            config     = Config.defaults(procedure_whitelist, "a\tb");
            procConfig = new ProcedureConfig(config);
            assertThat(procConfig.IsWhitelisted("a    b"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("a\tb"), equalTo(true));
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowWhiteListsWildcardProceduresNames()
        public virtual void ShouldAllowWhiteListsWildcardProceduresNames()
        {
            Config          config     = Config.defaults(procedure_whitelist, " test.procedure.* ,  test.*.otherName");
            ProcedureConfig procConfig = new ProcedureConfig(config);

            assertThat(procConfig.IsWhitelisted("xyzabc"), equalTo(false));
            assertThat(procConfig.IsWhitelisted("test.procedure.name"), equalTo(true));
            assertThat(procConfig.IsWhitelisted("test.procedure.otherName"), equalTo(true));
            assertThat(procConfig.IsWhitelisted("test.other.otherName"), equalTo(true));
            assertThat(procConfig.IsWhitelisted("test.other.cool.otherName"), equalTo(true));
            assertThat(procConfig.IsWhitelisted("test.other.name"), equalTo(false));
        }