Package org.togglz.core.user

Examples of org.togglz.core.user.SimpleFeatureUser


        assertEquals(false, active);
    }

    @Test
    public void shouldReturnTrueForFeatureOnCorrectMachine() {
        FeatureUser user = new SimpleFeatureUser("ea", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE).enable().setStrategyId(ServerIpActivationStrategy.ID);
        state.setParameter(ServerIpActivationStrategy.PARAM_IPS, getMachineIP());
        boolean active = strategy.isActive(state, user);
        assertEquals(true, active);
    }
View Full Code Here


        assertEquals(true, active);
    }

    @Test
    public void shouldReturnFalseForFeatureOnOtherMachine() {
        FeatureUser user = new SimpleFeatureUser("ea", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE).enable().setStrategyId(ServerIpActivationStrategy.ID);
        state.setParameter(ServerIpActivationStrategy.PARAM_IPS, "1.1.1.1");
        boolean active = strategy.isActive(state, user);
        assertEquals(false, active);
    }
View Full Code Here

        assertEquals(false, active);
    }

    @Test
    public void multipleMachineIps() {
        FeatureUser user = new SimpleFeatureUser("ea", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE).enable().setStrategyId(ServerIpActivationStrategy.ID);
        state.setParameter(ServerIpActivationStrategy.PARAM_IPS, "1.1.1.1,2.2.2.2," + getMachineIP());
        boolean active = strategy.isActive(state, user);
        assertEquals(true, active);
    }
View Full Code Here

        // will always return a result
        Subject subject = SecurityUtils.getSubject();

        // only allow authenticated user
        if (subject.isAuthenticated()) {
            return new SimpleFeatureUser(subject.getPrincipal().toString(), subject.hasRole(featureAdminRole));
        }

        // user is not authenticated
        return null;
View Full Code Here

        if (principal != null) {

            boolean featureAdmin = request.isUserInRole(featureAdminRole);

            return new SimpleFeatureUser(principal.getName(), featureAdmin);

        }

        return null;
View Full Code Here

    private final UsernameActivationStrategy strategy = new UsernameActivationStrategy();

    @Test
    public void shouldReturnFalseForEmptyUserlist() {

        FeatureUser user = new SimpleFeatureUser("ck", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE)
            .enable()
            .setStrategyId(UsernameActivationStrategy.ID);

        boolean active = strategy.isActive(state, user);
View Full Code Here

    }

    @Test
    public void shouldReturnFalseForDifferentUser() {

        FeatureUser user = new SimpleFeatureUser("john", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE)
            .enable()
            .setStrategyId(UsernameActivationStrategy.ID)
            .setParameter(UsernameActivationStrategy.PARAM_USERS, "person1,ck,person2");
View Full Code Here

    }

    @Test
    public void shouldReturnTrueForCorrectUser() {

        FeatureUser user = new SimpleFeatureUser("ck", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE)
            .enable()
            .setStrategyId(UsernameActivationStrategy.ID)
            .setParameter(UsernameActivationStrategy.PARAM_USERS, "person1,ck,person2");
View Full Code Here

        // DELETE_USERS disabled for unknown user
        featureUserProvider.setFeatureUser(null);
        assertEquals(false, manager.isActive(MyFeatures.DELETE_USERS));

        // DELETE_USERS enabled for admin user
        featureUserProvider.setFeatureUser(new SimpleFeatureUser("admin", false));
        assertEquals(true, manager.isActive(MyFeatures.DELETE_USERS));

        // DELETE_USERS enabled for other user
        featureUserProvider.setFeatureUser(new SimpleFeatureUser("somebody", false));
        assertEquals(false, manager.isActive(MyFeatures.DELETE_USERS));

        // EXPERIMENTAL disabled for all
        featureUserProvider.setFeatureUser(null);
        assertEquals(false, manager.isActive(MyFeatures.EXPERIMENTAL));
View Full Code Here

    @Test
    public void testShouldHandleEnabledFlagCorrectlyWithCustomStrategy() {

        // enabled for admin
        featureUserProvider.setFeatureUser(new SimpleFeatureUser("admin", false));
        assertEquals(true, manager.isActive(MyFeatures.DELETE_USERS));

        // disable feature, but keep configuration
        FeatureState state = repository.getFeatureState(MyFeatures.DELETE_USERS);
        state.setEnabled(false);
View Full Code Here

TOP

Related Classes of org.togglz.core.user.SimpleFeatureUser

Copyright © 2018 www.massapicom. 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.