Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 184 lines (160 sloc) 4.921 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
##
# Models

Backup::Model.new(:archive_local, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  store_with Local
end

Backup::Model.new(:archive_scp, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  store_with SCP
end

# To initialize the Dropbox session cache, run manually first using:
# VERBOSE=1 rspec spec-live/storage/dropbox_spec.rb --tag init
Backup::Model.new(:archive_dropbox, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  store_with Dropbox
end

Backup::Model.new(:compressor_gzip_archive_local, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  compress_with Gzip
  store_with Local
end

Backup::Model.new(:compressor_custom_archive_local, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  compress_with Custom do |c|
    c.command = 'gzip -1'
    c.extension = '.foo'
  end
  store_with Local
end

Backup::Model.new(:notifier_mail, 'test_label') do
  notify_by Mail
end

Backup::Model.new(:notifier_mail_file, 'test_label') do
  notify_by Mail do |mail|
    mail.to = 'test@backup'
    mail.delivery_method = :file
  end
end

Backup::Model.new(:syncer_cloud_s3, 'test_label') do
  sync_with Cloud::S3 do |s3|
    s3.directories do
      add File.join(SpecLive::SYNC_PATH, 'dir_a')
      add File.join(SpecLive::SYNC_PATH, 'dir_b')
    end
  end
end

Backup::Model.new(:encryptor_gpg_asymmetric, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  encrypt_with GPG do |e|
    # this is the default mode
    # e.mode = :asymmetric

    e.keys = {
      # backup03 public key (email as identifier)
      'backup03@foo.com' => SpecLive::GPGKeys[:backup03][:public],
      # backup04 public key (long key id as identifier)
      '0F45932D3F24426D' => SpecLive::GPGKeys[:backup04][:public]
    }

    # The public keys for backup01 and backup02 will be in the system keyring
    # when this job is run. The public keys for backup03 and backup04 will be
    # imported from :keys above when they are not found in the system keyring.
    e.recipients = [
      # backup01 (short keyid)
      '16325C61',
      # backup02 (key fingerprint)
      'F9A9 9BD8 A570 182F F190 037C 7118 9938 6A6A 175A',
      # backup03 (email)
      'backup03@foo.com',
      # backup04 (long keyid)
      '0F45932D3F24426D'
    ]
  end
  store_with Local
end

Backup::Model.new(:encryptor_gpg_asymmetric_missing, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  encrypt_with GPG do |e|
    e.mode = :asymmetric

    e.keys = {
      'backup02@foo.com' => SpecLive::GPGKeys[:backup02][:public]
    }

    e.recipients = [
      'backup01@foo.com', # in the system
      'backup02@foo.com', # imported from #keys
      'backupfoo@foo.com' # a recipient with no public key
    ]
  end
  store_with Local
end

Backup::Model.new(:encryptor_gpg_asymmetric_fail, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  encrypt_with GPG do |e|
    # this is the default mode
    # e.mode = :asymmetric

    # no recipients have public keys available
    e.recipients = [
      'backupfoo@foo.com',
      'backupfoo2@foo.com'
    ]
  end
  store_with Local
end

Backup::Model.new(:encryptor_gpg_symmetric, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  encrypt_with GPG do |e|
    e.mode = :symmetric
    e.passphrase = 'a secret'
  end
  store_with Local
end

Backup::Model.new(:encryptor_gpg_symmetric_with_config, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  encrypt_with GPG do |e|
    e.mode = :symmetric
    e.passphrase = 'a secret'
    e.gpg_config = <<-EOS
personal-cipher-preferences AES256 CAST5
EOS
  end
  store_with Local
end

Backup::Model.new(:encryptor_gpg_both, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  encrypt_with GPG do |e|
    e.mode = :both
    e.passphrase = 'a secret'

    e.keys = {
      # backup03 public key (email as identifier)
      'backup03@foo.com' => SpecLive::GPGKeys[:backup03][:public]
    }

    # The public key for backup01 will be in the system keyring.
    # The public key for backup03 will be imported from :keys.
    e.recipients = [
      # backup01 (short keyid)
      '16325C61',
      # backup03 (email)
      'backup03@foo.com'
    ]
  end
  store_with Local
end

Backup::Model.new(:encryptor_gpg_both_no_asymmetric, 'test_label') do
  archive :test_archive, &SpecLive::ARCHIVE_JOB
  encrypt_with GPG do |e|
    e.mode = :both
    e.passphrase = 'a secret'

    # valid entry for backup04, but this is not one of the recipients
    e.keys = {
      'backup04@foo.com' => SpecLive::GPGKeys[:backup04][:public]
    }

    # no keys will be found for these,
    # so only symmetric encryption will be possible for this backup
    e.recipients = [
      # backup01 (short keyid)
      '16325C61',
      # backup03 (email)
      'backup03@foo.com'
    ]
  end
  store_with Local
end
Something went wrong with that request. Please try again.