summaryrefslogtreecommitdiffstats
path: root/src/test/java/com/gitblit/tests
Commit message (Collapse)AuthorAgeFilesLines
* TimeUtils: Move unit test to same package as TimeUtils isFlorian Zschocke2021-10-232-265/+1
| | | | | | | | | | For some reason the `TimeUtilsTest` class is, like almost all tests, in the `com.gitblit.tests` package. But this way all methods in classes which we might predominately need for tests have to be public. So move the unit test class `TimeUtilsTest` to the same package as the class it is testing, i.e. `com.gitblit.utils.TimeUtils`. This way we ca set the new added methods which get the current time passed in to be at least not public.
* TimeUtils: Increase testability and add testsFlorian Zschocke2021-10-231-0/+157
| | | | | | | | | Add tests for `timeAgo` to analyse issue #1248. The tests are dependent on when they run as they time functions use the current date and time. To make them testable in a reproducible way, we need the ability to pass in what we think is "now". So add overloaded methods that take a `now` parameter so that we can pass in the current time.
* raw: Strip leading and trailing slash from repo and path names for linkFlorian Zschocke2020-11-091-0/+12
| | | | | | When creating a link for raw display, a trailing slash is stripped from the end of the base URL. Also do this for the repository, as well as stripping leading slashes from the repository and the path values.
* Delete password from memory in AuthenticationManagerFlorian Zschocke2020-04-052-12/+87
| | | | | | Zero out the password to remove it from memory after use. This is only a first step, implementing it for one method: `AuthenticationManager.authenticate(String, char[], String)`.
* 🦟 fix: Password hash upgrade kills existing passwordsFlorian Zschocke2020-04-051-4/+12
| | | | | | | | | | The upgrade of a MD5 stored password hash to a PBKDF password hash destroys the stored password. The has check zeroes out the password that is tested, so that the new hash is built over the zeroed out value. This fix prevents that an also adds a check to the test. Fixes #1335
* Add `clone.bundle` as known command, but reject it as not implemented.Florian Zschocke2019-11-111-1/+13
|
* Fix NPE when no action can be parsed from the URLFlorian Zschocke2019-11-111-0/+54
| | | | | | | | | | | | Renames `static final` variables according to convention to be in all upper case. That makes it easier to see that in an `equals` comparison the final variable should come first as it will not trigger a NPE. Also strip parameters from the URL when extracting the repository name from it. Parameters can not be part of a repository name, and this way an empty repository name can be detected. Fixes #1092
* In SSH tests ignore an external SSH toolFlorian Zschocke2019-11-101-0/+55
| | | | | | | | | | | | | | The SshDaemonTest would fail under Windows. That is because JGit looks at the `GIT_SSH` environment variable. If it is set, the tool the variable is pointing to is used for the SSH connection. This is a problem when it is set to "Plink" under Windows, because Plink will not recognize the server key and will not find it in the registry, cached as a known host. Since a test can/should not add the key to the registry but simply wants to ignore it, but there is no way to tell Plink to do so, the tests would fail. This patch filters the `GIT_SSH` environment variable from JGit's `SystemReader`, so that the internal SSH client is used.
* Update SSHD dependency to version 1.2.0.Florian Zschocke2019-11-101-1/+15
|
* Update SSHD dependency to version 1.1.0.Florian Zschocke2019-11-102-6/+11
|
* Ignore the `RedisTicketService` tests until they are fixed.Florian Zschocke2019-11-101-0/+3
| | | | | Currently the tests cannot run as no Redis is available. Needs to be fixed at some time.
* Merge branch 'pingunaut-1166_more_secure_password_hashes' into master.Florian Zschocke2019-11-061-0/+32
|\
| * Use the new PasswordHash classes.Florian Zschocke2019-11-051-6/+32
| | | | | | | | | | | | Integrate the `PasswordHash` class and subclass in the user and password editing and authentication. Replaces the old code and the previous `SecurePasswordHashingUtils` class.
| * Update AuthenticationManager to update weakly stored passwords on loginMartin Spielmann2017-01-071-0/+6
| |
* | Fix revLog test that broke due to changes in the hello-world repository.Florian Zschocke2019-06-101-3/+4
| |
* | Create unit tests for special characters in path namesFlorian Zschocke2019-06-101-1/+13
| | | | | | | | | | | | | | Create a regression test for issue #999. Add directories with '[]' ans '()' in the name to the hello-world repository, so that they can be used in unit tests for repository paths with special characters.
* | Do not resolve symbolic links to repositories.Florian Zschocke2019-06-101-0/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When symbolic links under the base repository folder point to repositories outside the base repository folder, the forming of relative repository names failed and resulted in NullPointerExceptions. Create the relative path by not following symbolic links, i.e. the link name is taken as is and not resolved to the external path. This also changes the whole `exactPath` method to work on Paths, instead of Files. Fixes #891 and fixes #837.
* | Zips of recreated hello-world.git and all external repositories for testing.chirontt2019-06-076-46/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This hello-world.git repo is created using the native Git for Windows software. Various test classes in the GitBlitSuite test suite require the presence of the hello-world.git repo in github.com/git/ which has been missing, hence causing many test failures in the suite. This recreation of the hello-world.git repo aims to conform to the many test cases' requirements in the suite, and to be checked in as part of the gitblit repo, thus eliminates the requirement of a remote hello-world.git repo during the test run. The repo is now stored is a zip ball in the new src/test/data folder. The hello-world repo's various commit IDs were hard-coded in various test classes. These commit IDs, which must now have new values in the recreated repo, are now extracted out to the src/test/data/hello-world.properties file. The gitblit's build.xml is modified to generate the HelloworldKeys.java file containing the hello-world.properties file's key strings, in similar fashion as the existing generation of the com.gitblit.Keys.java file. And these key strings in HelloworldKeys.java are now used in the various test classes, thus eliminating the hard-coding of the hello-world repo's commit IDs in the test code. During the test run by GitBlitSuite test suite, some repos from GitHub were cloned and became part of the test data. These repos are now zipped to be part of gitblit repo itself, thus eliminating the network fetch at the start of test run which can be slow, especially with the JGit repo cloning which is huge and time consuming. The cloned JGit repo is now zipped and checked in to gitblit, along with the other 4 repos (hello-world, ambition, gitective and ticgit). They will be unzipped during the test suite run and be available in the local file system, thus avoiding the need for some network fetch. Special note on the zipped JGit repo: this repo is big (and growing all the time on GitHub), and takes up about 32MB of disk space after cloning from GitHub. I've made it smaller by resetting HEAD back to a commit of 5 years ago (with git reset --hard <commitId> command), to put it back to roughly where/when the tests were written for it (which is not quite, because there are tons of commit history since which can't be removed.) The local JGit repo is then garbage-collected (with git gc --prune --aggressive) to reduce its size to about 19MB. Zipped it is still 17MB. This is a lot of MBs for a few tests. So the JGit repo is not included in this commit. Fixes #1275
* | Fix for various test failures.chirontt2019-06-079-90/+112
| | | | | | | | | | | | | | | | | | | | | | | | Most of failures were due to temporary test repos, users and/or teams being left behind after the test run, and these left-over stuff in $baseFolder/data/git caused assertion errors in many tests in subsequent test runs. This fix tries to delete those left-over stuff at the end of each test, mainly in their @Afterclass code blocks. PushLogTest.java is deleted as it doesn't work, and has been superseded with better tests in various protocol test suites (GitServletTest, GitDaemonTest, SshDaemonTest, etc.)
* | Reindex tickets on server start if no index existsFlorian Zschocke2017-03-054-4/+4
|/ | | | | | | | | | | | | | Check if tickets need to be reindexed when the server starts. This is the case if no ticket index exists. In that case the ticket index is built. This is done during the start of the `ITicketService`. For this the interface of `ITicketService` needed to change. The `start` method was defined abstract and the specific ticket services had to implement it. None does any real starting stuff in it. The `start` method is now final. It calls a new abstract method `onStart` which the specific ticket services need to implement. In the existing implementations I just changed `start` to `onStart`.
* Merge pull request #1160 from fzs/sshLdapAuthenticatorFlorian Zschocke2016-12-185-339/+1427
|\ | | | | LDAP SSH key manager
| * Fix SshKeysDispatcher test failing on WindowsFlorian Zschocke2016-12-061-7/+7
| | | | | | | | | | | | | | | | | | The `SshKeysDispatcher` tests that use the keys list command are failing on Windows because they assume a Unix line ending after each key. But the command will use a system line ending. So this fix uses system line endings in the reference string for the assert, too. In addition, two `assertTrue(false)´ are replaced with a proper `fail`.
| * Use dynamic port selection for LDAP listeners in LDAP tests.Florian Zschocke2016-12-061-10/+11
| | | | | | | | | | | | | | Instead of using fixed ports for the listeners of the in-memory LDAP server, let the listeners select ports and then save them in the authentication mode instance. This way we prevent port collisions, which especially showed up under Windows.
| * Retrieve public SSH keys from LDAP.Florian Zschocke2016-11-292-0/+755
| | | | | | | | | | | | | | | | | | | | | | | | Add new class `LdapPublicKeyManager` which retrieves public SSH keys from LDAP. The attribute can be configured with the new configuration option `realm.ldap.sshPublicKey`. The setting can be a simple attribute name, like `sshPublicKey`, or an attribute name and a prefix for the value, like `altSecurityIdentities:SshKey`, in which case attributes are selected that have the name `altSecurityIdentities` and whose values start with `SshKey:`.
| * Extract LdapConnection into new class from LdapAuthProviderFlorian Zschocke2016-11-231-0/+248
| | | | | | | | | | | | | | | | Extract the inner class `LdapConnection` from the `LdapAuthProvider` into a separate class, so that it can be used from multiple classes that have to connect to an LDAP directory. The new class is placed into the new package `com.gitblit.ldap`, since it isn't specific to authentication.
| * Create base unit test class for LDAP tests.Florian Zschocke2016-11-232-332/+416
| | | | | | | | | | | | Extract the creation of the in-memory servers and the interceptor code to a base class that LDAP related unit tests can extend to have the servers available.
* | Merge branch 'fixMentionsInTickets-985'Florian Zschocke2016-12-121-1/+73
|\ \ | |/ |/|
| * Fix user mention regular expression and group replacement.merged--fixMentionsInTickets-985Florian Zschocke2016-12-101-1/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The regular expression used for user mentions used to work only inside sentences. Also, since it tested for whitespace, the whitespace would get replaced, too, which would join lines together. Instead the new regex uses boundary matchers to match against word boundaires. As these are not capturing only the actual user mention can be captured and is then replaced. Also, this way the regex can ignore punctuation like in "@jim, look at this." Since Gibtlit now requires Java 7 we can use named capture groups. This makes the use of a centrally defined regular expression much safer. The (admittedly only) group to capture the user name is named "user" and can be referenced by this name. By using the name instead of a group number, the regex could be changed without the code using it breaking because the group number changed. A simple test is added for user mentions, which unfortunately has to deal with the full markdown replacement, too. Fixes #985
* | Set "can admin" permission on LDAP users and teams correctlymerged--fixAdminRoleLDAPFlorian Zschocke2016-11-181-4/+261
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The canAdmin permission is set on a LDAP user, when the user is listed in `realm.ldap.admins` or is a member of a team listed in `realm.ldap.admins`. This leads to inconsistent and surprising behaviour on the EditUser page when clicking the "can admin" checkbox. Also, the "can admin" checkbox is disabled, but not checked, for teams that are listed as admin teams. The new behaviour implemented in this patch makes users and teams from LDAP match local ones. That means: * LDAP teams that are listed in `realm.ldap.admins` get the canAdmin property set if teams are maintained in LDAP. * LDAP users that are listed in `realm.ldap.admins` get the canAdmin property set if teams are maintained in LDAP. * LDAP users do not get the canAdmin property set, if they are only a member of a team listed in `realm.ldap.admins`. * The `supportsRoleChanges` method for users and teams of the `LdapAuthProvider` unconditially returns false if teams are maintained in LDAP, not only for users and teams listed in `realm.ldap.admins`. * Therefore, for all LDAP users and teams the "can admin" checkbox is always disabled if teams are maintained in LDAP.
* | Extend LDAP tests to use LDAP servers with access restrictions.Florian Zschocke2016-11-091-45/+257
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add access restrictions to the LDAP test server instances. New modes used a test parameters are ANONYMOUS, DS_MANAGER and USR_MANAGER. ANONYMOUS can bind anonymously and access users and groups. In DS_MANAGER the server requires authentication and will only allow the DIRECTORY_MANAGER user to search for users and groups. In USR_MANAGER only the user can search groups, the USER_MANAGER, which is used to bind in this mode, can not. A third server instance is created because I did fear side effects should the tests be run in parallel, had I tried to configure the access restriction in Before.
* | Extend LDAP authentication tests to use different modes.Florian Zschocke2016-11-061-23/+107
|/ | | | | | | Instantiate two LDAP servers, one that allows anonymous access, and one that requires authentication for all operations. The JUnit test is parameterized to run all tests with both instances. It uses different settings for each mode.
* TicketReference Testing #1048Paul Martin2016-06-181-4/+36
| | | | + Multiple commits in a single push
* Ticket Reference handling #1048Paul Martin2016-04-272-1/+940
| | | | | | | | | | | | | | | + Supports referencing: + Tickets from other tickets via comments + Tickets from commits on any branch + Common TicketLink class used for both commits and tickets + TicketLink is temporary and persisted to ticket as a Reference + Support deletion of ticket references + Rebasing patchsets/branches will generate new references + Deleting old patchsets/branches will remove the relevant references + Substantial testing of use cases + With and without patchsets, deleting, amending + BranchTicketService used during testing to allow end-to-end ref testing + Relocated common git helper functions to JGitUtils
* Fix for #976 - Filestore links via browserPaul Martin2015-12-251-3/+3
| | | | | | | | | | | | | + GitLFS client support + FilestoreModel now parses meta file + Read meta heading from cache if available + Authentication based on accept headers for browser view filestore login + PathModel & PathChangeModel now understands filestore items + Zip & Rar downloads contain include filestore items + Filestore servlet returns LFS JSON error only if accepted by client + DiffStat now knows repository to allow identification of filestore items + Filestore items identified and returned via view, raw & blob links on blame, commitDiff, commit and Tree pages
* Log update for Fail2Ban usagePaul Martin2015-10-255-34/+34
| | | | | + Adds standard logging for all authentication providers + Updates help page to use default GitBlit SSH port
* Git-LFS supportPaul Martin2015-10-104-1/+908
| | | | | | | | | | | | | | + Metadata maintained in append-only JSON file providing complete audit history. + Filestore menu item + Lists filestore items + Current size and availability + Link to GitBlit Filestore help page (top right) + Hooks into existing repository permissions + Uses default repository path for out-of-box operation with Git-LFS client + accessRestrictionFilter now has access to http method and auth header + Testing for servlet and manager
* Revert manual specification of ssh user auth factoriesJames Moger2015-10-053-14/+8
|
* Update to SSHD 1.0.0James Moger2015-09-182-8/+8
|
* Revised AvatarGenerator to be injectableJames Moger2015-06-152-52/+50
|
* First draft for a customized avatar imageFabrice Bacchella2015-06-151-0/+77
|
* Invalid kerberos patches, works now and with a test.Fabrice Bacchella2015-05-262-1/+77
|
* Implement configurable tab length support for blob viewsJames Moger2015-05-222-4/+4
|
* Merged #247 "Add Kerberos5/GSS authentication to ssh"James Moger2015-05-212-0/+9
|\
| * Adding Kerberos5/GSS authentication to sshFabrice Bacchella2015-05-042-0/+9
| | | | | | | | Adding the possibility to define authentication method order for ssh
* | A patch that allows to extract a new user informations from the HTTP sessionFabrice Bacchella2015-05-151-17/+658
|/ | | | if the webapp container can fill it.
* Add links to commit diff and blob diff pages to toggle whitespace settingJames Moger2015-03-071-3/+3
|
* Add DiffComparator argument to all DiffUtils calls, default to ignore all ↵James Moger2015-03-071-3/+4
| | | | whitespace
* #230 - Improve empty folder navigation.Milos Cubrilo2015-01-113-7/+82
| | | | Empty folders are automatically skipped when browsing repository tree (similar to github "folder jumping" feature).
* Tickets - Priority, Severity optionsPaul Martin2014-10-203-4/+193
| | | | | | | | | + Severity indicated via new character indicator and color of ticket icon on ticket list + Priority indicated via new priority icon and color on ticket list + Indexed as integers to provide sorting and maintain language neutral index + Colours and indicator text controlled through CSS classes priority-<x> & severity-<x> + UITicketTest created to generate tickets of all types to ease debugging
* Merge release-1.6.1James Moger2014-10-201-1/+1
|\