use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method putMimeFailTest.
@Test
public void putMimeFailTest() throws Exception {
User system = User.get("SYSTEM");
put("/users/" + system.getId(), "", "text/plain", 415);
}
use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method createUserFavouriteFolderTest.
// TODO: migrate to FavoritesApiTest after PR receives initial approval (trying to cut down on PR noise)
@Test
public void createUserFavouriteFolderTest() throws Exception {
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
hudson.model.User user = User.get("alice");
user.setFullName("Alice Cooper");
MockFolder folder1 = j.createFolder("folder1");
Project p = folder1.createProject(FreeStyleProject.class, "pipeline1");
// String token = getJwtToken(j.jenkins,"alice", "alice");
Map map = new RequestBuilder(baseUrl).put("/organizations/jenkins/pipelines/folder1/pipelines/pipeline1/favorite/").authAlice().data(ImmutableMap.of("favorite", true)).build(Map.class);
validatePipeline(p, (Map) map.get("item"));
List l = new RequestBuilder(baseUrl).get("/users/" + user.getId() + "/favorites/").authAlice().build(List.class);
assertEquals(1, l.size());
Map pipeline = (Map) ((Map) l.get(0)).get("item");
validatePipeline(p, pipeline);
String href = getHrefFromLinks((Map) l.get(0), "self");
assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/pipeline1/favorite/", href);
map = new RequestBuilder(baseUrl).put(href.substring("/blue/rest".length())).authAlice().data(ImmutableMap.of("favorite", false)).build(Map.class);
validatePipeline(p, (Map) map.get("item"));
l = new RequestBuilder(baseUrl).get("/users/" + user.getId() + "/favorites/").authAlice().build(List.class);
assertEquals(0, l.size());
new RequestBuilder(baseUrl).put("/organizations/jenkins/pipelines/folder1/favorite/").authAlice().data(ImmutableMap.of("favorite", true)).status(405).build(Map.class);
new RequestBuilder(baseUrl).put("/organizations/jenkins/pipelines/folder1/favorite/").authAlice().data(ImmutableMap.of("favorite", false)).status(405).build(Map.class);
l = new RequestBuilder(baseUrl).get("/users/" + user.getId() + "/favorites/").authAlice().build(List.class);
assertEquals(0, l.size());
}
use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method getUserTest.
@Test
public void getUserTest() throws Exception {
User system = User.get("SYSTEM");
get("/users/", List.class);
Map response = get("/users/" + system.getId());
assertEquals(system.getId(), response.get("id"));
assertEquals(system.getFullName(), response.get("fullName"));
assertEquals("http://avatar.example/i/img.png", response.get("avatar"));
}
use of hudson.model.User in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method putMimeTest.
// UX-159
@Test
@Ignore
public void putMimeTest() throws Exception {
User system = User.get("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 postCrumbFailTest.
// UX-159
@Test
public void postCrumbFailTest() throws Exception {
User system = User.get("SYSTEM");
post("/users/" + system.getId() + "/", "", "text/plain", 403);
}
Aggregations