提交 bd8234cc 编写于 作者: K Kohsuke Kawaguchi

Fixing a test failure.

The intent of this test is to make sure that a floating User object without any storage returns false from canDelete() method.
The earlier change made User.impersonate() to actually check if the user is a valid, so to make this test case work where it does
"user.impersonate" and "user2.impersonate2", I'm creating valid accounts for these two users.

Now what that means is that user2 is no longer a floating flyweight storage-less User, so it breaks the assumption of the
"User should not be able to delete because he is not saved." assertion.

To make this test case work, I'm introducing the 3rd user that is storage-less, and using it for the test.
上级 17c4c1f5
......@@ -408,16 +408,19 @@ public class UserTest {
User user = realm.createAccount("John Smith","password");
User user2 = realm.createAccount("John Smith2","password");
user2.save();
User user3 = User.get("Random Somebody");
SecurityContextHolder.getContext().setAuthentication(user.impersonate());
assertFalse("User should not be able delete because he does not have administer permission.", user2.canDelete());
auth.add(Jenkins.ADMINISTER, user.getId());
assertTrue("User should be able to delete.", user2.canDelete());
assertFalse("User should not be able to delete because it is current user.", user.canDelete());
SecurityContextHolder.getContext().setAuthentication(user2.impersonate());
auth.add(Jenkins.ADMINISTER, user2.getId());
assertFalse("User should not be able to delete because he is not saved.", user.canDelete());
user.save();
assertTrue("User should be able to delete.", user.canDelete());
assertFalse("User should not be able to delete because he is not saved.", user3.canDelete());
user3.save();
assertTrue("User should be able to delete.", user3.canDelete());
}
@Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册