aaf-gumboot 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 621e2323c9655c1e7b36f143102db089b01d2aace411cc099eada952ad0324c6
4
- data.tar.gz: c1bccb4e8dc8b110d9116f91dd54552b2ec4f97d8e8f58948588e9df314ea1d5
3
+ metadata.gz: 7a713e915fc7a71196b7127e2a20f052e328fad64bc53c8c18ed4f9b77d1bbc0
4
+ data.tar.gz: 389bb5fb4cde9a1db6ab7027b8f3db37120adb29b41f0d5a3fc68a74dfe0b720
5
5
  SHA512:
6
- metadata.gz: b69c418d9f7e73fa8f426b7ceb380b6b7e5ce7adaa9d53742614a5e1a0ecd2c9a2f6772895d07ab1c5f5576dbcdbe1017492ea02436410a47b1a25ab8fd554ed
7
- data.tar.gz: d2363f1fdfc5eea05e4c8f003bdd17ffb09d27576eb6615a31c7e3c46f8cceb3e96f4640d9e227538794fdecff8f0802c8550255a3d9d7872db2d1513e4f2b2a
6
+ metadata.gz: 2bba367eadd046a177e1efae9c68b0dc875925e84500d9a2de0d52671e4ec27705a16e32134ee8e8bd2d540442eabafdb1356feddb01915ff675639febc7cfd3
7
+ data.tar.gz: e078a051b4e7f1cd7d4ac05b2f5fb380fc5cc353426fced3cf1ce72e60414fade87bfc6a5dec952a332a004fd91920422fb248722d8b8904014ca386274a831d
@@ -35,6 +35,7 @@ RSpec.shared_examples 'Database Schema' do
35
35
  query('SHOW TABLE STATUS').each do |table|
36
36
  table_name = table[:Name]
37
37
  next if table_name == 'schema_migrations'
38
+
38
39
  expect(table).to(
39
40
  have_collations(%w[utf8_bin utf8mb4_bin], "`#{table_name}`")
40
41
  )
@@ -47,6 +48,7 @@ RSpec.shared_examples 'Database Schema' do
47
48
  except_column == column[:Field].to_sym
48
49
  end
49
50
  end
51
+
50
52
  expect(column)
51
53
  .to have_collations(%w[utf8_bin utf8mb4_bin],
52
54
  " `#{table_name}`.`#{column[:Field]}`")
@@ -42,9 +42,14 @@ module Gumboot
42
42
  "Ensuring access to `#{database}` for #{username} user is granted"
43
43
  )
44
44
 
45
+ create_and_grant_user(client, database, username, password)
46
+ end
47
+
48
+ def create_and_grant_user(client, database, username, password)
49
+ client.query("CREATE USER IF NOT EXISTS '#{client.escape(username)}'" \
50
+ "@'localhost' IDENTIFIED BY '#{client.escape(password)}';")
45
51
  client.query("GRANT ALL PRIVILEGES ON `#{database}`.* " \
46
- "TO '#{client.escape(username)}'@'localhost' " \
47
- "IDENTIFIED BY '#{client.escape(password)}'")
52
+ "TO '#{client.escape(username)}'@'localhost'")
48
53
  end
49
54
 
50
55
  def maintain_activerecord_schema
@@ -82,6 +87,7 @@ module Gumboot
82
87
 
83
88
  dest = "config/#{file}"
84
89
  next if File.exist?(dest)
90
+
85
91
  FileUtils.ln_s(src, dest)
86
92
  end
87
93
  end
@@ -104,6 +110,7 @@ module Gumboot
104
110
  raise("Missing dist config file: #{src}") unless File.exist?(src)
105
111
 
106
112
  next if File.exist?(dest)
113
+
107
114
  FileUtils.copy(src, dest)
108
115
  end
109
116
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gumboot
4
- VERSION = '2.1.3'.freeze
4
+ VERSION = '2.1.4'.freeze
5
5
  end
@@ -2,6 +2,5 @@ inherit_from:
2
2
  - ../../aaf-rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
6
5
  Exclude:
7
6
  - db/schema.rb
@@ -58,6 +58,7 @@ module API
58
58
 
59
59
  def check_access!(action)
60
60
  raise(Forbidden) unless @subject.permits?(action)
61
+
61
62
  @access_checked = true
62
63
  end
63
64
 
@@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base
16
16
  def subject
17
17
  subject = session[:subject_id] && Subject.find_by(id: session[:subject_id])
18
18
  return nil unless subject.try(:functioning?)
19
+
19
20
  @subject = subject
20
21
  end
21
22
 
@@ -38,6 +39,7 @@ class ApplicationController < ActionController::Base
38
39
 
39
40
  def check_access!(action)
40
41
  raise(Forbidden) unless subject.permits?(action)
42
+
41
43
  @access_checked = true
42
44
  end
43
45
 
@@ -73,11 +73,17 @@ RSpec.describe Gumboot::Strap do
73
73
 
74
74
  it 'sets permissions for database users' do
75
75
  expect(client).to receive(:query)
76
- .with("GRANT ALL PRIVILEGES ON `one_db`.* TO 'one_user'@'localhost' " \
77
- "IDENTIFIED BY 'one_password'").once
76
+ .with("CREATE USER IF NOT EXISTS 'one_user'@'localhost' " \
77
+ "IDENTIFIED BY 'one_password';").once
78
78
  expect(client).to receive(:query)
79
- .with("GRANT ALL PRIVILEGES ON `two_db`.* TO 'two_user'@'localhost' " \
80
- "IDENTIFIED BY 'two_password'").once
79
+ .with("GRANT ALL PRIVILEGES ON `one_db`.* TO 'one_user'@'localhost'")
80
+ .once
81
+ expect(client).to receive(:query)
82
+ .with("CREATE USER IF NOT EXISTS 'two_user'@'localhost' " \
83
+ "IDENTIFIED BY 'two_password';").once
84
+ expect(client).to receive(:query)
85
+ .with("GRANT ALL PRIVILEGES ON `two_db`.* TO 'two_user'@'localhost'")
86
+ .once
81
87
 
82
88
  allow(client).to receive(:query).with(match(/^CREATE DATABASE.*/))
83
89
 
@@ -107,9 +113,12 @@ RSpec.describe Gumboot::Strap do
107
113
  end
108
114
 
109
115
  it 'sets permission for the database user' do
116
+ expect(client).to receive(:query)
117
+ .with("CREATE USER IF NOT EXISTS 'test_user'@'localhost' " \
118
+ "IDENTIFIED BY 'test_password';").once
110
119
  expect(client).to receive(:query)
111
120
  .with('GRANT ALL PRIVILEGES ON `test_db`.* TO ' \
112
- "'test_user'@'localhost' IDENTIFIED BY 'test_password'").once
121
+ "'test_user'@'localhost'").once
113
122
 
114
123
  subject.ensure_database_user(opts)
115
124
  end
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: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Beddoes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-30 00:00:00.000000000 Z
11
+ date: 2018-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: accession