Search in sources :

Example 16 with User

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"));
}
Also used : Mailer(hudson.tasks.Mailer) User(hudson.model.User) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) Test(org.junit.Test)

Example 17 with User

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);
}
Also used : User(hudson.model.User) Test(org.junit.Test)

Example 18 with User

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"));
}
Also used : User(hudson.model.User) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 19 with User

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);
}
Also used : User(hudson.model.User) Test(org.junit.Test)

Example 20 with User

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"));
}
Also used : User(hudson.model.User) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Aggregations

User (hudson.model.User)48 Test (org.junit.Test)30 Map (java.util.Map)22 ImmutableMap (com.google.common.collect.ImmutableMap)21 PipelineBaseTest (io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest)11 Mailer (hudson.tasks.Mailer)8 Domain (com.cloudbees.plugins.credentials.domains.Domain)7 CredentialsStore (com.cloudbees.plugins.credentials.CredentialsStore)5 BlueOceanDomainRequirement (io.jenkins.blueocean.rest.impl.pipeline.credential.BlueOceanDomainRequirement)5 FreeStyleProject (hudson.model.FreeStyleProject)4 Job (hudson.model.Job)4 ServiceException (io.jenkins.blueocean.commons.ServiceException)4 List (java.util.List)4 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)3 Cause (hudson.model.Cause)3 IOException (java.io.IOException)3 OrganizationFolder (jenkins.branch.OrganizationFolder)3 Authentication (org.acegisecurity.Authentication)3 MockFolder (org.jvnet.hudson.test.MockFolder)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3