Sha256: 824103d5690a995791b8dfea53748b2612f642fdf4458713cb9a7730fcc15398

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

require_relative '../spec_helper'

module SAML2
  describe Entity do
    it "should parse and validate" do
      entity = Entity.parse(fixture('service_provider.xml'))
      entity.valid_schema?.must_equal true
    end

    it "should return nil when not valid schema" do
      entity = Entity.parse("<xml></xml>")
      entity.must_equal nil
    end

    it "should return nil on non-XML" do
      entity = Entity.parse("garbage")
      entity.must_equal nil
    end

    describe "valid schema" do
      let(:entity) { Entity.parse(fixture('service_provider.xml')) }

      it "should find the id" do
        entity.entity_id.must_equal "http://siteadmin.instructure.com/saml2"
      end

      it "should parse the organization" do
        entity.organization.display_name.must_equal 'Canvas'
        entity.organization.display_name('en').must_equal 'Canvas'
        entity.organization.display_name('es').must_equal nil
        entity.organization.display_name(:all).must_equal en: 'Canvas'
      end
    end

    describe Entity::Group do
      it "should parse and validate" do
        group = Entity.parse(fixture('entities.xml'))
        group.must_be_instance_of Entity::Group
        group.valid_schema?.must_equal true

        group.map(&:entity_id).must_equal ['urn:entity1', 'urn:entity2']
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
saml2-1.0.5 spec/lib/entity_spec.rb
saml2-1.0.4 spec/lib/entity_spec.rb
saml2-1.0.3 spec/lib/entity_spec.rb
saml2-1.0.2 spec/lib/entity_spec.rb
saml2-1.0.1 spec/lib/entity_spec.rb
saml2-1.0.0 spec/lib/entity_spec.rb