Examples of FeatureUser


Examples of org.togglz.core.user.FeatureUser

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        FeatureManager featureManager = FeatureContext.getFeatureManager();
        FeatureUser user = featureManager.getCurrentFeatureUser();

        StringBuilder builder = new StringBuilder();
        builder.append("USER = " + (user != null ? user.getName() : "null"));
        builder.append("ADMIN = " + (user != null ? user.isFeatureAdmin() : "null"));

        resp.getOutputStream().write(builder.toString().getBytes());

    }
View Full Code Here

Examples of org.togglz.core.user.FeatureUser

    }

    @Test
    public void userIsNotLoggedIn() {
        helper.setEnvIsLoggedIn(false);
        FeatureUser user = userProvider.getCurrentUser();
        assertNull(user);
    }
View Full Code Here

Examples of org.togglz.core.user.FeatureUser

        helper.setEnvIsLoggedIn(true)
            .setEnvEmail("user@togglz.org")
            .setEnvAuthDomain("togglz.org");

        UserService userService = UserServiceFactory.getUserService();
        FeatureUser user = userProvider.getCurrentUser();
        assertFalse(user.isFeatureAdmin());
        assertEquals(userService.getCurrentUser().getUserId(), user.getName());
        assertEquals(userService.getCurrentUser().getEmail(), user.getAttribute("email"));
        assertEquals(userService.getCurrentUser().getNickname(), user.getAttribute("nickname"));
    }
View Full Code Here

Examples of org.togglz.core.user.FeatureUser

            String strategyId = state.getStrategyId();
            if (strategyId == null) {
                return true;
            }

            FeatureUser user = userProvider.getCurrentUser();

            // check the selected strategy
            for (ActivationStrategy strategy : strategyProvider.getActivationStrategies()) {
                if (strategy.getId().equalsIgnoreCase(strategyId)) {
                    return strategy.isActive(state, user);
View Full Code Here

Examples of org.togglz.core.user.FeatureUser

        authorities.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
        authorities.add(new SimpleGrantedAuthority("ROLE_2"));
        when(authentication.getAuthorities()).thenReturn(authorities);

        // act
        FeatureUser user = userProvider.getCurrentUser();

        // assert
        assertThat(user.isFeatureAdmin(), is(true));
    }
View Full Code Here

Examples of org.togglz.core.user.FeatureUser

        authorities.add(new SimpleGrantedAuthority("ROLE_1"));
        authorities.add(new SimpleGrantedAuthority("ROLE_2"));
        when(authentication.getAuthorities()).thenReturn(authorities);

        // act
        FeatureUser user = userProvider.getCurrentUser();

        // assert
        assertThat(user.isFeatureAdmin(), is(false));
    }
View Full Code Here

Examples of org.togglz.core.user.FeatureUser

        authorities.add(new SimpleGrantedAuthority("ROLE_1"));
        authorities.add(new SimpleGrantedAuthority("ROLE_2"));
        when(authentication.getAuthorities()).thenReturn(authorities);

        // act
        FeatureUser user = userProvider.getCurrentUser();

        // assert
        Object authoritiesAttr = user.getAttribute(USER_ATTRIBUTE_ROLES);

        assertThat(authoritiesAttr, notNullValue());
        assertThat(authoritiesAttr, is(Set.class));

        Set<String> authoritySet = (Set<String>) authoritiesAttr;
View Full Code Here

Examples of org.togglz.core.user.FeatureUser

    private final ServerIpActivationStrategy strategy = new ServerIpActivationStrategy();

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

Examples of org.togglz.core.user.FeatureUser

        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

Examples of org.togglz.core.user.FeatureUser

        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
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.