Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-9293] Add test that project-level permissions of a matrix pr…
…oject

apply to child configurations as well.

Originally-Committed-As: 2c767feea175aa2b7113216f10d0f972671a0e92
  • Loading branch information
alanharder committed Apr 14, 2011
1 parent eb2f618 commit cbc8e82
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion test/src/test/java/hudson/matrix/MatrixTest.java
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (c) 2010, Alan Harder
* Copyright (c) 2010-2011, Alan Harder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -23,7 +23,13 @@
*/
package hudson.matrix;

import hudson.model.Item;
import hudson.security.AuthorizationMatrixProperty;
import hudson.security.ProjectMatrixAuthorizationStrategy;
import java.util.Collections;
import org.acegisecurity.context.SecurityContextHolder;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.Bug;

/**
* @author Alan Harder
Expand All @@ -41,4 +47,22 @@ public void testSpaceInUrl() {
"job/matrix%20test/foo%20bar=baz%20bat/".equals(mc.getUrl())
|| "job/matrix%20test/./foo%20bar=baz%20bat/".equals(mc.getUrl()));
}

/**
* Test that project level permissions apply to child configurations as well.
*/
@Bug(9293)
public void testConfigurationACL() throws Exception {
hudson.setAuthorizationStrategy(new ProjectMatrixAuthorizationStrategy());
MatrixProject mp = createMatrixProject();
mp.setAxes(new AxisList(new Axis("foo", "a", "b")));
MatrixConfiguration mc = mp.getItem("foo=a");
assertNotNull(mc);
SecurityContextHolder.clearContext();
assertFalse(mc.getACL().hasPermission(Item.READ));
mp.addProperty(new AuthorizationMatrixProperty(
Collections.singletonMap(Item.READ, Collections.singleton("anonymous"))));
// Project-level permission should apply to single configuration too:
assertTrue(mc.getACL().hasPermission(Item.READ));
}
}

0 comments on commit cbc8e82

Please sign in to comment.