Skip to content
This repository was archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Tweak test according to latest configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ikikko committed Jun 11, 2016
1 parent bd6144d commit 743e4ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,18 @@ class BuildExecutorSpec extends Specification {
}

@Unroll
def "execute : #username"() {
def "execute : authorized is #authorized"() {
setup:
setUpRootUrl()
setUpProject([])
executor = new BuildExecutor(req, res, "typetalk-plugin", [])

def old = ACL.impersonate(new TestingAuthenticationToken(username, null, null))
setUpAuthorizationStrategy()
def old = ACL.impersonate(new TestingAuthenticationToken("test user", null, null))
setUpAuthorizationStrategy(authorized)

when:
executor.execute()
if (isBuilt) buildStarted.block()
if (authorized) buildStarted.block()

then:
1 * res.setStatus(HttpServletResponse.SC_OK)
Expand All @@ -195,9 +195,9 @@ class BuildExecutorSpec extends Specification {
SecurityContextHolder.setContext(old);

where:
username || isBuilt
"authorized" || true
"not authorized" || false
authorized || isBuilt
true || true
false || false
}

// --- helper method ---
Expand Down Expand Up @@ -228,14 +228,14 @@ class BuildExecutorSpec extends Specification {
project.lastBuild.getAction(ParametersAction.class).getParameter(key).value
}

def setUpAuthorizationStrategy() {
def setUpAuthorizationStrategy(authorized) {
j.jenkins.setAuthorizationStrategy(new AuthorizationStrategy() {
@Override
ACL getRootACL() {
new ACL() {
@Override
boolean hasPermission(Authentication a, Permission permission) {
a.name == "authorized"
authorized
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ListExecutorSpec extends Specification {
}

def countResultProjects() {
writer.toString().count(":astonished:")
writer.toString().count(":mask:")
}

}

0 comments on commit 743e4ee

Please sign in to comment.