|
1 | | -require "test_helper" |
| 1 | +require File.expand_path(File.join(File.dirname(__FILE__), "test_helper")) |
2 | 2 |
|
3 | 3 | class UtilsTest < Minitest::Test |
4 | 4 | describe ".format_cert" do |
@@ -154,5 +154,55 @@ class UtilsTest < Minitest::Test |
154 | 154 | refute_equal OneLogin::RubySaml::Utils.uuid, OneLogin::RubySaml::Utils.uuid |
155 | 155 | end |
156 | 156 | end |
| 157 | + |
| 158 | + describe 'uri_match' do |
| 159 | + it 'matches two urls' do |
| 160 | + destination = 'http://www.example.com/test?var=stuff' |
| 161 | + settings = 'http://www.example.com/test?var=stuff' |
| 162 | + assert OneLogin::RubySaml::Utils.uri_match?(destination, settings) |
| 163 | + end |
| 164 | + |
| 165 | + it 'fails to match two urls' do |
| 166 | + destination = 'http://www.example.com/test?var=stuff' |
| 167 | + settings = 'http://www.example.com/othertest?var=stuff' |
| 168 | + assert !OneLogin::RubySaml::Utils.uri_match?(destination, settings) |
| 169 | + end |
| 170 | + |
| 171 | + it "matches two URLs if the scheme case doesn't match" do |
| 172 | + destination = 'http://www.example.com/test?var=stuff' |
| 173 | + settings = 'HTTP://www.example.com/test?var=stuff' |
| 174 | + assert OneLogin::RubySaml::Utils.uri_match?(destination, settings) |
| 175 | + end |
| 176 | + |
| 177 | + it "matches two URLs if the host case doesn't match" do |
| 178 | + destination = 'http://www.EXAMPLE.com/test?var=stuff' |
| 179 | + settings = 'http://www.example.com/test?var=stuff' |
| 180 | + assert OneLogin::RubySaml::Utils.uri_match?(destination, settings) |
| 181 | + end |
| 182 | + |
| 183 | + it "fails to match two URLs if the path case doesn't match" do |
| 184 | + destination = 'http://www.example.com/TEST?var=stuff' |
| 185 | + settings = 'http://www.example.com/test?var=stuff' |
| 186 | + assert !OneLogin::RubySaml::Utils.uri_match?(destination, settings) |
| 187 | + end |
| 188 | + |
| 189 | + it "fails to match two URLs if the query case doesn't match" do |
| 190 | + destination = 'http://www.example.com/test?var=stuff' |
| 191 | + settings = 'http://www.example.com/test?var=STUFF' |
| 192 | + assert !OneLogin::RubySaml::Utils.uri_match?(destination, settings) |
| 193 | + end |
| 194 | + |
| 195 | + it 'matches two non urls' do |
| 196 | + destination = 'stuff' |
| 197 | + settings = 'stuff' |
| 198 | + assert OneLogin::RubySaml::Utils.uri_match?(destination, settings) |
| 199 | + end |
| 200 | + |
| 201 | + it "fails to match two non urls" do |
| 202 | + destination = 'stuff' |
| 203 | + settings = 'not stuff' |
| 204 | + assert !OneLogin::RubySaml::Utils.uri_match?(destination, settings) |
| 205 | + end |
| 206 | + end |
157 | 207 | end |
158 | 208 | end |
0 commit comments