From 768da57fe4aeb9fddc96620d5a91d5a2974e438d Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:28:50 -0700 Subject: clarify when database.yml needs to be updated Clarify that database.yml should be updated if you are running a MySQL Database. Remove wording that de-emphasises importance of update. --- doc/update/7.3-to-7.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index 193f44bb67e..c50eb01d279 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -101,7 +101,7 @@ timeout 60 * HTTPS setups: Make `/etc/nginx/sites-available/nginx-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your setting -#### Update database.yml config file(for mysql only) if needed (basically it is required for old gitlab installations) +#### MySQL Databases: Update database.yml config file * Add `collation: utf8_general_ci` to config/database.yml as seen in [config/database.yml.mysql](config/database.yml.mysql) -- cgit v1.2.1 From 35b1a036d79382c9311d4c6fac0cdbefb067e940 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:33:51 -0700 Subject: stop gitlab before mysql optimizations, run checks Update MySQL optimizations to reflect doing updates after GitLab has already been started back up. --- doc/update/7.3-to-7.4.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index 193f44bb67e..e8d72bf2310 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -134,6 +134,9 @@ More details can be found at the [integration documentation](../integration/goog Only applies if running MySQL database created with GitLab 6.7 or earlier. If you are not experiencing any issues you may not need the following instructions however following them will bring your database in line with the latest recommended installation configuration and help avoid future issues. Be sure to follow these directions exactly. These directions should be safe for any MySQL instance but to be sure make a current MySQL database backup beforehand. ``` +# Stop GitLab +sudo service gitlab stop + # Secure your MySQL installation (added in GitLab 6.2) sudo mysql_secure_installation @@ -195,6 +198,9 @@ mysql> \q # Set production -> username: git # Set production -> password: the password your replaced $password with earlier sudo -u git -H editor /home/git/gitlab/config/database.yml + +# Run thorough check +sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production ``` -- cgit v1.2.1 From 76e2ae8148e8fd72048cc1c9d57e5b5f5452aae9 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:39:01 -0700 Subject: actually give command necessary to update unicorn Give command to update unicorn.rb rather than just say you need to do it. --- doc/update/7.3-to-7.4.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index 193f44bb67e..045e611b3e9 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -93,8 +93,8 @@ git diff origin/7-3-stable:config/gitlab.yml.example origin/7-4-stable:config/gi #### Change timeout for unicorn ``` -# config/unicorn.rb -timeout 60 +# set timeout to 60 +sudo -u git -H editor config/unicorn.rb ``` #### Change nginx https settings -- cgit v1.2.1 From 9a92e53f622f29388851f25abe191dad38e35516 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:49:59 -0700 Subject: stop gitlab before backup Stopping gitlab before backup ensures that backup has everything before upgrade incase something goes wrong. Also remove extra cd. --- doc/update/7.3-to-7.4.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index 193f44bb67e..6ef91913bbf 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -1,22 +1,18 @@ # From 7.3 to 7.4 -### 0. Backup +### 0. Stop server -```bash -cd /home/git/gitlab -sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production -``` + sudo service gitlab stop -### 1. Stop server +### 1. Backup ```bash -sudo service gitlab stop -``` +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production ### 2. Get latest code ```bash -cd /home/git/gitlab sudo -u git -H git fetch --all sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically ``` -- cgit v1.2.1 From 3e6b284bd0cf597f6446e1990a53acb806fb359a Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 01:51:35 -0700 Subject: stop gitlab before backup --- doc/update/6.x-or-7.x-to-7.4.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/update/6.x-or-7.x-to-7.4.md b/doc/update/6.x-or-7.x-to-7.4.md index e923060223b..c332e5fe267 100644 --- a/doc/update/6.x-or-7.x-to-7.4.md +++ b/doc/update/6.x-or-7.x-to-7.4.md @@ -13,7 +13,11 @@ possible to edit the label text and color. The characters `?`, `&` and `,` are no longer allowed however so those will be removed from your tags during the database migrations for GitLab 7.2. -## 0. Backup +## 0. Stop server + + sudo service gitlab stop + +## 1. Backup It's useful to make a backup just in case things go south: (With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version) @@ -23,10 +27,6 @@ cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production ``` -## 1. Stop server - - sudo service gitlab stop - ## 2. Update Ruby If you are still using Ruby 1.9.3 or below, you will need to update Ruby. -- cgit v1.2.1 From 0ff6105589960bc617b8e974874f1f22a5841ad0 Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 02:08:01 -0700 Subject: add missing configure Redis to use sockets Add details from 7.2-to-7.3.md. Replaces https://github.com/gitlabhq/gitlabhq/pull/8047. --- doc/update/6.x-or-7.x-to-7.4.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/update/6.x-or-7.x-to-7.4.md b/doc/update/6.x-or-7.x-to-7.4.md index e923060223b..4b7ed03f49e 100644 --- a/doc/update/6.x-or-7.x-to-7.4.md +++ b/doc/update/6.x-or-7.x-to-7.4.md @@ -99,6 +99,8 @@ sudo apt-get install pkg-config cmake sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf # Enable Redis socket for default Debian / Ubuntu path echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf + # Be sure redis group can write to the socket, enable only if supported (>= redis 2.4.0). + sudo sed -i '/# unixsocketperm/ s/^# unixsocketperm.*/unixsocketperm 0775/' /etc/redis/redis.conf # Activate the changes to redis.conf sudo service redis-server restart # Add git to the redis group -- cgit v1.2.1 From 4880b91ff1be9dda28dfe2b3feb0cd746cadf73e Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Sat, 18 Oct 2014 02:13:15 -0700 Subject: add optimizations for mysql to 6.x->7.4 guide Add mysql optimizations from 7.3-to-7.4.md. --- doc/update/6.x-or-7.x-to-7.4.md | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/doc/update/6.x-or-7.x-to-7.4.md b/doc/update/6.x-or-7.x-to-7.4.md index e923060223b..5d2264c108b 100644 --- a/doc/update/6.x-or-7.x-to-7.4.md +++ b/doc/update/6.x-or-7.x-to-7.4.md @@ -196,6 +196,76 @@ When using Google omniauth login, changes of the Google account required. Ensure that `Contacts API` and the `Google+ API` are enabled in the [Google Developers Console](https://console.developers.google.com/). More details can be found at the [integration documentation](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/integration/google.md). +## 12. Optional optimizations for GitLab setups with MySQL databases + +Only applies if running MySQL database created with GitLab 6.7 or earlier. If you are not experiencing any issues you may not need the following instructions however following them will bring your database in line with the latest recommended installation configuration and help avoid future issues. Be sure to follow these directions exactly. These directions should be safe for any MySQL instance but to be sure make a current MySQL database backup beforehand. + +``` +# Stop GitLab +sudo service gitlab stop + +# Secure your MySQL installation (added in GitLab 6.2) +sudo mysql_secure_installation + +# Login to MySQL +mysql -u root -p + +# do not type the 'mysql>', this is part of the prompt + +# Convert all tables to use the InnoDB storage engine (added in GitLab 6.8) +SELECT CONCAT('ALTER TABLE gitlabhq_production.', table_name, ' ENGINE=InnoDB;') AS 'Copy & run these SQL statements:' FROM information_schema.tables WHERE table_schema = 'gitlabhq_production' AND `ENGINE` <> 'InnoDB' AND `TABLE_TYPE` = 'BASE TABLE'; + +# If previous query returned results, copy & run all outputed SQL statements + +# Convert all tables to correct character set +SET foreign_key_checks = 0; +SELECT CONCAT('ALTER TABLE gitlabhq_production.', table_name, ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') AS 'Copy & run these SQL statements:' FROM information_schema.tables WHERE table_schema = 'gitlabhq_production' AND `TABLE_COLLATION` <> 'utf8_unicode_ci' AND `TABLE_TYPE` = 'BASE TABLE'; + +# If previous query returned results, copy & run all outputed SQL statements + +# turn foreign key checks back on +SET foreign_key_checks = 1; + +# Find MySQL users +mysql> SELECT user FROM mysql.user WHERE user LIKE '%git%'; + +# If git user exists and gitlab user does not exist +# you are done with the database cleanup tasks +mysql> \q + +# If both users exist skip to Delete gitlab user + +# Create new user for GitLab (changed in GitLab 6.4) +# change $password in the command below to a real password you pick +mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; + +# Grant the git user necessary permissions on the database +mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO 'git'@'localhost'; + +# Delete the old gitlab user +mysql> DELETE FROM mysql.user WHERE user='gitlab'; + +# Quit the database session +mysql> \q + +# Try connecting to the new database with the new user +sudo -u git -H mysql -u git -p -D gitlabhq_production + +# Type the password you replaced $password with earlier + +# You should now see a 'mysql>' prompt + +# Quit the database session +mysql> \q + +# Update database configuration details +# See config/database.yml.mysql for latest recommended configuration details +# Remove the reaping_frequency setting line if it exists (removed in GitLab 6.8) +# Set production -> pool: 10 (updated in GitLab 5.3) +# Set production -> username: git +# Set production -> password: the password your replaced $password with earlier +sudo -u git -H editor /home/git/gitlab/config/database.yml + ## Things went south? Revert to previous version (6.0) ### 1. Revert the code to the previous version -- cgit v1.2.1 From 082d59d21f7f8857eca2715c1a58fbce30f9b92d Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 20 Oct 2014 10:52:29 +0200 Subject: Ask the wiki repo, not Gollum, if it's empty We need to skip empty repositories when creating a backup. Before this change, we were asking gollum-lib if the wiki contains any _pages_. Now we ask gitlab_git if the repository contains _files_. This should resolve gollum_lib Grit timeouts in the backup script. --- lib/backup/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 4e99d4bbe5c..380beac708d 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -30,7 +30,7 @@ module Backup if File.exists?(path_to_repo(wiki)) print " * #{wiki.path_with_namespace} ... " - if wiki.empty? + if wiki.repository.empty? puts " [SKIPPED]".cyan else output, status = Gitlab::Popen.popen(%W(git --git-dir=#{path_to_repo(wiki)} bundle create #{path_to_bundle(wiki)} --all)) -- cgit v1.2.1 From ebc0a7050afe71f5c30341dcf6b15da76b810408 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 20 Oct 2014 12:59:16 +0300 Subject: Fix group user removal from admin area Signed-off-by: Dmitriy Zaporozhets --- app/views/admin/groups/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index c1a9214b77a..1da6e4c5f1a 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -80,7 +80,7 @@ = link_to user.name, admin_user_path(user) %span.pull-right.light = member.human_access - = link_to group_group_members_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do + = link_to group_group_member_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do %i.fa.fa-minus.fa-inverse .panel-footer = paginate @members, param_name: 'members_page', theme: 'gitlab' -- cgit v1.2.1 From 644fd232dbe827aaae46068119345c2344495239 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 20 Oct 2014 13:18:07 +0300 Subject: Add tests for remove group member feature in admin area Signed-off-by: Dmitriy Zaporozhets --- app/controllers/groups/group_members_controller.rb | 1 + app/views/admin/groups/show.html.haml | 2 +- features/admin/groups.feature | 7 +++++++ features/steps/admin/groups.rb | 23 ++++++++++++++++++++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index 63c05d4f33b..ca88d033878 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -19,6 +19,7 @@ class Groups::GroupMembersController < ApplicationController def destroy @users_group = @group.group_members.find(params[:id]) + if can?(current_user, :destroy, @users_group) # May fail if last owner. @users_group.destroy respond_to do |format| diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 1da6e4c5f1a..4494acc4842 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -74,7 +74,7 @@ %ul.well-list.group-users-list - @members.each do |member| - user = member.user - %li{class: dom_class(user)} + %li{class: dom_class(member), id: dom_id(user)} .list-item-name %strong = link_to user.name, admin_user_path(user) diff --git a/features/admin/groups.feature b/features/admin/groups.feature index 1a465c1be55..aa365a6ea1a 100644 --- a/features/admin/groups.feature +++ b/features/admin/groups.feature @@ -20,3 +20,10 @@ Feature: Admin Groups When I visit admin group page When I select user "John Doe" from user list as "Reporter" Then I should see "John Doe" in team list in every project as "Reporter" + + @javascript + Scenario: Remove user from group + Given we have user "John Doe" in group + When I visit admin group page + And I remove user "John Doe" from group + Then I should not see "John Doe" in team list diff --git a/features/steps/admin/groups.rb b/features/steps/admin/groups.rb index 4f0ba05606d..d69a87cd07e 100644 --- a/features/steps/admin/groups.rb +++ b/features/steps/admin/groups.rb @@ -37,8 +37,7 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps end When 'I select user "John Doe" from user list as "Reporter"' do - user = User.find_by(name: "John Doe") - select2(user.id, from: "#user_ids", multiple: true) + select2(user_john.id, from: "#user_ids", multiple: true) within "#new_team_member" do select "Reporter", from: "access_level" end @@ -58,9 +57,29 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps end end + step 'we have user "John Doe" in group' do + current_group.add_user(user_john, Gitlab::Access::REPORTER) + end + + step 'I remove user "John Doe" from group' do + within "#user_#{user_john.id}" do + click_link 'Remove user from group' + end + end + + step 'I should not see "John Doe" in team list' do + within ".group-users-list" do + page.should_not have_content "John Doe" + end + end + protected def current_group @group ||= Group.first end + + def user_john + @user_john ||= User.find_by(name: "John Doe") + end end -- cgit v1.2.1 From 49bd9812000626af71c1b7b00d9f998fcaca2a46 Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Fri, 17 Oct 2014 18:03:34 +0200 Subject: Prevent redeclaration of LDAP strategy --- config/initializers/7_omniauth.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/initializers/7_omniauth.rb b/config/initializers/7_omniauth.rb index b8ac87fbd5a..18759f0cfb0 100644 --- a/config/initializers/7_omniauth.rb +++ b/config/initializers/7_omniauth.rb @@ -1,7 +1,8 @@ if Gitlab::LDAP::Config.enabled? module OmniAuth::Strategies server = Gitlab.config.ldap.servers.values.first - const_set(server['provider_class'], Class.new(LDAP)) + klass = server['provider_class'] + const_set(klass, Class.new(LDAP)) unless klass == 'LDAP' end OmniauthCallbacksController.class_eval do -- cgit v1.2.1 From 3d3726a026f465a441abd7438de85790d9d84d94 Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Fri, 17 Oct 2014 18:08:26 +0200 Subject: Default the LDAP server label to LDAP --- config/initializers/1_settings.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 7e7c91ced77..88cbaefea7d 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -61,7 +61,6 @@ Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil? if Settings.ldap['enabled'] || Rails.env.test? if Settings.ldap['host'].present? server = Settings.ldap.except('sync_time') - server['label'] = 'LDAP' server['provider_name'] = 'ldap' Settings.ldap['servers'] = { 'ldap' => server @@ -69,6 +68,7 @@ if Settings.ldap['enabled'] || Rails.env.test? end Settings.ldap['servers'].each do |key, server| + server['label'] ||= 'LDAP' server['allow_username_or_email_login'] = false if server['allow_username_or_email_login'].nil? server['active_directory'] = true if server['active_directory'].nil? server['provider_name'] ||= "ldap#{key}".downcase -- cgit v1.2.1 From db5ea013f4a75b6f6b6cf7fd43011f5c2c29fda1 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Thu, 25 Sep 2014 16:43:23 +0200 Subject: Use :message key, not :error for File::Service. --- app/controllers/projects/blob_controller.rb | 2 +- app/controllers/projects/edit_tree_controller.rb | 2 +- app/services/files/base_service.rb | 6 ------ features/project/source/browse_files.feature | 20 ++++++++++++++++++++ features/steps/project/source/browse_files.rb | 8 ++++++++ features/steps/shared/paths.rb | 9 +++++++++ lib/api/files.rb | 6 +++--- 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 7009e3b1bc8..0944c7421ee 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -20,7 +20,7 @@ class Projects::BlobController < Projects::ApplicationController flash[:notice] = "Your changes have been successfully committed" redirect_to project_tree_path(@project, @ref) else - flash[:alert] = result[:error] + flash[:alert] = result[:message] render :show end end diff --git a/app/controllers/projects/edit_tree_controller.rb b/app/controllers/projects/edit_tree_controller.rb index 8976d7c7be8..fdc1a85d8d7 100644 --- a/app/controllers/projects/edit_tree_controller.rb +++ b/app/controllers/projects/edit_tree_controller.rb @@ -22,7 +22,7 @@ class Projects::EditTreeController < Projects::BaseTreeController redirect_to after_edit_path else - flash[:alert] = result[:error] + flash[:alert] = result[:message] render :show end end diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb index db6f0831f8b..bd245100955 100644 --- a/app/services/files/base_service.rb +++ b/app/services/files/base_service.rb @@ -10,12 +10,6 @@ module Files private - def success - out = super() - out[:error] = '' - out - end - def repository project.repository end diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature index aca255b9444..b7d70881d56 100644 --- a/features/project/source/browse_files.feature +++ b/features/project/source/browse_files.feature @@ -34,6 +34,16 @@ Feature: Project Source Browse Files Then I am redirected to the new file And I should see its new content + @javascript + Scenario: If I enter an illegal file name I see an error message + Given I click on "new file" link in repo + And I fill the new file name with an illegal name + And I edit code + And I fill the commit message + And I click on "Commit changes" + Then I am on the new file page + And I see a commit error message + @javascript Scenario: I can edit file Given I click on ".gitignore" file in repo @@ -50,6 +60,16 @@ Feature: Project Source Browse Files Then I am redirected to the ".gitignore" And I should see its new content + @javascript @wip + Scenario: If I don't change the content of the file I see an error message + Given I click on ".gitignore" file in repo + And I click button "edit" + And I fill the commit message + And I click on "Commit changes" + # Test fails because carriage returns are added to the file. + Then I am on the ".gitignore" edit file page + And I see a commit error message + @javascript Scenario: I can see editing preview Given I click on ".gitignore" file in repo diff --git a/features/steps/project/source/browse_files.rb b/features/steps/project/source/browse_files.rb index 20f8f6c24ae..665f5d6d195 100644 --- a/features/steps/project/source/browse_files.rb +++ b/features/steps/project/source/browse_files.rb @@ -61,6 +61,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps fill_in :file_name, with: new_file_name end + step 'I fill the new file name with an illegal name' do + fill_in :file_name, with: '.git' + end + step 'I fill the commit message' do fill_in :commit_message, with: 'Not yet a commit message.' end @@ -151,6 +155,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps expect(page).not_to have_link('permalink') end + step 'I see a commit error message' do + expect(page).to have_content('Your changes could not be committed') + end + private def set_new_content diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 1f238f8befd..5f292255ce1 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -265,6 +265,15 @@ module SharedPaths visit project_blob_path(@project, File.join(root_ref, '.gitignore')) end + step 'I am on the new file page' do + current_path.should eq(project_new_tree_path(@project, root_ref)) + end + + step 'I am on the ".gitignore" edit file page' do + current_path.should eq(project_edit_tree_path( + @project, File.join(root_ref, '.gitignore'))) + end + step 'I visit project source page for "6d39438"' do visit project_tree_path(@project, "6d39438") end diff --git a/lib/api/files.rb b/lib/api/files.rb index e63e635a4d3..84e1d311781 100644 --- a/lib/api/files.rb +++ b/lib/api/files.rb @@ -85,7 +85,7 @@ module API branch_name: branch_name } else - render_api_error!(result[:error], 400) + render_api_error!(result[:message], 400) end end @@ -117,7 +117,7 @@ module API branch_name: branch_name } else - render_api_error!(result[:error], 400) + render_api_error!(result[:message], 400) end end @@ -149,7 +149,7 @@ module API branch_name: branch_name } else - render_api_error!(result[:error], 400) + render_api_error!(result[:message], 400) end end end -- cgit v1.2.1 From b1e60cfa1b56d01c2328ebe2a3d49cd82058f981 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 21 Oct 2014 13:20:59 +0300 Subject: remove unnecessary parts from update doc --- doc/update/7.3-to-7.4.md | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index c1a70ba4e60..b3eaa3bdce5 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -52,31 +52,7 @@ sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab ``` - -### 4. Configure Redis to use sockets - - # Configure redis to use sockets - sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig - # Disable Redis listening on TCP by setting 'port' to 0 - sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf - # Enable Redis socket for default Debian / Ubuntu path - echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf - # Be sure redis group can write to the socket, enable only if supported (>= redis 2.4.0). - sed -i '/# unixsocketperm/ s/^# unixsocketperm.*/unixsocketperm 0775/' /etc/redis/redis.conf - # Activate the changes to redis.conf - sudo service redis-server restart - # Add git to the redis group - sudo usermod -aG redis git - - # Configure Redis connection settings - sudo -u git -H cp config/resque.yml.example config/resque.yml - # Change the Redis socket path if you are not using the default Debian / Ubuntu configuration - sudo -u git -H editor config/resque.yml - - # Configure gitlab-shell to use Redis sockets - sudo -u git -H sed -i 's|^ # socket.*| socket: /var/run/redis/redis.sock|' /home/git/gitlab-shell/config.yml - -### 5. Update config files +### 4. Update config files #### New configuration options for gitlab.yml @@ -102,12 +78,12 @@ sudo -u git -H editor config/unicorn.rb * Add `collation: utf8_general_ci` to config/database.yml as seen in [config/database.yml.mysql](config/database.yml.mysql) -### 6. Start application +### 5. Start application sudo service gitlab start sudo service nginx restart -### 7. Check application status +### 6. Check application status Check if GitLab and its environment are configured correctly: @@ -119,13 +95,8 @@ To make sure you didn't miss anything run a more thorough check with: If all items are green, then congratulations upgrade is complete! -### 8. Update OmniAuth configuration - -When using Google omniauth login, changes of the Google account required. -Ensure that `Contacts API` and the `Google+ API` are enabled in the [Google Developers Console](https://console.developers.google.com/). -More details can be found at the [integration documentation](../integration/google.md). -### 9. Optional optimizations for GitLab setups with MySQL databases +### 7. Optional optimizations for GitLab setups with MySQL databases Only applies if running MySQL database created with GitLab 6.7 or earlier. If you are not experiencing any issues you may not need the following instructions however following them will bring your database in line with the latest recommended installation configuration and help avoid future issues. Be sure to follow these directions exactly. These directions should be safe for any MySQL instance but to be sure make a current MySQL database backup beforehand. -- cgit v1.2.1 From 9f54397f3a3e094665d25109a63f24757a19df3a Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 21 Oct 2014 11:38:41 +0200 Subject: Use allowed slack team name. --- app/models/project_services/slack_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb index 95f3ddcef45..837002ef3c8 100644 --- a/app/models/project_services/slack_service.rb +++ b/app/models/project_services/slack_service.rb @@ -40,7 +40,8 @@ class SlackService < Service project_name: project_name )) - credentials = webhook.match(/(\w*).slack.com.*services\/(.*)/) + credentials = webhook.match(/([\w-]*).slack.com.*services\/(.*)/) + if credentials.present? subdomain = credentials[1] token = credentials[2].split("token=").last -- cgit v1.2.1 From 536f61e0e77227828d363a7008bd39b0e9fd43a7 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 21 Oct 2014 11:33:26 +0200 Subject: Add test for allowed team name of slack. --- spec/models/slack_service_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/models/slack_service_spec.rb b/spec/models/slack_service_spec.rb index 95df38d9400..526165e397c 100644 --- a/spec/models/slack_service_spec.rb +++ b/spec/models/slack_service_spec.rb @@ -77,5 +77,25 @@ describe SlackService do WebMock.should have_requested(:post, api_url).once end end + + context 'with new webhook syntax with slack allowed team name' do + before do + @allowed_webhook = 'https://gitlab-hq-123.slack.com/services/hooks/incoming-webhook?token=cdIj4r4LfXUOySDUjp0tk3OI' + slack_service.stub( + project: project, + project_id: project.id, + service_hook: true, + webhook: @allowed_webhook + ) + + WebMock.stub_request(:post, @allowed_webhook) + end + + it "should call Slack API" do + slack_service.execute(sample_data) + + WebMock.should have_requested(:post, @allowed_webhook).once + end + end end end -- cgit v1.2.1 From be80837a6941abe48d99acad1c3eb8a9957a0b42 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 21 Oct 2014 19:12:52 +0300 Subject: Update Guide: Change path to nginx config --- doc/update/6.x-or-7.x-to-7.4.md | 4 ++-- doc/update/7.3-to-7.4.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/update/6.x-or-7.x-to-7.4.md b/doc/update/6.x-or-7.x-to-7.4.md index 8516c3babaa..2fa6889af73 100644 --- a/doc/update/6.x-or-7.x-to-7.4.md +++ b/doc/update/6.x-or-7.x-to-7.4.md @@ -160,8 +160,8 @@ git diff 6-0-stable:config/gitlab.yml.example 7-4-stable:config/gitlab.yml.examp * Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/config/gitlab.yml.example but with your settings. * Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/config/unicorn.rb.example but with your settings. * Make `/home/git/gitlab-shell/config.yml` the same as https://gitlab.com/gitlab-org/gitlab-shell/blob/v2.0.1/config.yml.example but with your settings. -* HTTP setups: Make `/etc/nginx/sites-available/nginx` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab but with your settings. -* HTTPS setups: Make `/etc/nginx/sites-available/nginx-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your settings. +* HTTP setups: Make `/etc/nginx/sites-available/gitlab` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab but with your settings. +* HTTPS setups: Make `/etc/nginx/sites-available/gitlab-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your settings. * Copy rack attack middleware config ```bash diff --git a/doc/update/7.3-to-7.4.md b/doc/update/7.3-to-7.4.md index b3eaa3bdce5..69d86fb06ed 100644 --- a/doc/update/7.3-to-7.4.md +++ b/doc/update/7.3-to-7.4.md @@ -71,7 +71,7 @@ sudo -u git -H editor config/unicorn.rb #### Change nginx https settings -* HTTPS setups: Make `/etc/nginx/sites-available/nginx-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your setting +* HTTPS setups: Make `/etc/nginx/sites-available/gitlab-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your setting #### MySQL Databases: Update database.yml config file -- cgit v1.2.1 From 37e09858e8f6dec949f004a933eef8346ddc97d4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 21 Oct 2014 18:26:40 +0300 Subject: Fix rake gitlab:ldap:check Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/ldap/adapter.rb | 6 +++++- lib/tasks/gitlab/check.rake | 40 ++++++++++------------------------------ 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index c4d0a20d89a..256cdb4c2f1 100644 --- a/lib/gitlab/ldap/adapter.rb +++ b/lib/gitlab/ldap/adapter.rb @@ -22,7 +22,7 @@ module Gitlab Gitlab::LDAP::Config.new(provider) end - def users(field, value) + def users(field, value, limit = nil) if field.to_sym == :dn options = { base: value, @@ -45,6 +45,10 @@ module Gitlab end end + if limit.present? + options.merge!(size: limit) + end + entries = ldap_search(options).select do |entry| entry.respond_to? config.uid end diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 9ec368254ac..707d236068e 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -664,7 +664,7 @@ namespace :gitlab do warn_user_is_not_gitlab start_checking "LDAP" - if ldap_config.enabled + if Gitlab::LDAP::Config.enabled? print_users(args.limit) else puts 'LDAP is disabled in config/gitlab.yml' @@ -675,39 +675,19 @@ namespace :gitlab do def print_users(limit) puts "LDAP users with access to your GitLab server (only showing the first #{limit} results)" - ldap.search(attributes: attributes, filter: filter, size: limit, return_result: false) do |entry| - puts "DN: #{entry.dn}\t#{ldap_config.uid}: #{entry[ldap_config.uid]}" - end - end - - def attributes - [ldap_config.uid] - end - def filter - uid_filter = Net::LDAP::Filter.present?(ldap_config.uid) - if user_filter - Net::LDAP::Filter.join(uid_filter, user_filter) - else - uid_filter - end - end + servers = Gitlab.config.ldap.servers.keys - def user_filter - if ldap_config['user_filter'] && ldap_config.user_filter.present? - Net::LDAP::Filter.construct(ldap_config.user_filter) - else - nil + servers.each do |server| + puts "Server: #{server}" + Gitlab::LDAP::Adapter.open("ldap#{server}") do |adapter| + users = adapter.users(adapter.config.uid, '*', 100) + users.each do |user| + puts "\tDN: #{user.dn}\t #{adapter.config.uid}: #{user.uid}" + end + end end end - - def ldap - @ldap ||= OmniAuth::LDAP::Adaptor.new(ldap_config).connection - end - - def ldap_config - @ldap_config ||= Gitlab.config.ldap - end end # Helper methods -- cgit v1.2.1 From 4c034142a13c2e82e62b6f27a61e371b463310fb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 22 Oct 2014 11:11:18 +0300 Subject: Make gitlab ldap check work for old and new syntax Signed-off-by: Dmitriy Zaporozhets --- lib/tasks/gitlab/check.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 707d236068e..56e8ff44988 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -676,11 +676,11 @@ namespace :gitlab do def print_users(limit) puts "LDAP users with access to your GitLab server (only showing the first #{limit} results)" - servers = Gitlab.config.ldap.servers.keys + servers = Gitlab::LDAP::Config.providers servers.each do |server| puts "Server: #{server}" - Gitlab::LDAP::Adapter.open("ldap#{server}") do |adapter| + Gitlab::LDAP::Adapter.open(server) do |adapter| users = adapter.users(adapter.config.uid, '*', 100) users.each do |user| puts "\tDN: #{user.dn}\t #{adapter.config.uid}: #{user.uid}" -- cgit v1.2.1 From ed00ab75214389d108a857a22027f221a6649fbe Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 22 Oct 2014 12:42:41 +0000 Subject: Merge branch 'fix-500-login-disabled' into 'master' Fix 500 error on login page if ldap enabled and sign-in disabled Related to gitlab/gitlabhq#1701 See merge request !1209 --- app/views/devise/sessions/new.html.haml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index b9832787446..ca7e9570b43 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -2,22 +2,22 @@ .login-heading %h3 Sign in .login-body - - if ldap_enabled? && gitlab_config.signin_enabled + - if ldap_enabled? %ul.nav.nav-tabs - @ldap_servers.each_with_index do |server, i| - %li{class: (:active if i==0)} + %li{class: (:active if i.zero?)} = link_to server['label'], "#tab-#{server['provider_name']}", 'data-toggle' => 'tab' - %li - = link_to 'Standard', '#tab-signin', 'data-toggle' => 'tab' + - if gitlab_config.signin_enabled + %li + = link_to 'Standard', '#tab-signin', 'data-toggle' => 'tab' .tab-content - - @ldap_servers.each_with_index do |server,i| - %div.tab-pane{id: "tab-#{server['provider_name']}", class: (:active if i==0)} + - @ldap_servers.each_with_index do |server, i| + %div.tab-pane{id: "tab-#{server['provider_name']}", class: (:active if i.zero?)} = render 'devise/sessions/new_ldap', provider: server['provider_name'] - %div#tab-signin.tab-pane - = render 'devise/sessions/new_base' + - if gitlab_config.signin_enabled + %div#tab-signin.tab-pane + = render 'devise/sessions/new_base' - - elsif ldap_enabled? - = render 'devise/sessions/new_ldap', ldap_servers: @ldap_servers - elsif gitlab_config.signin_enabled = render 'devise/sessions/new_base' - else -- cgit v1.2.1 From ba76dbc3667c2eb0a1a3687f8b0481e619946d73 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 22 Oct 2014 15:42:43 +0200 Subject: Version 7.4.0. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7b65f139cb2..ba7f754d0c3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.4.0.rc1 +7.4.0 -- cgit v1.2.1 From e8da077d4f9b63d7d7157416dbf0dad010ea90bd Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 23 Oct 2014 14:21:21 +0200 Subject: Fix LDAP authentication for Git HTTP access Conflicts: CHANGELOG --- CHANGELOG | 3 +++ lib/gitlab/ldap/authentication.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 05290698320..561a23538e7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +v 7.4.1 + - Fix LDAP authentication for Git HTTP access + v 7.4.0 - Refactored membership logic - Improve error reporting on users API (Julien Bianchi) diff --git a/lib/gitlab/ldap/authentication.rb b/lib/gitlab/ldap/authentication.rb index a5944f96983..8af2c74e959 100644 --- a/lib/gitlab/ldap/authentication.rb +++ b/lib/gitlab/ldap/authentication.rb @@ -42,7 +42,7 @@ module Gitlab end def adapter - OmniAuth::LDAP::Adaptor.new(config.options) + OmniAuth::LDAP::Adaptor.new(config.options.symbolize_keys) end def config @@ -68,4 +68,4 @@ module Gitlab end end end -end \ No newline at end of file +end -- cgit v1.2.1 From 5f7906e1635baa1aca12527ac9d9f8e84323e95d Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 24 Oct 2014 11:52:52 +0300 Subject: fix for public snippet --- app/controllers/snippets_controller.rb | 2 +- features/snippets/public_snippets.feature | 5 +++++ features/snippets/snippets.feature | 2 +- features/steps/shared/snippet.rb | 9 +++++++++ features/steps/snippets/public_snippets.rb | 17 +++++++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 features/snippets/public_snippets.feature create mode 100644 features/steps/snippets/public_snippets.rb diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 30fb4c5552d..987694260c6 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -9,7 +9,7 @@ class SnippetsController < ApplicationController before_filter :set_title - skip_before_filter :authenticate_user!, only: [:index, :user_index] + skip_before_filter :authenticate_user!, only: [:index, :user_index, :show] respond_to :html diff --git a/features/snippets/public_snippets.feature b/features/snippets/public_snippets.feature new file mode 100644 index 00000000000..6964badc413 --- /dev/null +++ b/features/snippets/public_snippets.feature @@ -0,0 +1,5 @@ +Feature: Public snippets + Scenario: Unauthenticated user should see public snippets + Given There is public "Personal snippet one" snippet + And I visit snippet page "Personal snippet one" + Then I should see snippet "Personal snippet one" diff --git a/features/snippets/snippets.feature b/features/snippets/snippets.feature index 4c4e3ee2cff..6e8019c326f 100644 --- a/features/snippets/snippets.feature +++ b/features/snippets/snippets.feature @@ -25,4 +25,4 @@ Feature: Snippets Scenario: I destroy "Personal snippet one" Given I visit snippet page "Personal snippet one" And I click link "Destroy" - Then I should not see "Personal snippet one" in snippets + Then I should not see "Personal snippet one" in snippets \ No newline at end of file diff --git a/features/steps/shared/snippet.rb b/features/steps/shared/snippet.rb index 432f32defce..bb596c1620a 100644 --- a/features/steps/shared/snippet.rb +++ b/features/steps/shared/snippet.rb @@ -51,4 +51,13 @@ module SharedSnippet visibility_level: Snippet::PUBLIC, author: current_user) end + + step 'There is public "Personal snippet one" snippet' do + create(:personal_snippet, + title: "Personal snippet one", + content: "Test content", + file_name: "snippet.rb", + visibility_level: Snippet::PUBLIC, + author: create(:user)) + end end diff --git a/features/steps/snippets/public_snippets.rb b/features/steps/snippets/public_snippets.rb new file mode 100644 index 00000000000..956aa4a3e7e --- /dev/null +++ b/features/steps/snippets/public_snippets.rb @@ -0,0 +1,17 @@ +class Spinach::Features::PublicSnippets < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedSnippet + + step 'I should see snippet "Personal snippet one"' do + page.should have_no_xpath("//i[@class='public-snippet']") + end + + step 'I visit snippet page "Personal snippet one"' do + visit snippet_path(snippet) + end + + def snippet + @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one") + end +end -- cgit v1.2.1 From 16a10eb1cd4a5447da9d50b1eba25f020dc8f6b7 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 23 Oct 2014 22:57:16 +0200 Subject: Fix LDAP config lookup for provider 'ldap' --- CHANGELOG | 1 + lib/gitlab/ldap/config.rb | 27 ++++++++++++++++----------- spec/lib/gitlab/ldap/config_spec.rb | 16 +++++++++++++++- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 561a23538e7..5a494cccc69 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ v 7.4.1 - Fix LDAP authentication for Git HTTP access + - Fix LDAP config lookup for provider 'ldap' v 7.4.0 - Refactored membership logic diff --git a/lib/gitlab/ldap/config.rb b/lib/gitlab/ldap/config.rb index d41bfba9b0f..0cb24d0ccc1 100644 --- a/lib/gitlab/ldap/config.rb +++ b/lib/gitlab/ldap/config.rb @@ -16,10 +16,23 @@ module Gitlab servers.map {|server| server['provider_name'] } end + def self.valid_provider?(provider) + providers.include?(provider) + end + + def self.invalid_provider(provider) + raise "Unknown provider (#{provider}). Available providers: #{providers}" + end + def initialize(provider) - @provider = provider - invalid_provider unless valid_provider? - @options = config_for(provider) + if self.class.valid_provider?(provider) + @provider = provider + elsif provider == 'ldap' + @provider = self.class.providers.first + else + self.class.invalid_provider(provider) + end + @options = config_for(@provider) # Use @provider, not provider end def enabled? @@ -89,14 +102,6 @@ module Gitlab end end - def valid_provider? - self.class.providers.include?(provider) - end - - def invalid_provider - raise "Unknown provider (#{provider}). Available providers: #{self.class.providers}" - end - def auth_options { auth: { diff --git a/spec/lib/gitlab/ldap/config_spec.rb b/spec/lib/gitlab/ldap/config_spec.rb index 76cc7f95c47..3ebb8aae243 100644 --- a/spec/lib/gitlab/ldap/config_spec.rb +++ b/spec/lib/gitlab/ldap/config_spec.rb @@ -16,5 +16,19 @@ describe Gitlab::LDAP::Config do it "raises an error if a unknow provider is used" do expect{ Gitlab::LDAP::Config.new 'unknown' }.to raise_error end + + context "if 'ldap' is the provider name" do + let(:provider) { 'ldap' } + + context "and 'ldap' is not in defined as a provider" do + before { Gitlab::LDAP::Config.stub(providers: %w{ldapmain}) } + + it "uses the first provider" do + # Fetch the provider_name attribute from 'options' so that we know + # that the 'options' Hash is not empty/nil. + expect(config.options['provider_name']).to eq('ldapmain') + end + end + end end -end \ No newline at end of file +end -- cgit v1.2.1 From d4ae4fe670c75ffbb3974734aafbcdc667e53172 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 24 Oct 2014 11:25:39 +0200 Subject: Bump gitlab_git to 7.0.0.rc10 (submodules fix) --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index c6be76f4ecc..f6f3607cbd1 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ gem 'omniauth-shibboleth' # Extracting information from a git repository # Provide access to Gitlab::Git library -gem "gitlab_git", '7.0.0.rc9' +gem "gitlab_git", '7.0.0.rc10' # Ruby/Rack Git Smart-HTTP Server Handler gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' diff --git a/Gemfile.lock b/Gemfile.lock index 0e82f14ca9d..314884fa36e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,7 +179,7 @@ GEM mime-types (~> 1.19) gitlab_emoji (0.0.1.1) emoji (~> 1.0.1) - gitlab_git (7.0.0.rc9) + gitlab_git (7.0.0.rc10) activesupport (~> 4.0) charlock_holmes (~> 0.6) gitlab-linguist (~> 3.0) @@ -624,7 +624,7 @@ DEPENDENCIES gitlab-grack (~> 2.0.0.pre) gitlab-linguist (~> 3.0.0) gitlab_emoji (~> 0.0.1.1) - gitlab_git (= 7.0.0.rc9) + gitlab_git (= 7.0.0.rc10) gitlab_meta (= 7.0) gitlab_omniauth-ldap (= 1.1.0) gollum-lib (~> 3.0.0) -- cgit v1.2.1 From 9712fbcdd366c173e2ec277a617a4e690f6a86e9 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 24 Oct 2014 13:30:04 +0300 Subject: Bump to 7.4.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ba7f754d0c3..815da58b7a9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.4.0 +7.4.1 -- cgit v1.2.1 From 7f97a1277de78bcd86d68978e9ec29a2548fc144 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 24 Oct 2014 19:24:49 +0300 Subject: internal snippets: fix exposing of title --- CHANGELOG | 5 +++++ VERSION | 2 +- app/finders/snippets_finder.rb | 2 ++ spec/finders/snippets_finder_spec.rb | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5a494cccc69..4428bae4ebd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ +v 7.4.2 + - Fix internal snippet exposing for unauthenticated users + v 7.4.1 - Fix LDAP authentication for Git HTTP access - Fix LDAP config lookup for provider 'ldap' + - Fix public snippets + - Fix 500 error on projects with nested submodules v 7.4.0 - Refactored membership logic diff --git a/VERSION b/VERSION index 815da58b7a9..f8cb1fa110d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.4.1 +7.4.2 diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb index b29ab6cf40b..4b0c69f2d2f 100644 --- a/app/finders/snippets_finder.rb +++ b/app/finders/snippets_finder.rb @@ -29,6 +29,8 @@ class SnippetsFinder def by_user(current_user, user, scope) snippets = user.snippets.fresh.non_expired + return snippets.are_public unless current_user + if user == current_user case scope when 'are_internal' then diff --git a/spec/finders/snippets_finder_spec.rb b/spec/finders/snippets_finder_spec.rb index 5af76968183..c645cbc964c 100644 --- a/spec/finders/snippets_finder_spec.rb +++ b/spec/finders/snippets_finder_spec.rb @@ -64,6 +64,13 @@ describe SnippetsFinder do snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user) snippets.should include(@snippet1, @snippet2, @snippet3) end + + it "returns only public snippets if unauthenticated user" do + snippets = SnippetsFinder.new.execute(nil, filter: :by_user, user: user) + snippets.should include(@snippet3) + snippets.should_not include(@snippet2, @snippet1) + end + end context 'by_project filter' do -- cgit v1.2.1