aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/optional/capi
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-24 20:59:12 -0700
committerJeremy Evans <code@jeremyevans.net>2019-11-18 01:00:25 +0200
commitffd0820ab317542f8780aac475da590a4bdbc7a8 (patch)
tree6a5d774933c15fd2b9ea948bd3ae2fa587faaf82 /spec/ruby/optional/capi
parentc5c05460ac20abcbc0ed686eb4acf06da7a39a79 (diff)
downloadruby-ffd0820ab317542f8780aac475da590a4bdbc7a8.tar.gz
Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
Diffstat (limited to 'spec/ruby/optional/capi')
-rw-r--r--spec/ruby/optional/capi/object_spec.rb120
-rw-r--r--spec/ruby/optional/capi/string_spec.rb44
2 files changed, 91 insertions, 73 deletions
diff --git a/spec/ruby/optional/capi/object_spec.rb b/spec/ruby/optional/capi/object_spec.rb
index 43b74b9151..30abe715e7 100644
--- a/spec/ruby/optional/capi/object_spec.rb
+++ b/spec/ruby/optional/capi/object_spec.rb
@@ -414,11 +414,13 @@ describe "CApiObject" do
end
describe "FL_TEST" do
- it "returns correct status for FL_TAINT" do
- obj = Object.new
- @o.FL_TEST(obj, "FL_TAINT").should == 0
- obj.taint
- @o.FL_TEST(obj, "FL_TAINT").should_not == 0
+ ruby_version_is ''...'2.7' do
+ it "returns correct status for FL_TAINT" do
+ obj = Object.new
+ @o.FL_TEST(obj, "FL_TAINT").should == 0
+ obj.taint
+ @o.FL_TEST(obj, "FL_TAINT").should_not == 0
+ end
end
it "returns correct status for FL_FREEZE" do
@@ -570,61 +572,67 @@ describe "CApiObject" do
end
describe "OBJ_TAINT" do
- it "taints the object" do
- obj = mock("tainted")
- @o.OBJ_TAINT(obj)
- obj.tainted?.should be_true
+ ruby_version_is ''...'2.7' do
+ it "taints the object" do
+ obj = mock("tainted")
+ @o.OBJ_TAINT(obj)
+ obj.tainted?.should be_true
+ end
end
end
describe "OBJ_TAINTED" do
- it "returns C true if the object is tainted" do
- obj = mock("tainted")
- obj.taint
- @o.OBJ_TAINTED(obj).should be_true
- end
+ ruby_version_is ''...'2.7' do
+ it "returns C true if the object is tainted" do
+ obj = mock("tainted")
+ obj.taint
+ @o.OBJ_TAINTED(obj).should be_true
+ end
- it "returns C false if the object is not tainted" do
- obj = mock("untainted")
- @o.OBJ_TAINTED(obj).should be_false
+ it "returns C false if the object is not tainted" do
+ obj = mock("untainted")
+ @o.OBJ_TAINTED(obj).should be_false
+ end
end
end
describe "OBJ_INFECT" do
- it "does not taint the first argument if the second argument is not tainted" do
- host = mock("host")
- source = mock("source")
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_false
- end
+ ruby_version_is ''...'2.7' do
+ it "does not taint the first argument if the second argument is not tainted" do
+ host = mock("host")
+ source = mock("source")
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_false
+ end
- it "taints the first argument if the second argument is tainted" do
- host = mock("host")
- source = mock("source").taint
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_true
- end
+ it "taints the first argument if the second argument is tainted" do
+ host = mock("host")
+ source = mock("source").taint
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_true
+ end
- it "does not untrust the first argument if the second argument is trusted" do
- host = mock("host")
- source = mock("source")
- @o.OBJ_INFECT(host, source)
- host.untrusted?.should be_false
- end
+ it "does not untrust the first argument if the second argument is trusted" do
+ host = mock("host")
+ source = mock("source")
+ @o.OBJ_INFECT(host, source)
+ host.untrusted?.should be_false
+ end
- it "untrusts the first argument if the second argument is untrusted" do
- host = mock("host")
- source = mock("source").untrust
- @o.OBJ_INFECT(host, source)
- host.untrusted?.should be_true
- end
+ it "untrusts the first argument if the second argument is untrusted" do
+ host = mock("host")
+ source = mock("source").untrust
+ @o.OBJ_INFECT(host, source)
+ host.untrusted?.should be_true
+ end
- it "propagates both taint and distrust" do
- host = mock("host")
- source = mock("source").taint.untrust
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_true
- host.untrusted?.should be_true
+ it "propagates both taint and distrust" do
+ host = mock("host")
+ source = mock("source").taint.untrust
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_true
+ host.untrusted?.should be_true
+ end
end
end
@@ -659,15 +667,17 @@ describe "CApiObject" do
end
describe "rb_obj_taint" do
- it "marks the object passed as tainted" do
- obj = ""
- obj.tainted?.should == false
- @o.rb_obj_taint(obj)
- obj.tainted?.should == true
- end
+ ruby_version_is ''...'2.7' do
+ it "marks the object passed as tainted" do
+ obj = ""
+ obj.tainted?.should == false
+ @o.rb_obj_taint(obj)
+ obj.tainted?.should == true
+ end
- it "raises a #{frozen_error_class} if the object passed is frozen" do
- -> { @o.rb_obj_taint("".freeze) }.should raise_error(frozen_error_class)
+ it "raises a #{frozen_error_class} if the object passed is frozen" do
+ -> { @o.rb_obj_taint("".freeze) }.should raise_error(frozen_error_class)
+ end
end
end
diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb
index 53d28f7940..4da31445fe 100644
--- a/spec/ruby/optional/capi/string_spec.rb
+++ b/spec/ruby/optional/capi/string_spec.rb
@@ -167,8 +167,10 @@ describe "C-API String function" do
@s.rb_str_new("hello", 3).should == "hel"
end
- it "returns a non-tainted string" do
- @s.rb_str_new("hello", 5).tainted?.should == false
+ ruby_version_is ''...'2.7' do
+ it "returns a non-tainted string" do
+ @s.rb_str_new("hello", 5).tainted?.should == false
+ end
end
it "returns an empty string if len is 0" do
@@ -305,19 +307,21 @@ describe "C-API String function" do
end
end
- describe "rb_tainted_str_new" do
- it "creates a new tainted String" do
- newstring = @s.rb_tainted_str_new("test", 4)
- newstring.should == "test"
- newstring.tainted?.should be_true
+ ruby_version_is ''...'2.7' do
+ describe "rb_tainted_str_new" do
+ it "creates a new tainted String" do
+ newstring = @s.rb_tainted_str_new("test", 4)
+ newstring.should == "test"
+ newstring.tainted?.should be_true
+ end
end
- end
- describe "rb_tainted_str_new2" do
- it "creates a new tainted String" do
- newstring = @s.rb_tainted_str_new2("test")
- newstring.should == "test"
- newstring.tainted?.should be_true
+ describe "rb_tainted_str_new2" do
+ it "creates a new tainted String" do
+ newstring = @s.rb_tainted_str_new2("test")
+ newstring.should == "test"
+ newstring.tainted?.should be_true
+ end
end
end
@@ -684,8 +688,10 @@ describe :rb_external_str_new, shared: true do
@s.send(@method, "#{x80}abc").encoding.should == Encoding::BINARY
end
- it "returns a tainted String" do
- @s.send(@method, "abc").tainted?.should be_true
+ ruby_version_is ''...'2.7' do
+ it "returns a tainted String" do
+ @s.send(@method, "abc").tainted?.should be_true
+ end
end
end
@@ -767,9 +773,11 @@ describe "C-API String function" do
s.encoding.should equal(Encoding::EUC_JP)
end
- it "returns a tainted String" do
- s = @s.rb_external_str_new_with_enc("abc", 3, Encoding::US_ASCII)
- s.tainted?.should be_true
+ ruby_version_is ''...'2.7' do
+ it "returns a tainted String" do
+ s = @s.rb_external_str_new_with_enc("abc", 3, Encoding::US_ASCII)
+ s.tainted?.should be_true
+ end
end
end