Java Code Examples for hudson.model.User#save()
The following examples show how to use
hudson.model.User#save() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserCreationListenerTest.java From audit-log-plugin with MIT License | 6 votes |
@Issue("JENKINS-54088") @Test @Parameters({ "1, alice, alicePassword", "1, bob, bobPassword", "1, charlie, charliePassword", "1, debbie, debbiePassword" }) public void testUserCreationFromRealm(int expectedCount, String username, String password) throws Exception { assertEventCount(app.getEvents(), 0); HudsonPrivateSecurityRealm realm = new HudsonPrivateSecurityRealm(false, false, null); j.jenkins.setSecurityRealm(realm); User user = realm.createAccount(username, password); user.save(); assertEventCount(app.getEvents(), expectedCount); }
Example 2
Source File: UserCreationListenerTest.java From audit-log-plugin with MIT License | 5 votes |
@Issue("JENKINS-54088") @Test public void testUserCreationAndLoginFromRealm() throws Exception { assertEventCount(app.getEvents(), 0); HudsonPrivateSecurityRealm realm = new HudsonPrivateSecurityRealm(false, false, null); j.jenkins.setSecurityRealm(realm); User u1 = realm.createAccount("charlie", USERS.get("charlie")); u1.save(); client.login("charlie", USERS.get("charlie")); // verify the audit event log messages as user creation and user login events StructuredDataMessage logMessageOne = (StructuredDataMessage) app.getEvents().get(0).getMessage(); StructuredDataMessage logMessageTwo = (StructuredDataMessage) app.getEvents().get(1).getMessage(); assertTrue(logMessageOne.toString().contains("createUser")); assertTrue(logMessageTwo.toString().contains("login")); // verify a login event occurred client.executeOnServer(() -> { Authentication a = Jenkins.getAuthentication(); assertEquals("charlie", a.getName()); return null; }); assertEventCount(app.getEvents(), 2); }