glacier_on_rails 0.9.5 → 0.9.6

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
  SHA1:
3
- metadata.gz: 4fca450bd43aa00111403add1acd3505f4d7775b
4
- data.tar.gz: 0c49c3ede142e1d3c9b952f2d8762282a6dce3db
3
+ metadata.gz: 4b787edca23f9db4ca73cbf890c3cbd953cbdd22
4
+ data.tar.gz: b72bc1553df28d0006b6d8716fdffd5c1d4feec2
5
5
  SHA512:
6
- metadata.gz: 3f7da1e401918ff170f0fb66e4d20a1803fa86c3e1202137e67f4e0296130d5762cc680c2ea24b67a640e7011bc080c154ce9e049c6e1a6a4dce836e138e24db
7
- data.tar.gz: c968f47766e1485690c3de3653cfde5852487d112eceb147cb86e91f7f767e6fa708aa7ae56c5924cd6d168342f2792f1ee9d5d546e97a99cca5ec0641a9acd4
6
+ metadata.gz: fbe7502e6960ad4486f06678410c0fa2c6ad0f2f6dd5157bf45c7c67b4dfa32b1cccf7e9de12b0ec3dc456597ba8a07316bb7d8c71ee833b6745c899e765c45a
7
+ data.tar.gz: b7eefdc7c7d81cff6ba92bc423d80053fc17247fd7d1f559eb61b1e257ef71d28792058080e077d433bce011f02e09750469beadf9fe44972dac15f494468ea9
data/Gemfile.lock CHANGED
@@ -248,7 +248,7 @@ DEPENDENCIES
248
248
  coffee-rails (~> 4.2, >= 4.2.2)
249
249
  database_cleaner (~> 1.6, >= 1.6.1)
250
250
  glacier_on_rails!
251
- haml-rails (~> 1.0.0)
251
+ haml-rails (~> 1.0)
252
252
  jquery-rails
253
253
  pg
254
254
  poltergeist (~> 1.15)
@@ -2,6 +2,13 @@ class ApplicationDatabase::PostgresAdapter < ApplicationDatabase::BaseAdapter
2
2
  class PgDumpCmdMissing < StandardError; end
3
3
  class PgRestoreCmdMissing < StandardError; end
4
4
  class PgRestoreFileMissing < StandardError; end
5
+ class PgPassFileMissing < StandardError
6
+ def initialize
7
+ message = "~/.pgpass file not found, cannot dump database contents"
8
+ AwsLog.error "ApplicationDatabase::PostgresAdapter::PgPassFileMissing exception: #{message}"
9
+ super(message)
10
+ end
11
+ end
5
12
 
