/** * @param client Is joining node client. * @throws Exception If failed. */ private void checkNodeJoinDisabled(boolean client) throws Exception { startGrid(configuration(0, true, false)); startGrid(configuration(1, false, client)); grid(0).cluster().active(true); AuthorizationContext actx = grid(1).context().authentication().authenticate("ignite", "ignite"); assertNotNull(actx); assertEquals("ignite", actx.userName()); }
/** * @throws Exception If failed. */ @Test public void testClientNodeJoinDisabled() throws Exception { checkNodeJoinDisabled(true); }
/** * @throws Exception If failed. */ @Test public void testClientNodeJoinEnabled() throws Exception { checkNodeJoinEnabled(true); }
/** * @param client Is joining node client. * @throws Exception If failed. */ private void checkNodeJoinEnabled(boolean client) throws Exception { startGrid(configuration(0, false, false)); GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { startGrid(configuration(1, true, client)); return null; } }, IgniteCheckedException.class, "User authentication is disabled on cluster"); }
startGrid(configuration(0, false, false)); grid(0).cluster().active(true);
/** * @param idx Node index. * @param authEnabled Authentication enabled. * @param client Client node flag. * @return Ignite configuration. * @throws Exception On error. */ private IgniteConfiguration configuration(int idx, boolean authEnabled, boolean client) throws Exception { IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(idx)); cfg.setClientMode(client); cfg.setAuthenticationEnabled(authEnabled); cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setMaxSize(200L * 1024 * 1024) .setPersistenceEnabled(true))); return cfg; }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); super.afterTest(); }
/** * @throws Exception If failed. */ @Test public void testServerNodeJoinEnabled() throws Exception { checkNodeJoinEnabled(false); }
/** * @throws Exception If failed. */ @Test public void testServerNodeJoinDisabled() throws Exception { checkNodeJoinDisabled(false); }