aaf-gumboot 1.0.0.pre.alpha.2 → 1.1.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 +4 -4
- data/.rubocop.yml +5 -7
- data/Gemfile +2 -0
- data/Guardfile +2 -0
- data/README.md +35 -45
- data/Rakefile +3 -1
- data/aaf-gumboot.gemspec +2 -0
- data/aaf-rubocop.yml +50 -0
- data/lib/aaf-gumboot.rb +2 -0
- data/lib/gumboot.rb +2 -0
- data/lib/gumboot/shared_examples/anonymous_controller.rb +2 -0
- data/lib/gumboot/shared_examples/api_constraints.rb +2 -0
- data/lib/gumboot/shared_examples/api_controller.rb +2 -0
- data/lib/gumboot/shared_examples/api_subjects.rb +2 -0
- data/lib/gumboot/shared_examples/application_controller.rb +2 -0
- data/lib/gumboot/shared_examples/database_schema.rb +11 -1
- data/lib/gumboot/shared_examples/foreign_keys.rb +2 -0
- data/lib/gumboot/shared_examples/permissions.rb +2 -0
- data/lib/gumboot/shared_examples/roles.rb +2 -0
- data/lib/gumboot/shared_examples/subjects.rb +2 -0
- data/lib/gumboot/strap.rb +16 -7
- data/lib/gumboot/version.rb +3 -1
- data/spec/dummy/.rubocop.yml +7 -0
- data/spec/dummy/Rakefile +2 -0
- data/spec/dummy/app/controllers/api/api_controller.rb +2 -1
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/api_subject.rb +3 -1
- data/spec/dummy/app/models/api_subject_role.rb +3 -1
- data/spec/dummy/app/models/application_record.rb +5 -0
- data/spec/dummy/app/models/permission.rb +3 -1
- data/spec/dummy/app/models/role.rb +3 -1
- data/spec/dummy/app/models/subject.rb +3 -1
- data/spec/dummy/app/models/subject_role.rb +3 -1
- data/spec/dummy/bin/bundle +2 -0
- data/spec/dummy/bin/rails +2 -0
- data/spec/dummy/bin/rake +2 -0
- data/spec/dummy/config.ru +2 -0
- data/spec/dummy/config/application.rb +2 -0
- data/spec/dummy/config/boot.rb +2 -0
- data/spec/dummy/config/environment.rb +2 -0
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/environments/test.rb +2 -0
- data/spec/dummy/config/initializers/assets.rb +2 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/spec/dummy/config/initializers/inflections.rb +2 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/session_store.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/schema.rb +3 -1
- data/spec/dummy/lib/api_constraints.rb +2 -0
- data/spec/factories/api_subjects.rb +2 -0
- data/spec/factories/permissions.rb +2 -0
- data/spec/factories/roles.rb +2 -0
- data/spec/factories/subjects.rb +2 -0
- data/spec/gumboot/api_constraints_spec.rb +2 -0
- data/spec/gumboot/api_controller_spec.rb +2 -0
- data/spec/gumboot/api_subjects_spec.rb +2 -0
- data/spec/gumboot/application_controller_spec.rb +2 -0
- data/spec/gumboot/foreign_keys_spec.rb +2 -0
- data/spec/gumboot/permissions_spec.rb +2 -0
- data/spec/gumboot/roles_spec.rb +2 -0
- data/spec/gumboot/subjects_spec.rb +2 -0
- data/spec/lib/gumboot/strap_spec.rb +17 -5
- data/spec/spec_helper.rb +3 -1
- metadata +8 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 52e23f002b6d20c1fba12e280d0e29c9bc83100c
|
|
4
|
+
data.tar.gz: a7bdbb8590251322dbee584a1b2a002377fdb465
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cea623e1c262ac3d6cf901a19d1a21f8c4a8bf40950da383a62497e23b3a1211fbd579b11e9448b740ecea912495fbf2b54ff833e5b4cf9a8e7aeaf2f5b66dea
|
|
7
|
+
data.tar.gz: 748e84bca55148e59168e3bca922d88aab8b99750eb22d88bf2fed361016b7e0d960da6988615b6d5ca430f7bc9d9da3448aaecbe1131dd9e4c6b8ed9230ceb2
|
data/.rubocop.yml
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
-
|
|
10
|
+
- "*.gemspec"
|
|
14
11
|
- spec/**/*.rb
|
|
15
|
-
- lib
|
|
12
|
+
- lib/tasks/*.rake
|
|
13
|
+
- lib/gumboot/**/*.rb
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
data/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Gumboot sloshes through these **muddy** topics for AAF applications, bringing do
|
|
|
24
24
|

|
|
25
25
|
|
|
26
26
|
```
|
|
27
|
-
Copyright 2014-
|
|
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 '
|
|
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
|
-
|
|
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-
|
|
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 '
|
|
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
|
-
|
|
170
|
-
|
|
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
|
|
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: [
|
|
10
|
+
task default: %i[spec rubocop]
|
data/aaf-gumboot.gemspec
CHANGED
data/aaf-rubocop.yml
ADDED
|
@@ -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
|
data/lib/aaf-gumboot.rb
CHANGED
data/lib/gumboot.rb
CHANGED
|
@@ -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 #{
|
|
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]}`")
|
data/lib/gumboot/strap.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
54
|
+
Rails.logger.info 'No tables exist yet, loading schema'
|
|
50
55
|
system 'rake db:schema:load'
|
|
51
56
|
end
|
|
52
57
|
|
|
53
|
-
|
|
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
|
-
|
|
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 =
|
|
114
|
-
old_config = File.exist?(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)))
|
data/lib/gumboot/version.rb
CHANGED
data/spec/dummy/Rakefile
CHANGED
|
@@ -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.
|
|
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
|
data/spec/dummy/bin/bundle
CHANGED
data/spec/dummy/bin/rails
CHANGED
data/spec/dummy/bin/rake
CHANGED
data/spec/dummy/config.ru
CHANGED
data/spec/dummy/config/boot.rb
CHANGED
data/spec/dummy/config/routes.rb
CHANGED
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -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 [
|
|
13
|
+
t.index %i[role_id value], unique: true
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
create_table :api_subjects do |t|
|
data/spec/factories/roles.rb
CHANGED
data/spec/factories/subjects.rb
CHANGED
data/spec/gumboot/roles_spec.rb
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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
|
data/spec/spec_helper.rb
CHANGED
|
@@ -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
|
|
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.
|
|
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:
|
|
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:
|
|
383
|
+
version: '0'
|
|
381
384
|
requirements: []
|
|
382
385
|
rubyforge_project:
|
|
383
|
-
rubygems_version: 2.6.
|
|
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
|