6
13
  RestoreExclusions = %w{ application_data_backups
7
14
  glacier_archives
@@ -10,6 +17,7 @@ class ApplicationDatabase::PostgresAdapter < ApplicationDatabase::BaseAdapter
10
17
  RestoreList = GlacierArchive::BackupFileDir.join('restore.list')
11
18
 
12
19
  def contents
20
+ raise PgPassFileMissing if db_config["password"].present? && !File.exists?("~/.pgpass")
13
21
  `#{pg_dump} -w -Fc -U #{db_config['username']} #{db_config['database']}`
14
22
  end
15
23
 
@@ -1,8 +1,9 @@
1
1
  class ApplicationDatabase
2
2
  class MissingConfigurationKeys < StandardError
3
3
  def initialize(missing_keys)
4
- msg = "#{missing_keys.join(' and ')} must be specified in config/database.yml"
5
- super(msg)
4
+ message = "#{missing_keys.join(' and ')} must be specified in config/database.yml"
5
+ AwsLog.error "ApplicationDatabase::MissingConfigurationKeys exception: #{message}"
6
+ super(message)
6
7
  end
7
8
  end
8
9
 
@@ -13,7 +13,7 @@ class AwsBackend
13
13
  @client.create_vault({:account_id => "-", :vault_name => ::SITE_NAME})
14
14
  end
15
15
  rescue => e
16
- AwsLog.info "Failed to initialize AwsBackend: #{e.class.name}: #{e.message}"
16
+ AwsLog.error "Failed to initialize AwsBackend: #{e.class.name}: #{e.message}"
17
17
  raise
18
18
  end
19
19
 
@@ -11,6 +11,8 @@ class GlacierDbArchive < GlacierArchive
11
11
 
12
12
  def archive_contents
13
13
  ApplicationDatabase.new.contents
14
+ rescue ApplicationDatabase::PostgresAdapter::PgPassFileMissing
15
+ nil
14
16
  rescue ApplicationDatabase::MissingConfigurationKeys
15
17
  nil
16
18
  end
@@ -3,11 +3,11 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "glacier_on_rails"
6
- s.version = "0.9.5"
6
+ s.version = "0.9.6"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Les Nightingill"]
10
- s.date = "2017-07-09"
10
+ s.date = "2017-07-12"
11
11
  s.description = "Rails engine for database backup/restore to/from Amazon Glacier, including file attachments."
12
12
  s.email = ["codehacker@comcast.net"]
13
13
  s.files = Dir.glob("{{app,config,db,lib,script,spec}/**/*,*}").reject{|f| f =~ /(cache|\.log|\.gem$)/}
@@ -175,4 +175,19 @@ feature "backup_now", :js => true do
175
175
  expect(flash_message).to eq "failed to create backup"
176
176
  end
177
177
  end
178
+
179
+ context "when there is a missing database password file" do
180
+ before do
181
+ ActiveRecord::Base.configurations[Rails.env].merge!({"password" => "sekret"})
182
+ allow(File).to receive(:exists?)
183
+ allow(File).to receive(:exists?).with("~/.pgpass").and_return(false)
184
+ end
185
+
186
+ it "should not create a new application_data_backup" do
187
+ expect{page.find('#backup_now').click; wait_for_ajax}.not_to change{ApplicationDataBackup.count}
188
+ expect(page).not_to have_selector("#application_data_backups .application_data_backup")
189
+ expect(flash_message).to eq "failed to create backup"
190
+ expect(aws_log).to match /ApplicationDatabase::PostgresAdapter::PgPassFileMissing exception: ~\/.pgpass file not found, cannot dump database contents/
191
+ end
192
+ end
178
193
  end
@@ -1,6 +1,51 @@
1
1
  require 'spec_helper'
2
2
  # helpers are all required in spec helper
3
3
 
4
+ describe "PostgresAdapter#contents dependence on password file ~/.pgpass" do
5
+ before do
6
+ @config = ActiveRecord::Base.configurations[Rails.env].dup
7
+ end
8
+ after do
9
+ ActiveRecord::Base.configurations[Rails.env] = @config
10
+ end
11
+
12
+ context "password not required in database config" do
13
+ before do
14
+ ActiveRecord::Base.configurations[Rails.env].merge!({"password" => nil })
15
+ allow(File).to receive(:exists?)
16
+ allow(File).to receive(:exists?).with("~/.pgpass").and_return(false)
17
+ end
18
+
19
+ it "should not raise an exception" do
20
+ expect{ ApplicationDatabase.new.contents }.not_to raise_exception
21
+ end
22
+ end
23
+
24
+ context "password is required in database config" do
25
+ before do
26
+ ActiveRecord::Base.configurations[Rails.env].merge!({"password" => "sekret"})
27
+ allow(File).to receive(:exists?)
28
+ allow(File).to receive(:exists?).with("~/.pgpass").and_return(false)
29
+ end
30
+
31
+ it "should raise an exception" do
32
+ expect{ ApplicationDatabase.new.contents }.to raise_exception ApplicationDatabase::PostgresAdapter::PgPassFileMissing
33
+ end
34
+ end
35
+
36
+ context "password is required in database config and .pgpass file is present" do
37
+ before do
38
+ ActiveRecord::Base.configurations[Rails.env].merge!({"password" => "sekret"})
39
+ allow(File).to receive(:exists?)
40
+ allow(File).to receive(:exists?).with("~/.pgpass").and_return(true)
41
+ end
42
+
43
+ it "should not raise an exception" do
44
+ expect{ ApplicationDatabase.new.contents }.not_to raise_exception
45
+ end
46
+ end
47
+ end
48
+
4
49
  describe "PostgresAdapter#create_object_restoral_list_omitting_exclusions" do
5
50
  include HttpMockHelpers
6
51
  include AwsHelper
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glacier_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Nightingill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-09 00:00:00.000000000 Z
11
+ date: 2017-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails