aaf-gumboot 1.0.0.pre.alpha.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -7
  3. data/Gemfile +2 -0
  4. data/Guardfile +2 -0
  5. data/README.md +35 -45
  6. data/Rakefile +3 -1
  7. data/aaf-gumboot.gemspec +2 -0
  8. data/aaf-rubocop.yml +50 -0
  9. data/lib/aaf-gumboot.rb +2 -0
  10. data/lib/gumboot.rb +2 -0
  11. data/lib/gumboot/shared_examples/anonymous_controller.rb +2 -0
  12. data/lib/gumboot/shared_examples/api_constraints.rb +2 -0
  13. data/lib/gumboot/shared_examples/api_controller.rb +2 -0
  14. data/lib/gumboot/shared_examples/api_subjects.rb +2 -0
  15. data/lib/gumboot/shared_examples/application_controller.rb +2 -0
  16. data/lib/gumboot/shared_examples/database_schema.rb +11 -1
  17. data/lib/gumboot/shared_examples/foreign_keys.rb +2 -0
  18. data/lib/gumboot/shared_examples/permissions.rb +2 -0
  19. data/lib/gumboot/shared_examples/roles.rb +2 -0
  20. data/lib/gumboot/shared_examples/subjects.rb +2 -0
  21. data/lib/gumboot/strap.rb +16 -7
  22. data/lib/gumboot/version.rb +3 -1
  23. data/spec/dummy/.rubocop.yml +7 -0
  24. data/spec/dummy/Rakefile +2 -0
  25. data/spec/dummy/app/controllers/api/api_controller.rb +2 -1
  26. data/spec/dummy/app/controllers/application_controller.rb +3 -1
  27. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  28. data/spec/dummy/app/models/api_subject.rb +3 -1
  29. data/spec/dummy/app/models/api_subject_role.rb +3 -1
  30. data/spec/dummy/app/models/application_record.rb +5 -0
  31. data/spec/dummy/app/models/permission.rb +3 -1
  32. data/spec/dummy/app/models/role.rb +3 -1
  33. data/spec/dummy/app/models/subject.rb +3 -1
  34. data/spec/dummy/app/models/subject_role.rb +3 -1
  35. data/spec/dummy/bin/bundle +2 -0
  36. data/spec/dummy/bin/rails +2 -0
  37. data/spec/dummy/bin/rake +2 -0
  38. data/spec/dummy/config.ru +2 -0
  39. data/spec/dummy/config/application.rb +2 -0
  40. data/spec/dummy/config/boot.rb +2 -0
  41. data/spec/dummy/config/environment.rb +2 -0
  42. data/spec/dummy/config/environments/development.rb +2 -0
  43. data/spec/dummy/config/environments/production.rb +2 -0
  44. data/spec/dummy/config/environments/test.rb +2 -0
  45. data/spec/dummy/config/initializers/assets.rb +2 -0
  46. data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
  47. data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
  48. data/spec/dummy/config/initializers/inflections.rb +2 -0
  49. data/spec/dummy/config/initializers/mime_types.rb +1 -0
  50. data/spec/dummy/config/initializers/session_store.rb +2 -0
  51. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
  52. data/spec/dummy/config/routes.rb +2 -0
  53. data/spec/dummy/db/schema.rb +3 -1
  54. data/spec/dummy/lib/api_constraints.rb +2 -0
  55. data/spec/factories/api_subjects.rb +2 -0
  56. data/spec/factories/permissions.rb +2 -0
  57. data/spec/factories/roles.rb +2 -0
  58. data/spec/factories/subjects.rb +2 -0
  59. data/spec/gumboot/api_constraints_spec.rb +2 -0
  60. data/spec/gumboot/api_controller_spec.rb +2 -0
  61. data/spec/gumboot/api_subjects_spec.rb +2 -0
  62. data/spec/gumboot/application_controller_spec.rb +2 -0
  63. data/spec/gumboot/foreign_keys_spec.rb +2 -0
  64. data/spec/gumboot/permissions_spec.rb +2 -0
  65. data/spec/gumboot/roles_spec.rb +2 -0
  66. data/spec/gumboot/subjects_spec.rb +2 -0
  67. data/spec/lib/gumboot/strap_spec.rb +17 -5
  68. data/spec/spec_helper.rb +3 -1
  69. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e952df6d99ca0bf6a4318eaa499ed7c77a89c141
