fire_and_forget 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/fire_and_forget.gemspec
CHANGED
@@ -20,6 +20,10 @@ module FireAndForget
|
|
20
20
|
@task.binary
|
21
21
|
end
|
22
22
|
|
23
|
+
def binary_file
|
24
|
+
@task.binary.split(" ").first
|
25
|
+
end
|
26
|
+
|
23
27
|
def cmd
|
24
28
|
%(#{binary} #{FireAndForget.to_arguments(@params)})
|
25
29
|
end
|
@@ -29,12 +33,12 @@ module FireAndForget
|
|
29
33
|
end
|
30
34
|
|
31
35
|
def permitted?
|
32
|
-
raise PermissionsError, "'#{
|
36
|
+
raise PermissionsError, "'#{binary_file}' does not belong to user '#{ENV["USER"]}'" unless File.stat(binary_file).uid == task_uid
|
33
37
|
true
|
34
38
|
end
|
35
39
|
|
36
40
|
def exists?
|
37
|
-
raise FileNotFoundError, "'#{
|
41
|
+
raise FileNotFoundError, "'#{binary_file}'" unless File.exists?(binary_file)
|
38
42
|
true
|
39
43
|
end
|
40
44
|
|
@@ -77,7 +77,7 @@ class TestFireAndForget < Test::Unit::TestCase
|
|
77
77
|
stub(stat).uid { Process.uid + 1 }
|
78
78
|
stub(File).stat("/publish") { stat }
|
79
79
|
cmd = FAF::Command::Fire.new(@task)
|
80
|
-
lambda { cmd.run }.should raise_error
|
80
|
+
lambda { cmd.run }.should raise_error
|
81
81
|
end
|
82
82
|
|
83
83
|
should "not raise an error if the binary belongs to this process" do
|
@@ -85,7 +85,7 @@ class TestFireAndForget < Test::Unit::TestCase
|
|
85
85
|
stub(stat).uid { Process.uid }
|
86
86
|
stub(File).stat("/publish") { stat }
|
87
87
|
cmd = FAF::Command::Fire.new(@task)
|
88
|
-
lambda { cmd.permitted? }.should_not raise_error
|
88
|
+
lambda { cmd.permitted? }.should_not raise_error
|
89
89
|
end
|
90
90
|
|
91
91
|
should "raise an error if the binary belongs to this process" do
|
@@ -111,6 +111,17 @@ class TestFireAndForget < Test::Unit::TestCase
|
|
111
111
|
mock(cmd).run.times(0)
|
112
112
|
lambda { FAF::Server.run(cmd) }.should raise_error(FAF::PermissionsError)
|
113
113
|
end
|
114
|
+
|
115
|
+
should "work with binaries involving a command" do
|
116
|
+
task = FAF::TaskDescription.new(:publish, "/publish all")
|
117
|
+
stat = Object.new
|
118
|
+
stub(stat).uid { Process.uid }
|
119
|
+
stub(File).stat("/publish") { stat }
|
120
|
+
stub(File).exist?("/publish") { true }
|
121
|
+
stub(File).exists?("/publish") { true }
|
122
|
+
cmd = FAF::Command::Fire.new(task)
|
123
|
+
lambda { cmd.valid? }.should_not raise_error
|
124
|
+
end
|
114
125
|
end
|
115
126
|
|
116
127
|
context "client" do
|