@@ -8,6 +8,12 @@ def condition(before, after)
88 Samlr ::Condition . new ( element , { } )
99end
1010
11+ def verify!
12+ Time . stub ( :now , Time . at ( 1344379365 ) ) do
13+ subject . verify!
14+ end
15+ end
16+
1117describe Samlr ::Condition do
1218 before do
1319 @not_before = ( Time . now - 10 *60 )
@@ -25,17 +31,13 @@ def condition(before, after)
2531 end
2632
2733 it "raises an exception" do
28- Time . stub ( :now , Time . at ( 1344379365 ) ) do
29- assert subject . not_on_or_after_satisfied?
30- assert subject . not_before_satisfied?
31- refute subject . audience_satisfied?
34+ refute subject . audience_satisfied?
3235
33- begin
34- subject . verify!
35- flunk "Expected exception"
36- rescue Samlr ::ConditionsError => e
37- assert_match /Audience/ , e . message
38- end
36+ begin
37+ verify!
38+ flunk "Expected exception"
39+ rescue Samlr ::ConditionsError => e
40+ assert_match /Audience/ , e . message
3941 end
4042 end
4143 end
@@ -46,8 +48,35 @@ def condition(before, after)
4648 end
4749
4850 it "does not raise an exception" do
49- Time . stub ( :now , Time . at ( 1344379365 ) ) do
50- assert subject . verify!
51+ assert verify!
52+ end
53+ end
54+
55+ describe "using a regex" do
56+ describe "valid regex" do
57+ before do
58+ response . options [ :audience ] = /example\. (org|com)/
59+ end
60+
61+ it "does not raise an exception" do
62+ assert verify!
63+ end
64+ end
65+
66+ describe "invalid regex" do
67+ before do
68+ response . options [ :audience ] = /\A [a-z]\z /
69+ end
70+
71+ it "raises an exception" do
72+ refute subject . audience_satisfied?
73+
74+ begin
75+ verify!
76+ flunk "Expected exception"
77+ rescue Samlr ::ConditionsError => e
78+ assert_match /Audience/ , e . message
79+ end
5180 end
5281 end
5382 end
0 commit comments