4
- data.tar.gz: c87a7d4266d7e3cfea893b31864c095c6cdb940b
3
+ metadata.gz: 52e23f002b6d20c1fba12e280d0e29c9bc83100c
4
+ data.tar.gz: a7bdbb8590251322dbee584a1b2a002377fdb465
5
5
  SHA512:
6
- metadata.gz: 6939763db4326b84e5df6b9ff948db76520132cafbee27578ed5c0dd3e358b24138589052092cce16b2eba42a21a95932d054c22bfc27fd1d31f22a94efc71b7
7
- data.tar.gz: 74e51eee1bfacd930826ade7230aecc10fbf5e463dd0b9ef61907f95c4d5e89a2b63eb1ca7125c52e13a44ce371e43f1b36a037f481a8c77bb7c79963150f2ac
6
+ metadata.gz: cea623e1c262ac3d6cf901a19d1a21f8c4a8bf40950da383a62497e23b3a1211fbd579b11e9448b740ecea912495fbf2b54ff833e5b4cf9a8e7aeaf2f5b66dea
7
+ data.tar.gz: 748e84bca55148e59168e3bca922d88aab8b99750eb22d88bf2fed361016b7e0d960da6988615b6d5ca430f7bc9d9da3448aaecbe1131dd9e4c6b8ed9230ceb2
@@ -1,15 +1,13 @@
1
- Style/Documentation:
2
- Enabled: false
1
+ inherit_from:
2
+ - aaf-rubocop.yml
3
3
 
4
4
  Style/FileName:
5
5
  Exclude:
6
6
  - lib/aaf-gumboot.rb
7
7
 
8
- AllCops:
9
- TargetRubyVersion: 2.1
10
-
11
8
  Metrics/BlockLength:
12
9
  Exclude:
13
- - aaf-gumboot.gemspec
10
+ - "*.gemspec"
14
11
  - spec/**/*.rb
15
- - lib/**/*.rb
12
+ - lib/tasks/*.rake
13
+ - lib/gumboot/**/*.rb
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in aaf-gumboot.gemspec
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  guard :bundler do
2
4
  watch('Gemfile')
3
5
  watch(/^.+\.gemspec/)
