Skip to content
Permalink
Browse files

Add a couple of tests for the new sanity checks

See incommon/inc-validator#4.
  • Loading branch information
iay committed Sep 6, 2018
1 parent ff08441 commit 0318c992cb5afc56a841d786f6bb74e33ab86e86
Showing with 38 additions and 1 deletion.
  1. +6 −1 Rakefile
  2. +32 −0 test/test_validate_sanity.rb
@@ -28,7 +28,12 @@ task :test_validate_empty do
run_test 'validate_empty'
end

task :test_validate_sanity do
run_test 'validate_sanity'
end

task default: %i[test_get_validators test_bad_validator
test_bad_xml test_validate test_validate_empty] do
test_bad_xml test_validate test_validate_empty
test_validate_sanity] do
puts 'All tests done.'
end
@@ -0,0 +1,32 @@
require 'new_api'
require 'pp'

metadata = IO.read 'test/test_validate.xml'

# Sub-test: wrong element name
begin
md = metadata.gsub(/EntityDescriptor/, 'ED')
new_api.validate('test', md)
puts 'expected an exception, didn\'t get one'
rescue ValidatorClient::ApiError => e
if e.code == 400
puts 'found the expected exception'
pp JSON.parse e.response_body
else
puts "got the wrong exception: #{e.code}"
end
end

# Sub-test: no entityID
begin
md = metadata.gsub(/entityID=".*"/, '')
new_api.validate('test', md)
puts 'expected an exception, didn\'t get one'
rescue ValidatorClient::ApiError => e
if e.code == 400
puts 'found the expected exception'
pp JSON.parse e.response_body
else
puts "got the wrong exception: #{e.code}"
end
end

0 comments on commit 0318c99

Please sign in to comment.
You can’t perform that action at this time.