提交 2c767fee 编写于 作者: A alanharder

[JENKINS-9293] Add test that project-level permissions of a matrix project

apply to child configurations as well.
上级 f9ad02a3
/*
* 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
......@@ -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
......@@ -41,4 +47,22 @@ public class MatrixTest extends HudsonTestCase {
"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));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册