mumuki-laboratory 5.11.0 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18f020ea8f88054e994d5e652d5ba0da08c502c1e49042d7906293695e396a82
4
- data.tar.gz: 49f403a38857fe24615f1c4429bc68927a621e9a714eabb5698815436f973466
3
+ metadata.gz: d1a14bc93fe037ed3d6ee6afa041dcd4c84d308011e819cffdd39b9c1fe5a7e2
4
+ data.tar.gz: 8f4fba71e09dab7bd831d8a2424a889b107e3e9b531c1b9d7a7ff3866d584c07
5
5
  SHA512:
6
- metadata.gz: 5255c69d3d6ce5834f5c58db4d0b0cc451bb52262997673911e6ee54729bc543768ac07650a124874306a921df9b1b4081ff8e87482ef8594a9afb06660561c0
7
- data.tar.gz: 16ba33bc9c99d07a865a17952aa5f7d4469d4532c5df5025677eaa926226c9aff94cdf3ef5817c007831356cdd124df417f629e2e366254f74d4150ab34e288d
6
+ metadata.gz: 0ee2606a772b5e0191e194f9c93cd1177247e1ba7d3407c40992a086d130059839b45ed5da6ea7ad89f1406fe48572bddd1190597f59ccf2718c17f897e56ed6
7
+ data.tar.gz: 496f224a3d84e678cefa614111eb8522b1e4d45539756db4708a9ca0a42b6c3d4ee73550e80fdcb9c71027ca5cadae6be043111980a600d43b0b6001016634b7
@@ -10,7 +10,7 @@ module UsersControllerTemplate
10
10
  private
11
11
 
12
12
  def protect_permissions_assignment!
13
- current_user.protect_permissions_assignment! user_params[:permissions], @user.permissions
13
+ current_user.protect_permissions_assignment! user_params[:permissions], @user.permissions_was
14
14
  end
15
15
 
16
16
  def user_params
@@ -2,8 +2,4 @@ module OrganizationListHelper
2
2
  def organizations_for(user)
3
3
  (user.accessible_organizations + [Organization.central]).uniq.compact
4
4
  end
5
-
6
- def organization_switch_url(organization)
7
- organization.url_for(controller_name == 'users' ? root_path : request.path)
8
- end
9
5
  end
@@ -7,7 +7,7 @@
7
7
  <%= image_tag(org.banner_url, height: 50, class: 'pull-left') %>
8
8
  </div>
9
9
  <div class="col-md-6 organization-row">
10
- <%= link_to(t(:go_to, organization: org.name), organization_switch_url(org), class: 'btn btn-success pull-right') %>
10
+ <%= link_to(t(:go_to, organization: org.name), org.url, class: 'btn btn-success pull-right') %>
11
11
  </div>
12
12
  </div>
13
13
  <% end %>
@@ -0,0 +1,5 @@
1
+ class RemoveNonNullConstraintFromPermissions < ActiveRecord::Migration[5.1]
2
+ def change
3
+ change_column :users, :permissions, :text, null: true, default: nil
4
+ end
5
+ end
@@ -36,7 +36,7 @@ module Mumuki::Laboratory::Controllers::DynamicErrors
36
36
  end
37
37
 
38
38
  def forbidden
39
- message = "Access to organization #{Organization.current} was forbidden to user #{current_user.uid} with permissions #{current_user.permissions.to_json}"
39
+ message = "The operation on organization #{Organization.current} was forbidden to user #{current_user.uid} with permissions #{current_user.permissions}"
40
40
  Rails.logger.info message
41
41
  render_error 'forbidden', 403, locals: { explanation: :forbidden_explanation }, error_message: message
42
42
  end
@@ -50,7 +50,7 @@ module Mumuki::Laboratory::Controllers::DynamicErrors
50
50
  end
51
51
 
52
52
  def render_error(template, status, options={})
53
- if Mumukit::Platform.organization_mapping.path_under_namespace? request.path, 'api'
53
+ if Mumukit::Platform.organization_mapping.path_under_namespace? Mumukit::Platform.current_organization_name, request.path, 'api'
54
54
  render_api_errors [options[:error_message] || template.gsub('_', ' ')], status
55
55
  else
56
56
  render_app_errors template, options.merge(status: status).except(:error_message)
@@ -1,12 +1,5 @@
1
1
  require 'mumukit/auth'
2
2
 
3
- class Mumukit::Auth::Permissions
4
- def protect_permissions_assignment!(other, previous)
5
- other ||= {}
6
- raise Mumukit::Auth::UnauthorizedAccessError unless assign_to?(Mumukit::Auth::Permissions.parse(other.to_h), previous)
7
- end
8
- end
9
-
10
3
  Mumukit::Auth.configure do |c|
11
4
  # We are not using tokens, so implementing this strategy is meaningless
12
5
  c.persistence_strategy = nil
@@ -18,14 +18,6 @@ class Mumuki::Laboratory::Engine < ::Rails::Engine
18
18
  config.i18n.available_locales = Mumukit::Platform::Locale.supported
19
19
  end
20
20
 
21
- module Mumukit::Platform::OrganizationMapping::Subdomain
22
- class << self
23
- def path_under_namespace?(path, namespace)
24
- path.start_with? "/#{namespace}/"
25
- end
26
- end
27
- end
28
-
29
21
  module Mumukit::Platform::OrganizationMapping::Path
30
22
  class << self
31
23
  alias __organization_name__ organization_name
@@ -38,9 +30,5 @@ module Mumukit::Platform::OrganizationMapping::Path
38
30
  name
39
31
  end
40
32
  end
