Commit Graph

151 Commits

Author SHA1 Message Date
Semyon Pupkov 3deb66ea56 Add traits for ProjectFeatures to Project factory
https://gitlab.com/gitlab-org/gitlab-ce/issues/24007
2017-02-05 13:11:45 +05:00
Lin Jen-Shin 406dfd6e0f Merge remote-tracking branch 'upstream/master' into fix-git-hooks-when-creating-file
* upstream/master:
  Ensure we have a project with a repo in GitlabMarkdownHelper specs
  Revert "Make sure TraceReader uses Encoding.default_external"
  Make sure TraceReader uses Encoding.default_external
  Update CONTRIBUTING.md after merging "up-for-grabs" and "Accepting Merge Requests" [ci skip]
  Use `:empty_project` where possible in finder specs
  Use `empty_project` where possible in controller specs
  Use `:empty_project` where possible in helper specs
  Don’t count tasks that are not defined as list items correctly
  Use a project factory with a repository where necessary
  Use `:empty_project` where possible throughout spec/lib
  Use hashrocket for dasherized attribute
  Remove markdown file extension and add anchor to link
  Fixed builds info link on project settings page
  Factories with a project association use `:empty_project` by default
  Update enviroments.md the example for deleting an environment is missing the "s" in environments. curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/environments/1"  wil 404
2017-01-26 22:19:50 +08:00
Robert Speicher 80a6d2fda2 Use `:empty_project` where possible throughout spec/lib 2017-01-25 12:25:42 -05:00
Lin Jen-Shin 104bac3d21 Merge branch 'master' into fix-git-hooks-when-creating-file
* master: (1031 commits)
  Add changelog entry for renaming API param [ci skip]
  Add missing milestone parameter
  Refactor issues filter in API
  Fix project hooks params
  Gitlab::LDAP::Person uses LDAP attributes configuration
  Don't delete files from spec/fixtures
  Copy, don't move uploaded avatar files
  Minor improvements to changelog docs
  Rename logo, apply for Slack too
  Fix Gemfile.lock for the octokit update
  Fix cross-project references copy to include the project reference
  Add logo in public files
  Use stable icon for Mattermost integration
  rewrite the item.respond_to?(:x?) && item.x? to item.try(:x?)
  API: extern_uid is a string
  Increases pipeline graph drowdown width in order to prevent strange position on chrome on ubuntu
  Removed bottom padding from merge manually from CLI because of repositioning award emoji's
  Make haml_lint happy
  Improve spec
  Add feature tests for Cycle Analytics
  ...
2017-01-04 22:25:55 +08:00
Lin Jen-Shin 884f57c910 Use consistent names and move checks to the method,
and move those checks to be private. Feedback:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7383#note_20285012

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7383#note_20285279
2016-12-20 21:19:07 +08:00
Lin Jen-Shin 07b9b80a88 Fix tests to use the new API 2016-12-08 19:11:52 +08:00
Lin Jen-Shin a41ee7eb5e Fix an old copypasta: internal -> private 2016-11-18 18:37:32 +08:00
Lin Jen-Shin 8c1a01e05f We never check user privilege if it's a deploy key 2016-11-18 03:48:23 +08:00
Lin Jen-Shin 48090a9188 Introduce no_user_or_blocked? and fix tests due to
checking user permission.
2016-11-16 22:07:04 +08:00
Lin Jen-Shin 40632455b8 Fix a typo: acccess -> access 2016-11-11 21:54:10 +08:00
Lin Jen-Shin 71ae01fefe Add more tests and fix write to project check 2016-11-11 21:44:33 +08:00
Lin Jen-Shin 24d9f51e7b Correct the test. Not sure why change it in the first place 2016-11-11 21:21:43 +08:00
Lin Jen-Shin 42e252da42 Merge remote-tracking branch 'upstream/master' into feature/1376-allow-write-access-deploy-keys
* upstream/master: (3852 commits)
  Grapify token API
  Fix cache for commit status in commits list to respect branches
  Grapify milestones API
  Grapify runners API
  Improve EeCompatCheck, cache EE repo and keep artifacts for the ee_compat_check task
  Use 'Forking in progress' title when appropriate
  Fix CHANGELOG after 8.14.0-rc1 tag
  Update CHANGELOG.md for 8.14.0-rc1
  Fix YAML syntax on CHANGELOG entry
  Remove redundant rescue from repository keep_around
  Remove redundant space from repository model code
  Remove order-dependent expectation
  Minor CHANGELOG.md cleanups
  Add a link to Git cheatsheet PDF in docs readme
  Grapify the session API
  Add 8.13.5, 8.12.9, and 8.11.11 CHANGELOG
  Merge branch 'unauthenticated-container-registry-access' into 'security'
  Merge branch '23403-fix-events-for-private-project-features' into 'security'
  Merge branch 'fix-unathorized-cloning' into 'security'
  Merge branch 'markdown-xss-fix-option-2.1' into 'security'
  ...
