2017-02-08 08:54:20 +01:00
|
|
|
# TODO: this test should be named after the corresponding class, once
|
|
|
|
# that class is abstracted from installer.rb.
|
2017-03-05 19:26:56 +01:00
|
|
|
describe "Accessibility Access", :cask do
|
2017-10-07 15:58:49 +02:00
|
|
|
let(:cask) { Hbc::CaskLoader.load(cask_path("with-accessibility-access")) }
|
2018-07-19 23:56:51 +02:00
|
|
|
let(:fake_system_command) { class_double(SystemCommand) }
|
2017-02-08 08:54:20 +01:00
|
|
|
let(:installer) { Hbc::Installer.new(cask, command: fake_system_command) }
|
|
|
|
|
2018-03-25 13:30:37 +01:00
|
|
|
before do
|
2017-02-08 08:54:20 +01:00
|
|
|
allow(MacOS).to receive(:version).and_return(MacOS::Version.new(macos_version))
|
|
|
|
allow(installer).to receive(:bundle_identifier).and_return("com.example.BasicCask")
|
|
|
|
end
|
|
|
|
|
|
|
|
context "on MacOS 10.8 and below" do
|
|
|
|
let(:macos_version) { "10.8" }
|
|
|
|
|
|
|
|
it "can enable accessibility access in macOS releases prior to Mavericks" do
|
|
|
|
expect(fake_system_command).to receive(:run!).with(
|
|
|
|
"/usr/bin/touch",
|
2018-06-09 09:01:09 +02:00
|
|
|
args: [MacOS.pre_mavericks_accessibility_dotfile],
|
2017-02-12 15:06:54 +00:00
|
|
|
sudo: true,
|
2017-02-08 08:54:20 +01:00
|
|
|
)
|
|
|
|
|
2017-07-29 19:55:05 +02:00
|
|
|
installer.enable_accessibility_access
|
2017-02-08 08:54:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "warns about disabling accessibility access on old macOS releases" do
|
|
|
|
expect {
|
|
|
|
installer.disable_accessibility_access
|
2018-09-02 16:15:09 +01:00
|
|
|
}.to output(
|
|
|
|
/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./,
|
|
|
|
).to_stderr
|
2017-02-08 08:54:20 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "on MacOS 10.9" do
|
|
|
|
let(:macos_version) { "10.9" }
|
|
|
|
|
|
|
|
it "can enable accessibility access" do
|
|
|
|
expect(fake_system_command).to receive(:run!).with(
|
|
|
|
"/usr/bin/sqlite3",
|
2018-09-02 16:15:09 +01:00
|
|
|
args: [
|
|
|
|
MacOS.tcc_db,
|
|
|
|
"INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);",
|
|
|
|
],
|
2017-02-12 15:06:54 +00:00
|
|
|
sudo: true,
|
2017-02-08 08:54:20 +01:00
|
|
|
)
|
|
|
|
|
2017-07-29 19:55:05 +02:00
|
|
|
installer.enable_accessibility_access
|
2017-02-08 08:54:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "can disable accessibility access" do
|
|
|
|
expect(fake_system_command).to receive(:run!).with(
|
|
|
|
"/usr/bin/sqlite3",
|
2018-06-09 09:01:09 +02:00
|
|
|
args: [MacOS.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"],
|
2017-02-12 15:06:54 +00:00
|
|
|
sudo: true,
|
2017-02-08 08:54:20 +01:00
|
|
|
)
|
|
|
|
|
2017-07-29 19:55:05 +02:00
|
|
|
installer.disable_accessibility_access
|
2017-02-08 08:54:20 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "on MacOS 10.12 and above" do
|
|
|
|
let(:macos_version) { "10.12" }
|
|
|
|
|
|
|
|
it "warns about enabling accessibility access on new macOS releases" do
|
|
|
|
expect {
|
|
|
|
expect {
|
|
|
|
installer.enable_accessibility_access
|
|
|
|
}.to output.to_stdout
|
2018-09-02 16:15:09 +01:00
|
|
|
}.to output(
|
|
|
|
/Warning: Accessibility access cannot be enabled automatically on this version of macOS\./,
|
|
|
|
).to_stderr
|
2017-02-08 08:54:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "warns about disabling accessibility access on new macOS releases" do
|
|
|
|
expect {
|
|
|
|
installer.disable_accessibility_access
|
2018-09-02 16:15:09 +01:00
|
|
|
}.to output(
|
|
|
|
/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./,
|
|
|
|
).to_stderr
|
2017-02-08 08:54:20 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|