use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method getAuthenticatedUser.
@Test
public void getAuthenticatedUser() throws Exception {
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
hudson.model.User user = j.jenkins.getUser("alice");
user.setFullName("Alice Cooper");
user.addProperty(new Mailer.UserProperty("alice@jenkins-ci.org"));
String token = getJwtToken(j.jenkins, "alice", "alice");
Map u = new RequestBuilder(baseUrl).get("/organizations/jenkins/user/").jwtToken(token).status(200).build(Map.class);
assertEquals(user.getFullName(), u.get("fullName"));
assertEquals("alice@jenkins-ci.org", u.get("email"));
assertEquals(user.getId(), u.get("id"));
Map permission = (Map) u.get("permission");
assertNotNull(permission);
assertTrue((Boolean) permission.get("administrator"));
Map pipelinePerm = (Map) permission.get("pipeline");
assertEquals(true, pipelinePerm.get("start"));
assertEquals(true, pipelinePerm.get("create"));
assertEquals(true, pipelinePerm.get("read"));
assertEquals(true, pipelinePerm.get("stop"));
assertEquals(true, pipelinePerm.get("configure"));
Map credentialPerm = (Map) permission.get("credential");
assertEquals(true, credentialPerm.get("create"));
assertEquals(true, credentialPerm.get("view"));
assertEquals(true, credentialPerm.get("update"));
assertEquals(true, credentialPerm.get("manageDomains"));
assertEquals(true, credentialPerm.get("delete"));
}
use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method postCrumbFailTest.
//UX-159
@Test
public void postCrumbFailTest() throws Exception {
User system = j.jenkins.getUser("SYSTEM");
post("/users/" + system.getId() + "/", "", "text/plain", 403);
}
use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method putMimeTest.
//UX-159
//@Test
public void putMimeTest() throws Exception {
User system = j.jenkins.getUser("SYSTEM");
Map response = put("/users/" + system.getId() + "/", Collections.emptyMap());
assertEquals(system.getId(), response.get("id"));
assertEquals(system.getFullName(), response.get("fullName"));
}
use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method patchMimeFailTest.
@Test
public void patchMimeFailTest() throws Exception {
User system = j.jenkins.getUser("SYSTEM");
new RequestBuilder(baseUrl).contentType("text/plain").status(415).patch("/users/" + system.getId()).build(Map.class);
}
use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method postCrumbTest.
//XXX: There is no method on User API to respond to POST or PUT or PATH. Since there are other tests that
// does POST, PUT for successful case, its ok to disable them.
//UX-159
// @Test
public void postCrumbTest() throws Exception {
User system = j.jenkins.getUser("SYSTEM");
Map response = post("/users/" + system.getId() + "/", Collections.emptyMap());
assertEquals(system.getId(), response.get("id"));
assertEquals(system.getFullName(), response.get("fullName"));
}
Aggregations