private boolean allFeaturesAreEnabled(String[] featureKeys) { for (String featureKey : featureKeys) { if (!darkFeatureManager.isFeatureEnabledForCurrentUser(featureKey)) { return false; } } return true; } }
/** * Returns true if legacy XSRF mode is active, otherwise returns false. * * @since 3.0.0 * @deprecated Only provided for legacy reasons, will be removed in 4.0.0 */ @VisibleForTesting @Deprecated boolean inLegacyXsrfMode() { return darkFeatureManager.isFeatureEnabledForAllUsers(LEGACY_FEATURE_KEY); }
@Test public void changeFeatureForAuthenticatedUser() { try { darkFeatureManager.enableFeatureForUser(adminUser(), ADMIN_USER_FEATURE); } catch (UnsupportedOperationException e) { ignoreTest(); } assertTrue("Feature key '" + ADMIN_USER_FEATURE + "' must be enabled for the admin user", darkFeatureManager.isFeatureEnabledForUser(adminUser(), ADMIN_USER_FEATURE)); assertFalse("Feature key '" + ADMIN_USER_FEATURE + "' must be disabled for all users", darkFeatureManager.isFeatureEnabledForAllUsers(ADMIN_USER_FEATURE)); darkFeatureManager.disableFeatureForUser(adminUser(), ADMIN_USER_FEATURE); assertFalse("Feature key '" + ADMIN_USER_FEATURE + "' must be disabled for the admin user", darkFeatureManager.isFeatureEnabledForUser(adminUser(), ADMIN_USER_FEATURE)); }
public boolean hasPermission(final UserKey userKey) { // Allow the sysadmin condition to be bypassed by a dark feature // This enables us to use the event reporter when sysadmin permissions may not be accessible, e.g. in OnDemand instances return userPermissionsHelper.isUserSystemAdmin(userKey) || darkFeatureManager.isFeatureEnabledForUser(userKey, DARK_FEATURE_KEY); } }
@After public void disableAdminFeature() throws Exception { if (darkFeatureManager.isFeatureEnabledForUser(adminUser(), ADMIN_USER_FEATURE)) { darkFeatureManager.disableFeatureForUser(adminUser(), ADMIN_USER_FEATURE); } }
private void enableFeature(@Nonnull ApplinksFeatures feature) { darkFeatureManager.enableFeatureForAllUsers(feature.featureKey); }
private void disableFeature(@Nonnull ApplinksFeatures feature) { darkFeatureManager.disableFeatureForAllUsers(feature.featureKey); }
@Test public void systemFeatureEnabledForAnonymous() { assertFeatureEnabled(darkFeatureManager.isFeatureEnabledForUser(ANONYMOUS, ENABLED_FEATURE)); }
@Test(expected = InvalidFeatureKeyException.class) public void invalidFeatureKeyNotEnabledForAllUsers() { darkFeatureManager.enableFeatureForAllUsers(INVALID_FEATURE_KEY); }
@Test(expected = InvalidFeatureKeyException.class) public void invalidFeatureKeyNotDisabledForAllUsers() { darkFeatureManager.disableFeatureForAllUsers(INVALID_FEATURE_KEY); }
@Override public boolean isInviteToHipChatEnabled() { return !darkFeatureManager.isFeatureEnabledForAllUsers(HIPCHAT_INVITE_DISABLED); } }
@Override public boolean isEnabled() { return this.darkFeatureManager.isFeatureEnabledForCurrentUser(DARK_FEATURE_PROGRAMMATIC_ANALYTICS); } }
@Test public void systemFeatureDisabledForAnonymous() { assertFeatureDisabled(darkFeatureManager.isFeatureEnabledForUser(ANONYMOUS, DISABLED_FEATURE)); }
/** * This flag decides if we should generate Protobuf derived Plugin modules as well as ModuleDescriptors. This method * allows fallback between the "vertigo ready" and old (deprecated) way of generating module descriptors at installation * time. * @return Whether or not to generate ModulDescriptors using the "vertigo ready" path or not. */ public boolean isVertigoSpiEnabled() { return !darkFeatureManager.isFeatureEnabledForAllUsers(DARKFEATURE_VERTIGO_SPI_DISABLED_KEY); } }
@Override public boolean isEnabled() { return featureManager.isFeatureEnabledForCurrentUser(DARK_FEATURE_PROGRAMMATIC_ANALYTICS); } }
@Test public void invalidFeatureKeyIsNeverEnabledForAnonymous() { assertInvalidFeatureDisabled(darkFeatureManager.isFeatureEnabledForUser(ANONYMOUS, INVALID_FEATURE_KEY)); }
@Override protected boolean isConditionTrue() { return darkFeatureManager.isFeatureEnabledForAllUsers(ACJS_VERSION_FEATURE_FLAG); }
public boolean isFeatureEnabledForCurrentUser(String key) { return darkFeatureManager.isFeatureEnabledForCurrentUser(key); } }
@Test(expected = IllegalArgumentException.class) public void featureUndefinedForInvalidUser() { darkFeatureManager.isFeatureEnabledForUser(notExistingUser(), ENABLED_FEATURE); }
public boolean isHipChatSystemUserEnabled() { return darkFeatureManager.isFeatureEnabledForAllUsers(HIPCHAT_SYSTEM_USER_ENABLED); }