data/README.md CHANGED
@@ -24,7 +24,7 @@ Gumboot sloshes through these **muddy** topics for AAF applications, bringing do
24
24
  ![](http://i.imgur.com/XP4Yw6e.jpg)
25
25
 
26
26
  ```
27
- Copyright 2014-2015, Australian Access Federation
27
+ Copyright 2014-2017, Australian Access Federation
28
28
 
29
29
  Licensed under the Apache License, Version 2.0 (the "License");
30
30
  you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ Before you get started you should ensure your development machine has the follow
46
46
 
47
47
  Generate a secret to use with Rapid Connect with the following:
48
48
 
49
- $> tr -dc '[[:alnum:][:punct:]]' < /dev/urandom | head -c32 ;echo
49
+ $> LC_CTYPE=C tr -dc '[[:alnum:][:punct:]]' < /dev/urandom | head -c32 ;echo
50
50
 
51
51
  Access [https://rapid.test.aaf.edu.au](https://rapid.test.aaf.edu.au) and register using your secret created above and the callback URL of `http://localhost:8080/auth/jwt`
52
52
 
@@ -100,39 +100,43 @@ Of course ACTUAL comments describing something you've written that is a little b
100
100
  The way we build ruby applications has tried to be standardised as much as possible at a base layer. You're likely going to want all these Gems in your Gemfile for a Rails app or a considerable subset of them for a non Rails app.
101
101
 
102
102
  ```ruby
103
- gem 'rails', '4.2.3' # Ensure latest release
104
103
  gem 'mysql2'
104
+ gem 'rails', '>= 5.0.0', '< 5.1' # Ensure latest release
105
105
 
106
- gem 'valhammer'
106
+ gem 'aaf-secure_headers'
107
+ gem 'aaf-lipstick'
107
108
  gem 'accession'
109
+ gem 'valhammer'
108
110
 
109
- gem 'puma', require: false
110
111
  gem 'god', require: false
112
+ gem 'puma', require: false
111
113
 
112
- group :development, :test do
113
- gem 'rspec-rails', '~> 3.3.0'
114
- gem 'shoulda-matchers'
114
+ gem 'local_time'
115
115
 
116
+ gem 'rails_admin'
117
+ gem 'rails_admin_aaf_theme'
118
+
119
+ group :development, :test do
120
+ gem 'aaf-gumboot'
121
+ gem 'bullet'
122
+ gem 'database_cleaner'
116
123
  gem 'factory_girl_rails'
117
124
  gem 'faker'
118
- gem 'timecop'
119
- gem 'database_cleaner'
120
-
121
- gem 'rubocop', require: false
122
- gem 'simplecov', require: false
123
-
124
- gem 'capybara', require: false
125
- gem 'poltergeist', require: false
126
- gem 'phantomjs', require: 'phantomjs/poltergeist'
127
-
128
125
  gem 'guard', require: false
126
+ gem 'guard-brakeman', require: false
129
127
  gem 'guard-bundler', require: false
130
- gem 'guard-rubocop', require: false
131
128
  gem 'guard-rspec', require: false
132
- gem 'guard-brakeman', require: false
129
+ gem 'guard-rubocop', require: false
130
+ gem 'pry'
131
+ gem 'rails-controller-testing'
132
+ gem 'rspec-rails', '~> 3.5.0.beta4'
133
+ gem 'rubocop', require: false
134
+ gem 'shoulda-matchers'
135
+ gem 'simplecov', require: false
133
136
  gem 'terminal-notifier-guard', require: false
134
-
135
- gem 'aaf-gumboot'
137
+ gem 'timecop'
138
+ gem 'web-console', '~> 2.0', require: false
139
+ gem 'webmock', require: false
136
140
  end
137
141
  ```
138
142
 
@@ -166,28 +170,8 @@ Modify the generated RSpec config file as follows `.rspec`:
166
170
  Add a Rubocop config file `.rubocop.yml`:
167
171
 
168
172
  ```
169
- AllCops:
170
- TargetRubyVersion: 2.3
171
- Exclude:
172
- - db/schema.rb
173
-
174
- Rails:
175
- Enabled: true
176
-
177
- Rails/Output:
178
- Exclude:
179
- - db/seeds.rb
180
-
181
- Style/Documentation:
182
- Enabled: false
183
-
184
- Metrics/MethodLength:
185
- Exclude:
186
- - db/migrate/*.rb
187
-
188
- Metrics/AbcSize:
189
- Exclude:
190
- - db/migrate/*.rb
173
+ inherit_gem:
174
+ aaf-gumboot: aaf-rubocop.yml
191
175
  ```
192
176
 
193
177
  ### Simplecov
@@ -246,6 +230,7 @@ Add the following gem to your Gemfile in the default group:
246
230
 
247
231
  ``` ruby
248
232
  gem 'rapid-rack'
233
+ gem 'super-identity'
249
234
  ```
250
235
 
251
236
  Execute:
@@ -277,6 +262,7 @@ module Authentication
277
262
  class SubjectReceiver
278
263
  include RapidRack::DefaultReceiver
279
264
  include RapidRack::RedisRegistry
265
+ include SuperIdentity::Client
280
266
 
281
267
  def map_attributes(_env, attrs)
282
268
  {}
@@ -436,6 +422,8 @@ require 'gumboot/shared_examples/database_schema'
436
422
 
437
423
  RSpec.describe 'Database Schema' do
438
424
  let(:connection) { ActiveRecord::Base.connection.raw_connection }
425
+ # Use the following (as an example) for column based exemptions
426
+ let(:collation_exemptions) { { table_name: %i[column_name] } }
439
427
 
440
428
  include_context 'Database Schema'
441
429
  end
@@ -761,7 +749,9 @@ You should now follow the documention for [https://github.com/ausaccessfed/rapid
761
749
 
762
750
  ## Controllers
763
751
 
764
- AAF applications must utilise controllers which default to verifying authentication and access control on every request. This can be changed as implementations require to be publicly accessible for example but must be explicitly configured in code to make it clear to all.
752
+ AAF applications must utilise controllers which default to verifying authentication
753
+ and access control on every request. This can be changed as implementations require
754
+ to be publicly accessible for example but must be explicitly configured in code to make it clear to all.
765
755
 
766
756
  ##### Rails 4.x
767
757
  See `spec/dummy/app/controllers/application_controller.rb` for the implementation this example is based on
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'rubocop/rake_task'
@@ -5,4 +7,4 @@ require 'rubocop/rake_task'
5
7
  RSpec::Core::RakeTask.new(:spec)
6
8
  RuboCop::RakeTask.new
7
9
 
8
- task default: [:spec, :rubocop]
10
+ task default: %i[spec rubocop]
@@ -1,4 +1,6 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  lib = File.expand_path('../lib', __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require 'gumboot/version'
@@ -0,0 +1,50 @@
1
+ # https://rubocop.readthedocs.io/en/latest/configuration/#inheritance
2
+
3
+ # If you override a setting in a project's local .rubocop.yml file
4
+ # you must add the pre-existing exceptions found here as well.
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.3
8
+ Exclude:
9
+ - db/schema.rb
10
+
11
+ Rails:
12
+ Enabled: true
13
+
14
+ Rails/NotNullColumn:
15
+ Enabled: false
16
+
17
+ Rails/ReversibleMigration:
18
+ Enabled: false
19
+
20
+ Rails/SkipsModelValidations:
21
+ Exclude:
22
+ - db/migrate/*.rb
23
+
24
+ Rails/Output:
25
+ Exclude:
26
+ - db/seeds.rb
27
+
28
+ Style/Documentation:
29
+ Enabled: false
30
+
31
+ Metrics/MethodLength:
32
+ Exclude:
33
+ - db/migrate/*.rb
34
+ - config/**/*.rb
35
+
36
+ Metrics/AbcSize:
37
+ Exclude:
38
+ - db/migrate/*.rb
39
+
40
+ Metrics/BlockLength:
41
+ Exclude:
42
+ - "*.gemspec"
43
+ - spec/**/*.rb
44
+ - lib/tasks/*.rake
45
+ - config/**/*.rb
46
+ - db/**/*.rb
47
+
48
+ Metrics/LineLength:
49
+ Exclude:
50
+ - db/migrate/*.rb
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gumboot'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gumboot
2
4
  # Your code goes here...
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'Anon controller' do
2
4
  controller(described_class) do
3
5
  def an_action
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'API constraints' do
2
4
  context 'AAF shared implementation' do
3
5
  context '#matches?' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: false
2
+
1
3
  require 'gumboot/shared_examples/anonymous_controller'
2
4
 
3
5
  RSpec.shared_examples 'API base controller' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'API Subjects' do
2
4
  context 'AAF shared implementation' do
3
5
  subject { build :api_subject }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gumboot/shared_examples/anonymous_controller'
2
4
 
3
5
  RSpec.shared_examples 'Application controller' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'Database Schema' do
2
4
  context 'AAF shared implementation' do
3
5
  RSpec::Matchers.define :have_collation do |expected, name|
@@ -24,6 +26,8 @@ RSpec.shared_examples 'Database Schema' do
24
26
  end
25
27
 
26
28
  it 'has the correct collation' do
29
+ exemptions = defined?(collation_exemptions) ? collation_exemptions : []
30
+
27
31
  db_collation = query('SHOW VARIABLES LIKE "collation_database"')
28
32
  .first[:Value]
29
33
  expect(db_collation).to eq('utf8_bin')
@@ -33,8 +37,14 @@ RSpec.shared_examples 'Database Schema' do
33
37
  next if table_name == 'schema_migrations'
34
38
  expect(table).to have_collation('utf8_bin', "`#{table_name}`")
35
39
 
36
- query("SHOW FULL COLUMNS FROM #{table[:Name]}").each do |column|
40
+ query("SHOW FULL COLUMNS FROM #{table_name}").each do |column|
37
41
  next unless column[:Collation]
42
+ next if exemptions.any? do |except_table, except_columns|
43
+ except_table == table_name.to_sym &&
44
+ except_columns.any? do |except_column|
45
+ except_column == column[:Field].to_sym
46
+ end
47
+ end
38
48
  expect(column)
39
49
  .to have_collation('utf8_bin',
40
50
  " `#{table_name}`.`#{column[:Field]}`")
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'Gumboot Foreign Keys' do
2
4
  RSpec.shared_examples 'gumboot fk' do
3
5
  let(:conn) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'Permissions' do
2
4
  context 'AAF shared implementation' do
3
5
  subject { build :permission }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'Roles' do
2
4
  context 'AAF shared implementation' do
3
5
  subject { build :role }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'Subjects' do
2
4
  context 'AAF shared implementation' do
3
5
  subject { build :subject }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require 'active_support/core_ext/hash/deep_merge'
3
5
 
@@ -25,7 +27,7 @@ module Gumboot
25
27
  adapter, database = db.values_at('adapter', 'database')
26
28
  raise('Only supports mysql2 adapter') unless adapter == 'mysql2'
27
29
 
28
- puts "Ensuring database `#{database}` exists"
30
+ Rails.logger.info "Ensuring database `#{database}` exists"
29
31
  client.query("CREATE DATABASE IF NOT EXISTS `#{database}` " \
30
32
  'CHARACTER SET utf8 COLLATE utf8_bin')
31
33
  end
@@ -36,7 +38,10 @@ module Gumboot
36
38
 
37
39
  raise('Only supports mysql2 adapter') unless adapter == 'mysql2'
38
40
 
39
- puts "Ensuring access to `#{database}` for #{username} user is granted"
41
+ Rails.logger.info(
42
+ "Ensuring access to `#{database}` for #{username} user is granted"
43
+ )
44
+
40
45
  client.query("GRANT ALL PRIVILEGES ON `#{database}`.* " \
41
46
  "TO '#{client.escape(username)}'@'localhost' " \
42
47
  "IDENTIFIED BY '#{client.escape(password)}'")
@@ -46,11 +51,11 @@ module Gumboot
46
51
  message 'Loading database schema'
47
52
 
48
53
  if ActiveRecord::Base.connection.execute('SHOW TABLES').count.zero?
49
- puts 'No tables exist yet, loading schema'
54
+ Rails.logger.info 'No tables exist yet, loading schema'
50
55
  system 'rake db:schema:load'
51
56
  end
52
57
 
53
- puts 'Running migrations'
58
+ Rails.logger.info 'Running migrations'
54
59
  system 'rake db:migrate'
55
60
  end
56
61
 
@@ -106,12 +111,16 @@ module Gumboot
106
111
  private
107
112
 
108
113
  def message(msg)
109
- puts "\n== #{msg} =="
114
+ Rails.logger.info "\n== #{msg} =="
115
+ end
116
+
117
+ def safe_load(yaml)
118
+ YAML.safe_load(yaml, [Symbol])
110
119
  end
111
120
 
112
121
  def merge_config(src, dest)
113
- new_config = YAML.load(File.read(src))
114
- old_config = File.exist?(dest) ? YAML.load(File.read(dest)) : {}
122
+ new_config = safe_load(File.read(src))
123
+ old_config = File.exist?(dest) ? safe_load(File.read(dest)) : {}
115
124
 
116
125
  File.open(dest, 'w') do |f|
117
126
  f.write(YAML.dump(new_config.deep_merge(old_config)))
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gumboot
2
- VERSION = '1.0.0-alpha.2'.freeze
4
+ VERSION = '1.1.0'
3
5
  end
@@ -0,0 +1,7 @@
1
+ inherit_from:
2
+ - ../../aaf-rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.3
6
+ Exclude:
7
+ - db/schema.rb
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('../config/application', __FILE__)
2
4
 
3
5
  Rails.application.load_tasks
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'openssl'
2
4
 
3
5
  module API
@@ -45,7 +47,6 @@ module API
45
47
  ]
46
48
 
47
49
  x509_dn_hash['CN'] || raise(Unauthorized, 'Subject CN invalid')
48
-
49
50
  rescue OpenSSL::X509::NameError
50
51
  raise(Unauthorized, 'Subject DN invalid')
51
52
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationController < ActionController::Base
2
4
  Forbidden = Class.new(StandardError)
3
5
  private_constant :Forbidden
@@ -12,7 +14,7 @@ class ApplicationController < ActionController::Base
12
14
  after_action :ensure_access_checked
13
15
 
14
16
  def subject
15
- subject = session[:subject_id] && Subject.find_by_id(session[:subject_id])
17
+ subject = session[:subject_id] && Subject.find_by(id: session[:subject_id])
16
18
  return nil unless subject.try(:functioning?)
17
19
  @subject = subject
18
20
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApplicationHelper
2
4
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'accession'
2
4
 
3
- class APISubject < ActiveRecord::Base
5
+ class APISubject < ApplicationRecord
4
6
  include Accession::Principal
5
7
 
6
8
  has_many :api_subject_roles
@@ -1,4 +1,6 @@
1
- class APISubjectRole < ActiveRecord::Base
1
+ # frozen_string_literal: true
2
+
3
+ class APISubjectRole < ApplicationRecord
2
4
  belongs_to :api_subject
3
5
  belongs_to :role
4
6
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
@@ -1,4 +1,6 @@
1
- class Permission < ActiveRecord::Base
1
+ # frozen_string_literal: true
2
+
3
+ class Permission < ApplicationRecord
2
4
  belongs_to :role
3
5
 
4
6
  valhammer
@@ -1,4 +1,6 @@
1
- class Role < ActiveRecord::Base
1
+ # frozen_string_literal: true
2
+
3
+ class Role < ApplicationRecord
2
4
  has_many :api_subject_roles
3
5
  has_many :api_subjects, through: :api_subject_roles
4
6
 
@@ -1,4 +1,6 @@
1
- class Subject < ActiveRecord::Base
1
+ # frozen_string_literal: true
2
+
3
+ class Subject < ApplicationRecord
2
4
  include Accession::Principal
3
5
 
4
6
  has_many :subject_roles
@@ -1,4 +1,6 @@
1
- class SubjectRole < ActiveRecord::Base
1
+ # frozen_string_literal: true
2
+
3
+ class SubjectRole < ApplicationRecord
2
4
  belongs_to :subject
3
5
  belongs_to :role
4
6
 
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
5
  load Gem.bin_path('bundler', 'bundle')
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  APP_PATH = File.expand_path('../../config/application', __FILE__)
3
5
  require_relative '../config/boot'
4
6
  require 'rails/commands'
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require_relative '../config/boot'
3
5
  require 'rake'
4
6
  Rake.application.run
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is used by Rack-based servers to start the application.
2
4
 
3
5
  require ::File.expand_path('../config/environment', __FILE__)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('../boot', __FILE__)
2
4
 
3
5
  # Pick the frameworks you want:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Set up gems listed in the Gemfile.
2
4
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the Rails application.
2
4
  require File.expand_path('../application', __FILE__)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  config.cache_classes = false
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  config.cache_classes = true
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  config.cache_classes = true
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Version of your assets, change this if you want to expire all your assets.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new mime types for use in respond_to blocks:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -1,4 +1,6 @@
1
1
 
2
+ # frozen_string_literal: true
3
+
2
4
  ActiveSupport.on_load(:action_controller) do
3
5
  wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
4
6
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveRecord::Schema.define(version: 0) do
2
4
  create_table :roles do |t|
3
5
  t.string :name, null: false
@@ -8,7 +10,7 @@ ActiveRecord::Schema.define(version: 0) do
8
10
  t.string :value, null: false
9
11
  t.belongs_to :role, null: false
10
12
  t.timestamps null: false
11
- t.index [:role_id, :value], unique: true
13
+ t.index %i[role_id value], unique: true
12
14
  end
13
15
 
14
16
  create_table :api_subjects do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class APIConstraints
2
4
  def initialize(version:, default: false)
3
5
  @version = version
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryGirl.define do
2
4
  factory :api_subject, class: API::APISubject do
3
5
  x509_cn { Faker::Lorem.word }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryGirl.define do
2
4
  factory :permission do
3
5
  association :role
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryGirl.define do
2
4
  factory :role, class: 'Role' do
3
5
  name { Faker::Lorem.word }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryGirl.define do
2
4
  factory :subject do
3
5
  name { Faker::Name.name }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'gumboot/shared_examples/api_constraints'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'gumboot/shared_examples/api_controller'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'gumboot/shared_examples/api_subjects'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'gumboot/shared_examples/application_controller'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'gumboot/shared_examples/foreign_keys'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'gumboot/shared_examples/permissions'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'gumboot/shared_examples/roles'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'gumboot/shared_examples/subjects'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'mysql2'
@@ -127,7 +129,7 @@ RSpec.describe Gumboot::Strap do
127
129
  end
128
130
 
129
131
  context 'when a database already exists' do
130
- let(:tables) { %w(schema_migrations) }
132
+ let(:tables) { %w[schema_migrations] }
131
133
 
132
134
  it 'runs the migrations' do
133
135
  expect(subject.kernel).to receive(:system).with('rake db:migrate')
@@ -179,19 +181,19 @@ RSpec.describe Gumboot::Strap do
179
181
  expect(FileUtils).to receive(:ln_s).with("#{base}/b", 'config/b')
180
182
  expect(FileUtils).to receive(:ln_s).with("#{base}/c", 'config/c')
181
183
 
182
- subject.link_global_configuration(%w(a b c))
184
+ subject.link_global_configuration(%w[a b c])
183
185
  end
184
186
 
185
187
  it 'skips an existing file' do
186
188
  allow(File).to receive(:exist?).and_return(true)
187
189
  expect(FileUtils).not_to receive(:ln_s)
188
190
 
189
- subject.link_global_configuration(%w(a))
191
+ subject.link_global_configuration(%w[a])
190
192
  end
191
193
 
192
194
  it 'raises an error for a missing file' do
193
195
  allow(File).to receive(:exist?).and_return(false)
194
- expect { subject.link_global_configuration(%w(a)) }
196
+ expect { subject.link_global_configuration(%w[a]) }
195
197
  .to raise_error(/Missing global config file/)
196
198
  end
197
199
  end
@@ -223,7 +225,7 @@ RSpec.describe Gumboot::Strap do
223
225
 
224
226
  def updated_config
225
227
  expect(written).not_to be_empty
226
- YAML.load(written.join)
228
+ YAML.safe_load(written.join, [Symbol])
227
229
  end
228
230
 
229
231
  context 'when the target does not exist' do
@@ -286,6 +288,16 @@ RSpec.describe Gumboot::Strap do
286
288
  expect { run }.to raise_error(/Missing dist config file/)
287
289
  end
288
290
  end
291
+
292
+ context 'when the files contain symbol keys' do
293
+ let(:dist) { YAML.dump(a: 2) }
294
+ let(:target) { YAML.dump(a: 3) }
295
+
296
+ it 'merges the new configuration option' do
297
+ run
298
+ expect(updated_config).to eq(a: 3)
299
+ end
300
+ end
289
301
  end
290
302
 
291
303
  describe '#install_dist_template' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
  require 'factory_girl'
3
5
  require 'rails/all'
@@ -13,7 +15,7 @@ end
13
15
  ENV['RAILS_ENV'] ||= 'test'
14
16
  require File.expand_path('../dummy/config/environment.rb', __FILE__)
15
17
 
16
- load Rails.root.join('db/schema.rb')
18
+ load Rails.root.join('db', 'schema.rb')
17
19
 
18
20
  FactoryGirl.find_definitions
19
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aaf-gumboot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Beddoes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-18 00:00:00.000000000 Z
11
+ date: 2017-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: accession
@@ -280,6 +280,7 @@ files:
280
280
  - README.md
281
281
  - Rakefile
282
282
  - aaf-gumboot.gemspec
283
+ - aaf-rubocop.yml
283
284
  - lib/aaf-gumboot.rb
284
285
  - lib/gumboot.rb
285
286
  - lib/gumboot/shared_examples/anonymous_controller.rb
@@ -294,6 +295,7 @@ files:
294
295
  - lib/gumboot/shared_examples/subjects.rb
295
296
  - lib/gumboot/strap.rb
296
297
  - lib/gumboot/version.rb
298
+ - spec/dummy/.rubocop.yml
297
299
  - spec/dummy/README.rdoc
298
300
  - spec/dummy/Rakefile
299
301
  - spec/dummy/app/assets/images/.keep
@@ -307,6 +309,7 @@ files:
307
309
  - spec/dummy/app/models/.keep
308
310
  - spec/dummy/app/models/api_subject.rb
309
311
  - spec/dummy/app/models/api_subject_role.rb
312
+ - spec/dummy/app/models/application_record.rb
310
313
  - spec/dummy/app/models/concerns/.keep
311
314
  - spec/dummy/app/models/permission.rb
312
315
  - spec/dummy/app/models/role.rb
@@ -375,12 +378,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
375
378
  version: '0'
376
379
  required_rubygems_version: !ruby/object:Gem::Requirement
377
380
  requirements:
378
- - - ">"
381
+ - - ">="
379
382
  - !ruby/object:Gem::Version
380
- version: 1.3.1
383
+ version: '0'
381
384
  requirements: []
382
385
  rubyforge_project:
383
- rubygems_version: 2.6.8
386
+ rubygems_version: 2.6.12
384
387
  signing_key:
385
388
  specification_version: 4
386
389
  summary: Kick off subject and API structure for AAF applications