Package webit.script.security

Source Code of webit.script.security.DefaultNativeSecurityManagerTest

// Copyright (c) 2013-2014, Webit Team. All Rights Reserved.
package webit.script.security;

import static org.junit.Assert.*;
import org.junit.Test;
import webit.script.EngineManager;
import webit.script.security.impl.DefaultNativeSecurityManager;

/**
*
* @author Zqq
*/
public class DefaultNativeSecurityManagerTest {

    @Test
    public void test() {

        String list = "-a"
                + ",a"
                + ",+b"
                + "\r\n-b"
                + ", c"
                + "\r-c.d "
                + ", c.d.e.f"
                + ",-c.d.e.f.g";

        DefaultNativeSecurityManager manager = new DefaultNativeSecurityManager();

        manager.setList(list);
        manager.init(EngineManager.getEngine());

        assertFalse(manager.access("a"));
        assertFalse(manager.access("a.aa"));
        assertFalse(manager.access("a.aa.aaa"));
       
        assertFalse(manager.access("b"));
        assertFalse(manager.access("b.b"));
        assertFalse(manager.access("b.c"));
       
        assertTrue(manager.access("c"));
        assertTrue(manager.access("c.cc"));
        assertTrue(manager.access("c.cc.ccc"));
        assertFalse(manager.access("c.d"));
        assertFalse(manager.access("c.d.e"));
        assertTrue(manager.access("c.d.e.f"));
        assertFalse(manager.access("c.d.e.f.g"));
        assertFalse(manager.access("c.d.e.f.g.h"));

    }
}
TOP

Related Classes of webit.script.security.DefaultNativeSecurityManagerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.