Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aeden committed Aug 4, 2008
1 parent 6b246e3 commit 019f434
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/rsaml.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
$KCODE = 'UTF-8'

SAML_NAMESPACES = {
'saml' => 'urn:oasis:names:tc:SAML:2.0:assertion',
'samlp' => 'urn:oasis:names:tc:SAML:2.0:protocol',
'ds' => 'http://www.w3.org/2000/09/xmldsig#',
'xenc' => 'http://www.w3.org/2001/04/xmlenc#',
'xs' => 'http://www.w3.org/2001/XMLSchema',
'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
}
module RSAML
def saml_namespaces
{
'saml' => 'urn:oasis:names:tc:SAML:2.0:assertion',
'samlp' => 'urn:oasis:names:tc:SAML:2.0:protocol',
'ds' => 'http://www.w3.org/2000/09/xmldsig#',
'xenc' => 'http://www.w3.org/2001/04/xmlenc#',
'xs' => 'http://www.w3.org/2001/XMLSchema',
'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
}
end
end

require 'rubygems'
require 'uuid'
Expand Down
2 changes: 2 additions & 0 deletions lib/rsaml/action_namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def self.namespaces
}
end

# Get an ActionNamespace instance for the given namespace URI. This method will
# return nil if no namespace is found for the given URI
def self.namespace_for_uri(uri)
namespaces.values.find { |ns| ns.uri == uri }
end
Expand Down
8 changes: 8 additions & 0 deletions test/action_namespace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class ActionNamespaceTest < Test::Unit::TestCase
assert namespace_uris.include?('urn:oasis:names:tc:SAML:1.0:action:ghpp')
assert namespace_uris.include?('urn:oasis:names:tc:SAML:1.0:action:unix')
end
should "return a namespace instance given a URI" do
assert_equal(ActionNamespace.namespaces[:rwedc],
ActionNamespace.namespace_for_uri('urn:oasis:names:tc:SAML:1.0:action:rwedc')
)
assert_equal(ActionNamespace.namespaces[:rwedc_negation],
ActionNamespace.namespace_for_uri('urn:oasis:names:tc:SAML:1.0:action:rwedc-negation')
)
end
end
context "the rwdec namespace" do
setup do
Expand Down
12 changes: 12 additions & 0 deletions test/rsaml_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class RSAMLTest < Test::Unit::TestCase
context "the RSAML module" do
should "provide the SAML namespaces" do
assert_equal 'urn:oasis:names:tc:SAML:2.0:assertion', RSAML::saml_namespaces['saml']
assert_equal 'urn:oasis:names:tc:SAML:2.0:protocol', RSAML::saml_namespaces['samlp']
assert_equal 'http://www.w3.org/2000/09/xmldsig#', RSAML::saml_namespaces['ds']
assert_equal 'http://www.w3.org/2001/04/xmlenc#', RSAML::saml_namespaces['xenc']
assert_equal 'http://www.w3.org/2001/XMLSchema', RSAML::saml_namespaces['xs']
assert_equal 'http://www.w3.org/2001/XMLSchema-instance', RSAML::saml_namespaces['xsi']
end
end
end

0 comments on commit 019f434

Please sign in to comment.