2016-11-10 15:16:33 +00:00
Douwe Maan b0bf92140f
Merge branch 'fix-unathorized-cloning' into 'security'
Ensure external users are not able to clone disabled repositories.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/23788

See merge request !2017

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-09 12:27:17 +01:00
Kamil Trzcinski 517dd4a3f3 Allow owners to fetch source code in CI builds
Due to different way of handling owners of a project, they were not allowed to fetch CI sources for project.
2016-11-01 09:37:20 +01:00
Sean McGivern cc6d42861b Backport git access spec changes from EE
These were introduced in:
<https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/645>
2016-10-18 17:28:57 +01:00
Kamil Trzcinski 0672c5a92e Post-merge improve of CI permissions 2016-09-20 15:41:41 +02:00
Kamil Trzcinski e941365f3b Rename capabilities to authentication_abilities 2016-09-16 11:12:21 +02:00
Kamil Trzcinski 548169cfb5 Fix most of specs 2016-09-15 15:40:53 +02:00
Kamil Trzcinski 9d1ccd2ad3 Fix existing authorization specs 2016-09-15 13:49:11 +02:00
Kamil Trzcinski 11f87700e8 Add access specs 2016-09-15 11:57:09 +02:00
Ali Ibrahim 2b73aaa15a Allow to add deploy keys with write-access 2016-08-17 11:11:08 -04:00
Jacob Vosmaer e55e224cd9 Fix ArgumentError in GitAccess specs 2016-08-04 15:22:34 +02:00
Timothy Andrew a72d449190 Remove duplicate specs from `git_access_spec`
- Likely introduced during an improper conflict resolution.
2016-07-29 15:20:39 +05:30
Timothy Andrew cc1cebdcc5 Admins count as masters too.
1. In the context of protected branches.

2. Test this behaviour.
2016-07-29 15:20:39 +05:30
Timothy Andrew c647540c10 Fix all specs related to changes in !5081.
1. Remove `Project#developers_can_push_to_protected_branch?` since it
   isn't used anymore.

2. Remove `Project#developers_can_merge_to_protected_branch?` since it
   isn't used anymore.
2016-07-29 15:20:39 +05:30
Timothy Andrew 828f6eb6e5 Enforce "No One Can Push" during git operations.
1. The crux of this change is in `UserAccess`, which looks through all
   the access levels, asking each if the user has access to push/merge
   for the current project.

2. Update the `protected_branches` factory to create access levels as
   necessary.

3. Fix and augment `user_access` and `git_access` specs.
2016-07-29 15:20:39 +05:30
Kamil Trzcinski 2532ec9edc Allow to pull code with deploy key from public projects 2016-07-19 12:23:41 +02:00
Rémy Coutable 2cf7f09b1e
Revert "Revert "Merge branch '18193-developers-can-merge' into 'master' ""
This reverts commit 530f5158e2.

See !4892.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-07-18 10:16:56 +02:00
Robert Speicher 530f5158e2 Revert "Merge branch '18193-developers-can-merge' into 'master' "
This reverts commit 9ca633eb4c, reversing
changes made to fb229bbf79.
2016-07-13 13:57:30 -05:00
Timothy Andrew 4d00ed21eb Appease rubocop. 2016-07-13 13:24:56 +05:30
Timothy Andrew 60245bbe22 Refactor `Gitlab::GitAccess`
1. Don't use case statements for dispatch anymore. This leads to a lot
   of duplication, and makes the logic harder to follow.