41
-
42
- def path_under_namespace?(path, namespace)
43
- path.start_with? "/#{Mumukit::Platform.current_organization_name}/#{namespace}/"
44
- end
45
33
  end
46
34
  end
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Laboratory
3
- VERSION = '5.11.0'
3
+ VERSION = '5.12.0'
4
4
  end
5
5
  end
@@ -38,10 +38,18 @@ describe Api::UsersController, type: :controller, organization_workspace: :base
38
38
  end
39
39
 
40
40
 
41
- context 'post without permissions' do
41
+ context 'post that tries to escalate permissions' do
42
42
  before { post :create, params: {user: owner_json} }
43
43
 
44
44
  it { expect(response.status).to eq 403 }
45
+ it { expect(response.body).to json_eq errors: ['The operation on organization base was forbidden to user foo+1@bar.com with permissions !janitor:test/*;owner:'] }
46
+ end
47
+
48
+ context 'post on a user with high permissions that does not operate on them' do
49
+ let!(:user) { User.create! owner_json }
50
+ before { put :update, params: {id: 'foo@bar.com', user: owner_json} }
51
+
52
+ it { expect(response.status).to eq 200 }
45
53
  end
46
54
 
47
55
  context 'put' do
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20181004173216) do
13
+ ActiveRecord::Schema.define(version: 20181014233438) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -312,7 +312,7 @@ ActiveRecord::Schema.define(version: 20181004173216) do
312
312
  t.integer "last_exercise_id"
313
313
  t.integer "last_organization_id"
314
314
  t.string "uid", null: false
315
- t.text "permissions", default: "{}", null: false
315
+ t.text "permissions"
316
316
  t.string "first_name"
317
317
  t.string "last_name"
318
318
  t.boolean "accepts_reminders", default: true
@@ -28,9 +28,9 @@ feature 'not found on app', organization_workspace: :base do
28
28
  visit '/api/nonexistentroute'
29
29
 
30
30
  expect(page.text).to json_eq errors: [
31
- 'Access to organization base' +
31
+ 'The operation on organization base' +
32
32
  ' was forbidden to user foo+1@bar.com' +
33
- ' with permissions {"student":"central/*","teacher":"","headmaster":"","janitor":"","owner":""}']
33
+ ' with permissions !student:central/*;teacher:;headmaster:;janitor:;owner:']
34
34
  end
35
35
 
36
36
  scenario 'api with authentication' do
@@ -71,6 +71,8 @@ feature 'Standard Flow', organization_workspace: :test do
71
71
  end
72
72
 
73
73
  context 'with organizations and messages' do
74
+ before { allow_any_instance_of(Mumukit::Platform::Application::Organic).to receive(:organization_mapping).and_return(Mumukit::Platform::OrganizationMapping::Path) }
75
+
74
76
  scenario 'visit organizations tab' do
75
77
  user.make_student_of! organization.slug
76
78
  user.save!
@@ -78,6 +80,7 @@ feature 'Standard Flow', organization_workspace: :test do
78
80
 
79
81
  expect(page).to_not have_text('It seems you aren\'t in any organizations yet!')
80
82
  expect(page).to have_text('Go to test-organization')
83
+ expect(page).to have_link(nil, href: 'http://localmumuki.io/test-organization/')
81
84
  end
82
85
 
83
86
  scenario 'visit messages tab' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-laboratory
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.11.0
4
+ version: 5.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 7.3.0
47
+ version: '7.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 7.3.0
54
+ version: '7.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mumukit-core
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.6'
117
+ version: '2.7'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.6'
124
+ version: '2.7'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: mumukit-login
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -802,6 +802,7 @@ files:
802
802
  - db/migrate/20180725145801_add_submissions_caps_to_exams.rb
803
803
  - db/migrate/20180802190437_add_approved_to_messages.rb
804
804
  - db/migrate/20181004173216_add_free_form_editor_to_exercises.rb
805
+ - db/migrate/20181014233438_remove_non_null_constraint_from_permissions.rb
805
806
  - db/seeds/users.rb
806
807
  - lib/events.rb
807
808
  - lib/mumuki/laboratory.rb
@@ -973,7 +974,6 @@ files:
973
974
  - spec/helpers/email_helper_spec.rb
974
975
  - spec/helpers/exercise_input_helper_spec.rb
975
976
  - spec/helpers/icons_helper_spec.rb
976
- - spec/helpers/organization_list_helper_spec.rb
977
977
  - spec/helpers/test_results_rendering_spec.rb
978
978
  - spec/helpers/with_choices_spec.rb
979
979
  - spec/helpers/with_navigation_spec.rb
@@ -1161,7 +1161,6 @@ test_files:
1161
1161
  - spec/helpers/email_helper_spec.rb
1162
1162
  - spec/helpers/exercise_input_helper_spec.rb
1163
1163
  - spec/helpers/icons_helper_spec.rb
1164
- - spec/helpers/organization_list_helper_spec.rb
1165
1164
  - spec/helpers/test_results_rendering_spec.rb
1166
1165
  - spec/helpers/with_choices_spec.rb
1167
1166
  - spec/helpers/with_navigation_spec.rb
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe OrganizationListHelper, organization_workspace: :test do
4
- helper OrganizationListHelper
5
-
6
- context 'not not users path' do
7
- let(:request) { struct path: '/guides/1' }
8
-
9
- it { expect(organization_switch_url(Organization.current)).to eq 'http://test.localmumuki.io/guides/1' }
10
- end
11
-
12
- context 'on users path' do
13
- let(:request) { struct path: '/users/' }
14
- let(:controller_name) { 'users' }
15
-
16
- it { expect(organization_switch_url(Organization.current)).to eq 'http://test.localmumuki.io/' }
17
- end
18
- end
19
-
20
-