-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addition of tests. Large commit, one message won't do it justice.
- Loading branch information
1 parent
10eedd6
commit 886fa7a
Showing
52 changed files
with
2,340 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require_relative '../../lib/AppleBackup.rb' | ||
|
||
describe AppleBackup, :expensive => true do | ||
before(:context) do | ||
TEST_OUTPUT_DIR.mkpath | ||
end | ||
after(:context) do | ||
TEST_OUTPUT_DIR.rmtree | ||
end | ||
|
||
let(:backup) { AppleBackup.new(TEST_DATA_DIR, 0, TEST_OUTPUT_DIR) } | ||
|
||
context "validations" do | ||
it "raises an error rather than failing validation" do | ||
expect{backup.valid?}.to raise_error("AppleBackup cannot stand on its own") | ||
end | ||
|
||
end | ||
|
||
context "files" do | ||
it "raises an error since it has no real file path" do | ||
expect{backup.get_real_file_path("test.tmp")}.to raise_error("Cannot return file_path for AppleBackup") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
require_relative '../../lib/AppleBackupFile.rb' | ||
|
||
describe AppleBackupFile, :expensive => true do | ||
before(:context) do | ||
TEST_OUTPUT_DIR.mkpath | ||
end | ||
after(:context) do | ||
TEST_OUTPUT_DIR.rmtree | ||
end | ||
|
||
let(:valid_backup) { AppleBackupFile.new(TEST_FORMATTING_FILE, TEST_OUTPUT_DIR) } | ||
|
||
context "validations" do | ||
it "validates a NoteStore.sqlite file", :missing_data => !TEST_FORMATTING_FILE_EXIST do | ||
expect(valid_backup.valid?).to be true | ||
end | ||
|
||
it "fails to validate a non-NoteStore sqlite file", :missing_data => !TEST_FALSE_SQLITE_FILE_EXIST do | ||
backup = AppleBackupFile.new(TEST_FALSE_SQLITE_FILE, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a non-sqlite file", :missing_data => !TEST_README_FILE_EXIST do | ||
backup = AppleBackupFile.new(TEST_README_FILE, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate an itunes backup folder", :missing_data => !TEST_ITUNES_DIR_EXIST do | ||
backup = AppleBackupFile.new(TEST_ITUNES_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a physical backup folder", :missing_data => !TEST_PHYSICAL_DIR_EXIST do | ||
backup = AppleBackupFile.new(TEST_PHYSICAL_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a mac backup folder", :missing_data => !TEST_MAC_DIR_EXIST do | ||
backup = AppleBackupFile.new(TEST_MAC_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
end | ||
|
||
context "versions" do | ||
|
||
it "correctly identifies all major versions" do | ||
# To do: acquire iOS 11 sample for here | ||
TEST_FILE_VERSIONS.each_pair do |version, version_file| | ||
backup = AppleBackupFile.new(version_file, TEST_OUTPUT_DIR) | ||
expect(backup.note_stores[0].version.version_number).to be version | ||
end | ||
end | ||
end | ||
|
||
context "files", :missing_data => !TEST_FORMATTING_FILE_EXIST do | ||
it "does not try to assert where a file is" do | ||
backup = AppleBackupFile.new(TEST_FORMATTING_FILE, TEST_OUTPUT_DIR) | ||
expect(valid_backup.get_real_file_path("NoteStore.sqlite")).to be nil | ||
end | ||
end | ||
|
||
context "note stores", :missing_data => !TEST_FORMATTING_FILE_EXIST do | ||
it "knows how to find just a modern note store" do | ||
expect(valid_backup.note_stores.length).to be 1 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require_relative '../../lib/AppleBackupHashed.rb' | ||
|
||
describe AppleBackupHashed, :expensive => true do | ||
before(:context) do | ||
TEST_OUTPUT_DIR.mkpath | ||
end | ||
after(:context) do | ||
TEST_OUTPUT_DIR.rmtree | ||
end | ||
|
||
let(:valid_backup) { AppleBackupHashed.new(TEST_ITUNES_DIR, TEST_OUTPUT_DIR) } | ||
|
||
context "validations" do | ||
it "validates an itunes backup folder", :missing_data => !TEST_ITUNES_DIR_EXIST do | ||
expect(valid_backup.valid?).to be true | ||
end | ||
|
||
it "fails to validate a physical backup folder", :missing_data => !TEST_PHYSICAL_DIR_EXIST do | ||
backup = AppleBackupHashed.new(TEST_PHYSICAL_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a mac backup folder", :missing_data => !TEST_MAC_DIR_EXIST do | ||
backup = AppleBackupHashed.new(TEST_MAC_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a valid NoteStore.sqlite file", :missing_data => !TEST_FORMATTING_FILE_EXIST do | ||
backup = AppleBackupHashed.new(TEST_FORMATTING_FILE, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
end | ||
|
||
context "files", :missing_data => !TEST_ITUNES_DIR_EXIST do | ||
it "knows how to find an appropriate file" do | ||
expect(valid_backup.get_real_file_path("NoteStore.sqlite").to_s).to match(/spec\/data\/itunes_backup\/4f\/4f98687d8ab0d6d1a371110e6b7300f6e465bef2/) | ||
end | ||
end | ||
|
||
context "note stores", :missing_data => !TEST_ITUNES_DIR_EXIST do | ||
it "knows how to find both legacy and modern note stores" do | ||
expect(valid_backup.note_stores.length).to be 2 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require_relative '../../lib/AppleBackupMac.rb' | ||
|
||
describe AppleBackupMac, :expensive => true do | ||
before(:context) do | ||
TEST_OUTPUT_DIR.mkpath | ||
end | ||
after(:context) do | ||
TEST_OUTPUT_DIR.rmtree | ||
end | ||
|
||
let(:valid_backup) { AppleBackupMac.new(TEST_MAC_DIR, TEST_OUTPUT_DIR) } | ||
|
||
context "validations" do | ||
it "validates a mac backup folder", :missing_data => !TEST_MAC_DIR_EXIST do | ||
expect(valid_backup.valid?).to be true | ||
end | ||
|
||
it "fails to validate an itunes backup folder", :missing_data => !TEST_ITUNES_DIR_EXIST do | ||
backup = AppleBackupMac.new(TEST_ITUNES_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a physical backup folder", :missing_data => !TEST_PHYSICAL_DIR_EXIST do | ||
backup = AppleBackupMac.new(TEST_PHYSICAL_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a valid NoteStore.sqlite file", :missing_data => !TEST_FORMATTING_FILE_EXIST do | ||
backup = AppleBackupMac.new(TEST_FORMATTING_FILE, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
end | ||
|
||
context "files", :missing_data => !TEST_MAC_DIR_EXIST do | ||
it "knows how to find an appropriate file" do | ||
expect(valid_backup.get_real_file_path("NoteStore.sqlite").to_s).to match(/spec\/data\/mac_backup\/NoteStore.sqlite/) | ||
end | ||
end | ||
|
||
context "note stores", :missing_data => !TEST_MAC_DIR_EXIST do | ||
it "knows how to find just a modern note store" do | ||
expect(valid_backup.note_stores.length).to be 1 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require_relative '../../lib/AppleBackupPhysical.rb' | ||
|
||
describe AppleBackupPhysical, :expensive => true do | ||
before(:context) do | ||
TEST_OUTPUT_DIR.mkpath | ||
end | ||
after(:context) do | ||
TEST_OUTPUT_DIR.rmtree | ||
end | ||
|
||
let(:valid_backup) { AppleBackupPhysical.new(TEST_PHYSICAL_DIR, TEST_OUTPUT_DIR) } | ||
|
||
context "validations" do | ||
it "validates a physical backup folder", :missing_data => !TEST_PHYSICAL_DIR_EXIST do | ||
expect(valid_backup.valid?).to be true | ||
end | ||
|
||
it "fails to validate an itunes backup folder", :missing_data => !TEST_ITUNES_DIR_EXIST do | ||
backup = AppleBackupPhysical.new(TEST_ITUNES_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a mac backup folder", :missing_data => !TEST_MAC_DIR_EXIST do | ||
backup = AppleBackupPhysical.new(TEST_MAC_DIR, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
|
||
it "fails to validate a valid NoteStore.sqlite file", :missing_data => !TEST_FORMATTING_FILE_EXIST do | ||
backup = AppleBackupPhysical.new(TEST_FORMATTING_FILE, TEST_OUTPUT_DIR) | ||
expect(backup.valid?).to be false | ||
end | ||
end | ||
|
||
context "files", :missing_data => !TEST_PHYSICAL_DIR_EXIST do | ||
it "knows how to find an appropriate file" do | ||
expect(valid_backup.get_real_file_path("NoteStore.sqlite").to_s).to match(/private\/var\/mobile\/Containers\/Shared\/AppGroup\/[A-F0-9\-]{36}\/NoteStore.sqlite/) | ||
end | ||
end | ||
|
||
context "note stores", :missing_data => !TEST_PHYSICAL_DIR_EXIST do | ||
it "knows how to find both legacy and modern note stores" do | ||
expect(valid_backup.note_stores.length).to be 2 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require_relative 'apple_backup.rb' | ||
require_relative 'apple_backup_file.rb' | ||
require_relative 'apple_backup_hashed.rb' | ||
require_relative 'apple_backup_mac.rb' | ||
require_relative 'apple_backup_physical.rb' |
Oops, something went wrong.