2. Remove duplicated logic.

    - For example, the `can_push_to_branch?` exists, but we also have a
      different way of checking the same condition within `change_access_check`.

    - This kind of duplication is removed, and the `can_push_to_branch?`
      method is used in both places.

3. Move checks returning true/false to `UserAccess`.

    - All public methods in `GitAccess` now return an instance of
      `GitAccessStatus`. Previously, some methods would return
      true/false as well, which was confusing.

    - It makes sense for these kinds of checks to be at the level of a
      user, so the `UserAccess` class was repurposed for this. The prior
      `UserAccess.allowed?` classmethod is converted into an instance
      method.

    - All external uses of these checks have been migrated to use the
      `UserAccess` class

4. Move the "change_access_check" into a separate class.

    - Create the `GitAccess::ChangeAccessCheck` class to run these
      checks, which are quite substantial.

    - `ChangeAccessCheck` returns an instance of `GitAccessStatus` as
      well.

5. Break out the boolean logic in `ChangeAccessCheck` into `if/else`
   chains - this seems more readable.

6. I can understand that this might look like overkill for !4892, but I
   think this is a good opportunity to clean it up.

    - http://martinfowler.com/bliki/OpportunisticRefactoring.html
2016-07-13 13:24:56 +05:30
Timothy Andrew 495db09653 Enforce "developers can merge" during `pre-receive`.
1. When a merge request is being merged, save the merge commit SHA in
   the `in_progress_merge_commit_sha` database column.

2. The `pre-receive` hook looks for any locked (in progress) merge
   request with `in_progress_merge_commit_sha` matching the `newrev` it
   is passed.

3. If it finds a matching MR, the merge is legitimate.

4. Update `git_access_spec` to test the behaviour we added here. Also
   refactored this spec a bit to make it easier to add more contexts / conditions.
2016-07-13 13:24:56 +05:30
Mathias Vestergaard f0577d8385 Added "developers can merge" setting to protected branches
- Cherry-picked from `mvestergaard:branch-protection-dev-merge`
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4220
2016-07-13 13:24:26 +05:30
Patricio Cano be221a30ac Revert back to not defining a default Git access protocol. 2016-07-05 16:54:22 -05:00
Patricio Cano 29c50c5315 Default Git access protocol to `web` 2016-07-05 16:54:22 -05:00
Patricio Cano fbaabb3911 Rename `enabled_git_access_protocols` to singular. 2016-07-05 16:54:22 -05:00
Patricio Cano 42fb2516d9 Add more tests to the allowed protocols feature 2016-07-05 16:54:22 -05:00
Patricio Cano 8b14d1d2c2 Rename ENV['PROTOCOL'] to ENV['GL_PROTOCOL'] to conform to what GitLab Shell expects and make the `protocol` param in `GitAccess` mandatory. 2016-07-05 16:54:22 -05:00
Grzegorz Bizon 9e211091a8 Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
Douwe Maan 13d6bab177 Tag lib specs 2015-12-09 11:55:42 +01:00
Douwe Maan c5e4b443ff Fix GitAccess. 2015-05-13 09:46:22 +02:00
Douwe Maan 4830b2be5e Refactor GitAccess to use instance variables. 2015-03-24 14:11:48 +01:00
Jeroen van Baarsen 0c4a70a306 Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-12 19:17:35 +01:00
Valery Sizov ab7a79bf3b developer can push to protected branches 2015-01-20 17:34:23 -08:00
Marin Jankovski 84af3ceb9b Add spec for developers can push to protected branches. 2014-12-26 11:41:04 +01:00
Dmitriy Zaporozhets 06b7907c2a
Fix deploy keys permission check in internal api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-01 16:25:10 +02:00
Valery Sizov 53bf52f191 Better message for failed pushes because of git hooks
Conflicts:
	lib/gitlab/git_access.rb
	spec/lib/gitlab/git_access_spec.rb
2014-11-18 13:10:07 +02:00
Ciro Santilli 71ed0ab069 Fix push not allowed to protected branch if
commit starts with 7 zeros.
2014-11-03 20:37:47 +01:00
Dmitriy Zaporozhets 15ba6ea105 Refactor Gitlab::GitAccess tests 2014-09-24 12:04:40 +03:00
Dmitriy Zaporozhets 3aa7132adc Add GitAccess specs 2014-09-24 11:37:30 +03:00