mailWriter.forwardSlashChar = forwardSlashChar\r
mailWriter.commands = commands\r
mailWriter.url = url\r
-mailWriter.mountParameters = GitBlit.getBoolean(Keys.web.mountParameters, true)\r
-mailWriter.includeGravatar = GitBlit.getBoolean(Keys.web.allowGravatar, true)\r
-mailWriter.shortCommitIdLength = GitBlit.getInteger(Keys.web.shortCommitIdLength, 8)\r
+mailWriter.mountParameters = gitblit.getBoolean(Keys.web.mountParameters, true)\r
+mailWriter.includeGravatar = gitblit.getBoolean(Keys.web.allowGravatar, true)\r
+mailWriter.shortCommitIdLength = gitblit.getInteger(Keys.web.shortCommitIdLength, 8)\r
\r
def content = mailWriter.write()\r
\r
this.settings = gitblit.getSettings();\r
this.gitblit = gitblit;\r
this.repository = repository;\r
- this.user = user == null ? UserModel.ANONYMOUS : user;\r
+ this.user = user;\r
this.groovyDir = gitblit.getHooksFolder();\r
try {\r
// set Grape root\r
import javax.servlet.http.HttpServletRequest;\r
import javax.servlet.http.HttpServletResponse;\r
\r
-import com.gitblit.Constants;\r
+import com.gitblit.Constants.RpcRequest;\r
import com.gitblit.IStoredSettings;\r
import com.gitblit.Keys;\r
-import com.gitblit.Constants.RpcRequest;\r
-import com.gitblit.Keys.web;\r
import com.gitblit.manager.IRuntimeManager;\r
import com.gitblit.manager.ISessionManager;\r
import com.gitblit.models.UserModel;\r
return;\r
}\r
// valid user, but not for requested access. send 403.\r
- if (runtimeManager.isDebugMode()) {\r
- logger.info(MessageFormat.format("RPC: {0} forbidden to access {1}",\r
+ logger.warn(MessageFormat.format("RPC: {0} forbidden to access {1}",\r
user.username, fullUrl));\r
- }\r
httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN);\r
return;\r
}\r
git.repositoriesFolder = ${baseFolder}/git
git.searchRepositoriesSubfolders = true
git.enableGitServlet = true
+git.daemonPort = 8300
groovy.scriptsFolder = src/main/distrib/data/groovy
groovy.preReceiveScripts = blockpush
groovy.postReceiveScripts = sendmail
web.authenticateViewPages = false
web.authenticateAdminPages = true
web.allowCookieAuthentication = true
-realm.userService = ${baseFolder}/src/test/config/test-users.conf
+realm.userService = src/test/config/test-users.conf
realm.passwordStorage = md5
realm.minPasswordLength = 5
web.siteName = Test Gitblit
role = "#admin"
role = "#notfederated"
[user "userthree"]
- password = StoredInLDAP
+ password = "#externalAccount"
cookie = d7d3894fc517612aa6c595555b6e1ab8e147e597
displayName = User Three
emailAddress = userthree@gitblit.com
role = "#admin"
[user "userone"]
- password = StoredInLDAP
+ password = "#externalAccount"
cookie = c97cd38e50858cd0b389ec61b18fb9a89b4da54c
displayName = User One
emailAddress = User.One@gitblit.com
role = "#admin"
[user "usertwo"]
- password = StoredInLDAP
+ password = "#externalAccount"
cookie = 498ca9bd2841d39050fa45d1d737b9f9f767858d
displayName = User Two
emailAddress = usertwo@gitblit.com
cookie = dd94709528bb1c83d08f3088d4043f4742891f4f
role = "#admin"
role = "#notfederated"
+[user "sampleuser"]
+ password = sampleuser
+ cookie = 6e07ed42149fc166206319faffdfba2e2ec82e43
+ role = "#none"
[team "admins"]
role = "#none"
user = admin
ModelUtilsTest.class, JnaUtilsTest.class })\r
public class GitBlitSuite {\r
\r
+ public static final File BASEFOLDER = new File("data");\r
+\r
public static final File REPOSITORIES = new File("data/git");\r
\r
public static final File SETTINGS = new File("src/test/config/test-gitblit.properties");\r
\r
private static AtomicBoolean started = new AtomicBoolean(false);\r
\r
- public static Repository getHelloworldRepository() throws Exception {\r
+ public static Repository getHelloworldRepository() {\r
return getRepository("helloworld.git");\r
}\r
\r
- public static Repository getTicgitRepository() throws Exception {\r
+ public static Repository getTicgitRepository() {\r
return getRepository("ticgit.git");\r
}\r
\r
- public static Repository getJGitRepository() throws Exception {\r
+ public static Repository getJGitRepository() {\r
return getRepository("test/jgit.git");\r
}\r
\r
- public static Repository getAmbitionRepository() throws Exception {\r
+ public static Repository getAmbitionRepository() {\r
return getRepository("test/ambition.git");\r
}\r
\r
- public static Repository getGitectiveRepository() throws Exception {\r
+ public static Repository getGitectiveRepository() {\r
return getRepository("test/gitective.git");\r
}\r
\r
- private static Repository getRepository(String name) throws Exception {\r
- File gitDir = FileKey.resolve(new File(REPOSITORIES, name), FS.DETECTED);\r
- Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();\r
- return repository;\r
+ private static Repository getRepository(String name) {\r
+ try {\r
+ File gitDir = FileKey.resolve(new File(REPOSITORIES, name), FS.DETECTED);\r
+ Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();\r
+ return repository;\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
}\r
\r
public static boolean startGitblit() throws Exception {\r
assertEquals(5, settings().getInteger("realm.userService", 5));\r
\r
assertTrue(settings().getBoolean("git.enableGitServlet", false));\r
- assertEquals(GitBlitSuite.USERSCONF.getAbsolutePath(), settings().getString("realm.userService", null));\r
+ assertEquals("src/test/config/test-users.conf", settings().getString("realm.userService", null));\r
assertEquals(5, settings().getInteger("realm.minPasswordLength", 0));\r
List<String> mdExtensions = settings().getStrings("web.markdownExtensions");\r
assertTrue(mdExtensions.size() > 0);\r
\r
private void testRefChange(AccessPermission permission, Status expectedCreate, Status expectedDelete, Status expectedRewind) throws Exception {\r
\r
+ final String originName = "ticgit.git";\r
+ final String forkName = "refchecks/ticgit.git";\r
+ final String workingCopy = "refchecks/ticgit-wc";\r
+\r
+\r
+ // lower access restriction on origin repository\r
+ RepositoryModel origin = repositories().getRepositoryModel(originName);\r
+ origin.accessRestriction = AccessRestrictionType.NONE;\r
+ repositories().updateRepositoryModel(origin.name, origin, false);\r
+\r
UserModel user = getUser();\r
delete(user);\r
\r
CredentialsProvider cp = new UsernamePasswordCredentialsProvider(user.username, user.password);\r
\r
// fork from original to a temporary bare repo\r
- File refChecks = new File(GitBlitSuite.REPOSITORIES, "refchecks/ticgit.git");\r
+ File refChecks = new File(GitBlitSuite.REPOSITORIES, forkName);\r
if (refChecks.exists()) {\r
FileUtils.delete(refChecks, FileUtils.RECURSIVE);\r
}\r
CloneCommand clone = Git.cloneRepository();\r
- clone.setURI(MessageFormat.format("{0}/ticgit.git", url));\r
+ clone.setURI(url + "/" + originName);\r
clone.setDirectory(refChecks);\r
clone.setBare(true);\r
clone.setCloneAllBranches(true);\r
GitBlitSuite.close(clone.call());\r
\r
// elevate repository to clone permission\r
- RepositoryModel model = repositories().getRepositoryModel("refchecks/ticgit.git");\r
+ RepositoryModel model = repositories().getRepositoryModel(forkName);\r
switch (permission) {\r
case VIEW:\r
model.accessRestriction = AccessRestrictionType.CLONE;\r
repositories().updateRepositoryModel(model.name, model, false);\r
\r
// clone temp bare repo to working copy\r
- File local = new File(GitBlitSuite.REPOSITORIES, "refchecks/ticgit-wc");\r
+ File local = new File(GitBlitSuite.REPOSITORIES, workingCopy);\r
if (local.exists()) {\r
FileUtils.delete(local, FileUtils.RECURSIVE);\r
}\r
return dv;\r
}\r
\r
+ public int getInteger(String key, int defaultValue) {\r
+ return defaultValue;\r
+ }\r
+\r
public void sendMail(String subject, String message, Collection<String> toAddresses) {\r
messages.add(new MockMail(subject, message, toAddresses));\r
}\r
private LuceneService newLuceneExecutor() {\r
MemorySettings settings = new MemorySettings();\r
settings.put(Keys.git.repositoriesFolder, GitBlitSuite.REPOSITORIES);\r
- RuntimeManager runtime = new RuntimeManager(settings);\r
- UserManager users = new UserManager(runtime);\r
+ RuntimeManager runtime = new RuntimeManager(settings, GitBlitSuite.BASEFOLDER).start();\r
+ UserManager users = new UserManager(runtime).start();\r
RepositoryManager repos = new RepositoryManager(runtime, users);\r
return new LuceneService(settings, repos);\r
}\r
}\r
\r
@Test\r
- public void testIndex() throws Exception {\r
+ public void testIndex() {\r
// reindex helloworld\r
Repository repository = GitBlitSuite.getHelloworldRepository();\r
RepositoryModel model = newRepositoryModel(repository);\r
import com.gitblit.Constants.AuthorizationControl;\r
import com.gitblit.Constants.PermissionType;\r
import com.gitblit.Constants.RegistrantType;\r
-import com.gitblit.GitBlitException.NotAllowedException;\r
+import com.gitblit.GitBlitException.ForbiddenException;\r
import com.gitblit.GitBlitException.UnauthorizedException;\r
import com.gitblit.Keys;\r
import com.gitblit.models.FederationModel;\r
UserModel user = null;\r
try {\r
user = RpcUtils.getUser("admin", url, null, null);\r
- } catch (NotAllowedException e) {\r
+ } catch (ForbiddenException e) {\r
}\r
assertNull("Server allows anyone to get user!", user);\r
\r