@Override public Object call() throws Exception { grid(0).context().authentication().updateUser("test", "test"); return null; } }, IgniteException.class,
@Override public Object call() throws Exception { grid(nodeIdx).context().authentication().updateUser("invalid_name", "test"); return null; } }, UserManagementException.class, "User doesn't exist");
grid(0).context().authentication().updateUser(user, "passwd_" + user);
/** * @param actx Authorization context. * @param updNode Node to execute update operation. * @param authNode Node to execute authentication. * @throws Exception On error. */ private void checkUpdateUser(AuthorizationContext actx, IgniteEx updNode, IgniteEx authNode) throws Exception { String newPasswd = randomString(16); updNode.context().authentication().updateUser("test", newPasswd); AuthorizationContext actxNew = authNode.context().authentication().authenticate("test", newPasswd); assertNotNull(actxNew); assertEquals("test", actxNew.userName()); } }
/** * @throws Exception If failed. */ @Test public void testConcurrentAddUpdateRemoveNodeRestartServer() throws Exception { IgniteInternalFuture restartFut = loopServerRestarts(); AuthorizationContext.context(actxDflt); final AtomicInteger usrCnt = new AtomicInteger(); GridTestUtils.runMultiThreaded(() -> { AuthorizationContext.context(actxDflt); String user = "test" + usrCnt.getAndIncrement(); try { while (!restartFut.isDone()) { grid(CLI_NODE).context().authentication().addUser(user, "init"); grid(CLI_NODE).context().authentication().updateUser(user, "passwd_" + user); grid(CLI_NODE).context().authentication().removeUser(user); } } catch (Exception e) { e.printStackTrace(); fail("Unexpected exception on add / remove"); } }, 10, "user-op"); restartFut.get(); }
authenticationProcessor.updateUser("test" + i, "passwd_" + i);
authentication.updateUser(req0.user(), req0.password()); break;
/** * @throws Exception If failed. */ @Test public void testDefaultUserUpdate() throws Exception { AuthorizationContext.context(actxDflt); try { // Change from all nodes for (int nodeIdx = 0; nodeIdx < NODES_COUNT; ++nodeIdx) { grid(nodeIdx).context().authentication().updateUser("ignite", "ignite" + nodeIdx); // Check each change from all nodes for (int i = 0; i < NODES_COUNT; ++i) { AuthorizationContext actx = grid(i).context().authentication().authenticate("ignite", "ignite" + nodeIdx); assertNotNull(actx); assertEquals("ignite", actx.userName()); } } } finally { AuthorizationContext.clear(); } }
grid(nodeIdx).context().authentication().updateUser("test", "new_password"); grid(nodeIdx).context().authentication().updateUser("test", "test");
grid(CLI_NODE).context().authentication().updateUser(user, "new_passwd_" + user);
/** * @param createNode Node to execute create operation. * @param authNode Node to execute authentication. * @throws Exception On error. */ private void checkAddUpdateRemoveUser(IgniteEx createNode, IgniteEx authNode) throws Exception { createNode.context().authentication().addUser("test", "test"); AuthorizationContext newActx = authNode.context().authentication().authenticate("test", "test"); assertNotNull(newActx); assertEquals("test", newActx.userName()); createNode.context().authentication().updateUser("test", "newpasswd"); newActx = authNode.context().authentication().authenticate("test", "newpasswd"); assertNotNull(newActx); assertEquals("test", newActx.userName()); createNode.context().authentication().removeUser("test"); }
SqlAlterUserCommand altCmd = (SqlAlterUserCommand)cmd; ctx.authentication().updateUser(altCmd.userName(), altCmd.password());
/** * @throws Exception If failed. */ @Test public void testUserPersistence() throws Exception { AuthorizationContext.context(actxDflt); try { for (int i = 0; i < NODES_COUNT; ++i) grid(i).context().authentication().addUser("test" + i , "passwd" + i); grid(CLI_NODE).context().authentication().updateUser("ignite", "new_passwd"); stopAllGrids(); startGrids(NODES_COUNT); for (int i = 0; i < NODES_COUNT; ++i) { for (int usrIdx = 0; usrIdx < NODES_COUNT; ++usrIdx) { AuthorizationContext actx0 = grid(i).context().authentication() .authenticate("test" + usrIdx, "passwd" + usrIdx); assertNotNull(actx0); assertEquals("test" + usrIdx, actx0.userName()); } AuthorizationContext actx = grid(i).context().authentication() .authenticate("ignite", "new_passwd"); assertNotNull(actx); assertEquals("ignite", actx.userName()); } } finally { AuthorizationContext.clear(); } }
authentication.updateUser(req0.user(), req0.password()); break;
SqlAlterUserCommand altCmd = (SqlAlterUserCommand)cmd; ctx.authentication().updateUser(altCmd.userName(), altCmd.password());