Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Don't allow access to the hidden global team
Browse files Browse the repository at this point in the history
The link to the global team is now hidden. If a user tries to access it
anyway, the user is presented with a 404 error.

Fixes #658

Signed-off-by: Thomas Hipp <thipp@suse.com>
  • Loading branch information
Thomas Hipp committed Apr 6, 2016
1 parent ad58ffe commit a540fd5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def index
# GET /teams/1
# GET /teams/1.json
def show
raise ActiveRecord::RecordNotFound if @team.name.starts_with?("portus_global_team_")

authorize @team
@team_users = @team.team_users.enabled.page(params[:users_page]).per(10)
@team_namespaces = @team.namespaces.page(params[:namespaces_page]).per(15)
Expand Down
7 changes: 4 additions & 3 deletions app/views/namespaces/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
'Namespace:
strong
= @namespace.clean_name
h6.label.label-info
| <span>Belongs to: </span>
= link_to "#{@namespace.team.name}", @namespace.team
- unless @namespace.global?
h6.label.label-info
| <span>Belongs to: </span>
= link_to "#{@namespace.team.name}", @namespace.team
.panel-body
.table-responsive
table.table.table-stripped.table-hover
Expand Down
11 changes: 11 additions & 0 deletions spec/controllers/teams_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

let(:owner) { create(:user) }
let(:team) { create(:team, description: "short test description", owners: [owner]) }
let(:hidden_team) do
create(:team, name: "portus_global_team_1",
description: "short test description", owners: [owner],
hidden: true)
end

describe "GET #show" do

Expand Down Expand Up @@ -42,6 +47,12 @@
expect(response.status).to eq 401
end

it "drops requests to a hidden global team" do
sign_in owner

expect { get :show, id: hidden_team.id }.to raise_error(ActiveRecord::RecordNotFound)
end

it "does not display disabled users" do
user = create(:user, enabled: false)
TeamUser.create(team: team, user: user, role: TeamUser.roles["viewer"])
Expand Down

0 comments on commit a540fd5

Please sign in to comment.