| | |
| | | public void testCommitterVerification() throws Exception {
|
| | | UserModel user = getUser();
|
| | |
|
| | | // account only uses account name to verify
|
| | | testCommitterVerification(user, user.username, null, true);
|
| | | // committer email address is ignored because account does not specify email
|
| | | testCommitterVerification(user, user.username, "something", true);
|
| | | // completely different committer
|
| | | testCommitterVerification(user, "joe", null, false);
|
| | | testCommitterVerification(user, "joe", user.emailAddress, false);
|
| | | testCommitterVerification(user, user.username, null, false);
|
| | | testCommitterVerification(user, user.username, user.emailAddress, true);
|
| | |
|
| | | // test display name verification
|
| | | user.displayName = "James Moger";
|
| | | testCommitterVerification(user, user.displayName, null, true);
|
| | | testCommitterVerification(user, user.displayName, "something", true);
|
| | | testCommitterVerification(user, "joe", null, false);
|
| | |
|
| | | // test email address verification
|
| | | user.emailAddress = "something";
|
| | | testCommitterVerification(user, user.displayName, null, false);
|
| | | testCommitterVerification(user, user.displayName, "somethingelse", false);
|
| | | testCommitterVerification(user, user.displayName, "something", false);
|
| | | testCommitterVerification(user, user.displayName, user.emailAddress, true);
|
| | |
|
| | | // use same email address but with different committer
|
| | | testCommitterVerification(user, "joe", "somethingelse", false);
|
| | | }
|
| | |
|
| | | private void testCommitterVerification(UserModel user, String displayName, String emailAddress, boolean expectedSuccess) throws Exception {
|
| | |
| | |
|
| | | private void testRefChange(AccessPermission permission, Status expectedCreate, Status expectedDelete, Status expectedRewind) throws Exception {
|
| | |
|
| | | final String originName = "ticgit.git";
|
| | | final String forkName = "refchecks/ticgit.git";
|
| | | final String workingCopy = "refchecks/ticgit-wc";
|
| | |
|
| | |
|
| | | // lower access restriction on origin repository
|
| | | RepositoryModel origin = repositories().getRepositoryModel(originName);
|
| | | origin.accessRestriction = AccessRestrictionType.NONE;
|
| | | repositories().updateRepositoryModel(origin.name, origin, false);
|
| | |
|
| | | UserModel user = getUser();
|
| | | delete(user);
|
| | |
|
| | | CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);
|
| | |
|
| | | // fork from original to a temporary bare repo
|
| | | File refChecks = new File(GitBlitSuite.REPOSITORIES, "refchecks/ticgit.git");
|
| | | File refChecks = new File(GitBlitSuite.REPOSITORIES, forkName);
|
| | | if (refChecks.exists()) {
|
| | | FileUtils.delete(refChecks, FileUtils.RECURSIVE);
|
| | | }
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setURI(url + "/" + originName);
|
| | | clone.setDirectory(refChecks);
|
| | | clone.setBare(true);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | GitBlitSuite.close(clone.call());
|
| | |
|
| | | // elevate repository to clone permission
|
| | | RepositoryModel model = repositories().getRepositoryModel("refchecks/ticgit.git");
|
| | | RepositoryModel model = repositories().getRepositoryModel(forkName);
|
| | | switch (permission) {
|
| | | case VIEW:
|
| | | model.accessRestriction = AccessRestrictionType.CLONE;
|
| | |
| | | repositories().updateRepositoryModel(model.name, model, false);
|
| | |
|
| | | // clone temp bare repo to working copy
|
| | | File local = new File(GitBlitSuite.REPOSITORIES, "refchecks/ticgit-wc");
|
| | | File local = new File(GitBlitSuite.REPOSITORIES, workingCopy);
|
| | | if (local.exists()) {
|
| | | FileUtils.delete(local, FileUtils.RECURSIVE);
|
| | | }
|