cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhaisaab <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-8562: Dynamic Role-Based API C...
Date Fri, 15 Apr 2016 10:50:54 GMT
Github user bhaisaab commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1489#discussion_r59857842
  
    --- Diff: api/test/org/apache/cloudstack/acl/RuleTest.java ---
    @@ -0,0 +1,39 @@
    +package org.apache.cloudstack.acl;
    +
    +import com.cloud.exception.InvalidParameterValueException;
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +import java.util.Arrays;
    +
    +public class RuleTest {
    +
    +    @Test
    +    public void testToString() throws Exception {
    +        Rule rule = new Rule("someString");
    +        Assert.assertEquals(rule.toString(), "someString");
    +    }
    +
    +    @Test
    +    public void testValidateRuleWithValidData() throws Exception {
    +        for (String rule : Arrays.asList("a", "1", "someApi", "someApi321", "123SomeApi",
    +                "prefix*", "*middle*", "*Suffix",
    +                "*", "**", "f***", "m0nk3yMa**g1c*")) {
    +            Assert.assertTrue(Rule.validate(rule));
    +            Assert.assertEquals(new Rule(rule).toString(), rule);
    +        }
    +    }
    +
    +    @Test
    +    public void testValidateRuleWithInvalidData() throws Exception {
    +        for (String rule : Arrays.asList(null, "", " ", "  ", "\n", "\t", "\r", "\"",
"\'",
    +                "^someApi$", "^someApi", "some$", "some-Api;", "some,Api",
    +                "^", "$", "^$", ".*", "\\w+", "r**l3rd0@Kr3", "j@s1n|+|0ȷ",
    +                "[a-z0-9-]+", "^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$"))
{
    +            try {
    +                new Rule(rule);
    +                Assert.fail("Invalid rule, exception was expected");
    +            } catch (InvalidParameterValueException ignored) {}
    +        }
    --- End diff --
    
    It's in a for loop, so won't do


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message