shibkit-meta_meta 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +21 -0
  4. data/Gemfile.lock +52 -0
  5. data/Icon.png +0 -0
  6. data/LICENSE.txt +177 -0
  7. data/README.md +789 -0
  8. data/Rakefile +38 -0
  9. data/VERSION +1 -0
  10. data/examples/biggest_entity_id.rb +4 -0
  11. data/lib/shibkit/meta_meta.rb +600 -0
  12. data/lib/shibkit/meta_meta/attribute.rb +73 -0
  13. data/lib/shibkit/meta_meta/config.rb +463 -0
  14. data/lib/shibkit/meta_meta/contact.rb +85 -0
  15. data/lib/shibkit/meta_meta/data/default_metadata/example_federation_metadata.xml +168 -0
  16. data/lib/shibkit/meta_meta/data/default_metadata/local_metadata.xml +66 -0
  17. data/lib/shibkit/meta_meta/data/default_metadata/uncommon_federation_metadata.xml +115 -0
  18. data/lib/shibkit/meta_meta/data/default_metadata_cache.yml +166 -0
  19. data/lib/shibkit/meta_meta/data/dev_sources.yml +86 -0
  20. data/lib/shibkit/meta_meta/data/real_sources.yml +163 -0
  21. data/lib/shibkit/meta_meta/entity.rb +219 -0
  22. data/lib/shibkit/meta_meta/federation.rb +161 -0
  23. data/lib/shibkit/meta_meta/idp.rb +81 -0
  24. data/lib/shibkit/meta_meta/logo.rb +216 -0
  25. data/lib/shibkit/meta_meta/metadata_item.rb +244 -0
  26. data/lib/shibkit/meta_meta/mixin/cached_downloads.rb +127 -0
  27. data/lib/shibkit/meta_meta/mixin/xpath_chores.rb +111 -0
  28. data/lib/shibkit/meta_meta/organisation.rb +73 -0
  29. data/lib/shibkit/meta_meta/provider.rb +195 -0
  30. data/lib/shibkit/meta_meta/provisioning/base.rb +33 -0
  31. data/lib/shibkit/meta_meta/requested_attribute.rb +29 -0
  32. data/lib/shibkit/meta_meta/service.rb +94 -0
  33. data/lib/shibkit/meta_meta/source.rb +558 -0
  34. data/lib/shibkit/meta_meta/sp.rb +79 -0
  35. data/shibkit-meta_meta.gemspec +154 -0
  36. data/spec/meta_meta/attribute/token +0 -0
  37. data/spec/meta_meta/config/autoloading_and_refreshing_spec.rb +72 -0
  38. data/spec/meta_meta/config/code_nspec.rb +13 -0
  39. data/spec/meta_meta/config/configuration_spec.rb +30 -0
  40. data/spec/meta_meta/config/creation_spec.rb +43 -0
  41. data/spec/meta_meta/config/downloading_and_caching_settings_spec.rb +216 -0
  42. data/spec/meta_meta/config/env_platform_settings.rb +129 -0
  43. data/spec/meta_meta/config/filtering_settings_spec.rb +123 -0
  44. data/spec/meta_meta/config/init.rb +8 -0
  45. data/spec/meta_meta/config/logger_settings_spec.rb +91 -0
  46. data/spec/meta_meta/config/smartcache_settings_spec.rb +110 -0
  47. data/spec/meta_meta/config/source_file_settings_spec.rb +99 -0
  48. data/spec/meta_meta/config/tagging_settings_spec.rb +81 -0
  49. data/spec/meta_meta/config/working_directory_settings_spec.rb +106 -0
  50. data/spec/meta_meta/config/xml_processing_settings_spec.rb +75 -0
  51. data/spec/meta_meta/contact/contact_oldspec.rb +0 -0
  52. data/spec/meta_meta/entity/entity_oldspec.rb +53 -0
  53. data/spec/meta_meta/federation/federation_oldspec.rb +0 -0
  54. data/spec/meta_meta/idp/token +0 -0
  55. data/spec/meta_meta/logo/token +0 -0
  56. data/spec/meta_meta/meta_meta/cache_example.yaml +141284 -0
  57. data/spec/meta_meta/meta_meta/meta_meta_spec.rb +269 -0
  58. data/spec/meta_meta/meta_meta/saved_sources.yaml +46 -0
  59. data/spec/meta_meta/metadata_item/token +0 -0
  60. data/spec/meta_meta/organisation/organisation_oldspec.rb +0 -0
  61. data/spec/meta_meta/provider/token +0 -0
  62. data/spec/meta_meta/requested_attribute/token +0 -0
  63. data/spec/meta_meta/service/token +0 -0
  64. data/spec/meta_meta/source/application_extras_spec.rb +234 -0
  65. data/spec/meta_meta/source/conversion_spec.rb +75 -0
  66. data/spec/meta_meta/source/creation_spec.rb +0 -0
  67. data/spec/meta_meta/source/downloads_and_caching_spec.rb +0 -0
  68. data/spec/meta_meta/source/federation_information_spec.rb +11 -0
  69. data/spec/meta_meta/source/fixtures.rb +24 -0
  70. data/spec/meta_meta/source/init.rb +1 -0
  71. data/spec/meta_meta/source/loading_and_saving_spec.rb +0 -0
  72. data/spec/meta_meta/source/metadata_details_spec.rb +0 -0
  73. data/spec/meta_meta/source/metadata_integrity_spec.rb +0 -0
  74. data/spec/meta_meta/source/selection_spec.rb +0 -0
  75. data/spec/meta_meta/source/source_oldspec.rb +353 -0
  76. data/spec/meta_meta/source/xml_parsing_spec.rb +0 -0
  77. data/spec/meta_meta/sp/token +0 -0
  78. data/spec/meta_meta/template +2 -0
  79. data/spec/moi/config_spec.rb +0 -0
  80. data/spec/spec.opts +1 -0
  81. data/spec/spec_helper.rb +25 -0
  82. data/spec/support/supply_xml.rb +0 -0
  83. metadata +320 -0
@@ -0,0 +1,129 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe Shibkit::MetaMeta::Config, "platform settings" do
4
+
5
+ ## Testing a singleton is tricky! Make a copy of the class each time
6
+ before(:each) do
7
+ @config_class = Shibkit::MetaMeta::Config.clone
8
+ @config = @config_class.instance
9
+ end
10
+
11
+ subject { @config }
12
+
13
+ it { should respond_to :environment= }
14
+ it { should respond_to :environment }
15
+ it { should respond_to :in_production? }
16
+ it { should respond_to :version }
17
+ it { should respond_to :platform }
18
+
19
+ it "should allow the #environment to be set" do
20
+
21
+ @config.environment = :porcupine
22
+ @config.environment.should == :porcupine
23
+
24
+ end
25
+
26
+ it "should return an environment as a symbol when set" do
27
+
28
+ @config.environment = "testing"
29
+ @config.environment.should == :testing
30
+
31
+ end
32
+
33
+ it "should return :development from #environment by default" do
34
+
35
+ @config.environment.should == :development
36
+
37
+ end
38
+
39
+ context "if #environment has been set and #in_production is called" do
40
+
41
+ it "should return true if #environment is :production" do
42
+
43
+ @config.environment = :production
44
+ @config.in_production?.should be_true
45
+
46
+ end
47
+
48
+ it "should return false if #environment is :development" do
49
+
50
+ @config.environment = :development
51
+ @config.in_production?.should be_false
52
+
53
+ end
54
+
55
+ it "should return false if #environment is :test" do
56
+
57
+ @config.environment = :test
58
+ @config.in_production?.should be_false
59
+
60
+ end
61
+
62
+ end
63
+
64
+ context "If #environment has not been set and #in_production? has been called" do
65
+
66
+ it "should return true if Rails environment set and is production" do
67
+
68
+ Rails = Class.new unless defined? Rails # Smells...
69
+ Rails.stub_chain(:env,:production?).and_return(true)
70
+
71
+ @config.in_production?.should be_true
72
+
73
+ end
74
+
75
+ it "should return false if Rails environment set and is not :production" do
76
+
77
+ Rails = Class.new unless defined? Rails # Smells...
78
+
79
+ Rails.stub_chain(:env,:production?).and_return(false)
80
+ @config.in_production?.should be_false
81
+
82
+ end
83
+
84
+ it "should return true if Rack environment set and is 'production'" do
85
+
86
+ Rack = Class.new unless defined? Rack # Smells...
87
+ RACK_ENV = 'production'
88
+
89
+ @config.in_production?.should be_true
90
+
91
+ end
92
+
93
+ it "should return false if Rack environment set is not :production" do
94
+
95
+ Rack = Class.new unless defined Rack # Smells...
96
+ RACK_ENV = 'development'
97
+
98
+ @config.in_production?.should be_false
99
+
100
+ end
101
+
102
+ it "should return false if environment, Rack and Rails are all undefined" do
103
+
104
+ @config.in_production?.should be_false
105
+
106
+ end
107
+
108
+ end
109
+
110
+ it "should return a version string from #version with at least three parts" do
111
+
112
+ @config.version.should be_a_kind_of String
113
+ @config.version.split('.').count.should be > 2
114
+
115
+ end
116
+
117
+ it "should return a version string matching the MAJOR.MINOR.PATCH pattern" do
118
+
119
+ @config.version.should match /^(\d+)\.(\d+)\.(\d+)/
120
+
121
+ end
122
+
123
+ it "should return a string for #platform made up of three parts" do
124
+
125
+ @config.platform.split(':').count.should == 3
126
+
127
+ end
128
+
129
+ end
@@ -0,0 +1,123 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe Shibkit::MetaMeta::Config, "source and federation filtering settings" do
4
+
5
+ ## Testing a singleton is tricky! Make a copy of the class each time
6
+ before(:each) do
7
+ @config_class = Shibkit::MetaMeta::Config.clone
8
+ @config = @config_class.instance
9
+ end
10
+
11
+ subject { @config }
12
+
13
+ it { should respond_to :only_use }
14
+ it { should respond_to :selected_federation_uris= }
15
+ it { should respond_to :selected_federation_uris }
16
+ it { should respond_to :selected_groups= }
17
+ it { should respond_to :selected_groups }
18
+
19
+ it "should allow #only_use as a alternative to #selected_federation_uris" do
20
+
21
+ @config.only_use("http://ukfederation.org.uk")
22
+ @config.selected_federation_uris.should == ["http://ukfederation.org.uk"]
23
+
24
+ uris_list = ["http://ukfederation.org.uk",'urn:mace:incommon']
25
+ @config.only_use(uris_list)
26
+ @config.selected_federation_uris.should =~ ["http://ukfederation.org.uk",'urn:mace:incommon']
27
+
28
+ end
29
+
30
+ it "selected federations URIs should always be returned as a list" do
31
+
32
+ @config.selected_federation_uris = "http://ukfederation.org.uk"
33
+ @config.selected_federation_uris.should be_kind_of Array
34
+
35
+ uris_list = ["http://ukfederation.org.uk",'urn:mace:incommon']
36
+ @config.selected_federation_uris = uris_list
37
+ @config.selected_federation_uris.should be_kind_of Array
38
+
39
+ end
40
+
41
+ it "should allow selection of a single federation/source URI string to load" do
42
+
43
+ @config.selected_federation_uris = "http://ukfederation.org.uk"
44
+ @config.selected_federation_uris.should == ["http://ukfederation.org.uk"]
45
+
46
+ end
47
+
48
+ it "should allow selection of a list of federations/sources (as URIs) to load" do
49
+
50
+ uris_list = ["http://ukfederation.org.uk",'urn:mace:incommon']
51
+ @config.selected_federation_uris = uris_list
52
+ @config.selected_federation_uris.should =~ ["http://ukfederation.org.uk",'urn:mace:incommon']
53
+
54
+ end
55
+
56
+ it "should allow selected of a list of federations/sources from a Hash" do
57
+
58
+ uris_hash = {
59
+ 'http://ukfederation.org.uk' => "potato",
60
+ 'urn:mace:incommon' => 'potato'
61
+ }
62
+
63
+ @config.selected_federation_uris = uris_hash
64
+ @config.selected_federation_uris.should =~ ["http://ukfederation.org.uk",'urn:mace:incommon']
65
+
66
+ end
67
+
68
+ it "should allow (re)selection of all sources/federations using :all or :everything symbols" do
69
+
70
+ @config.selected_federation_uris = :all
71
+ @config.selected_federation_uris.should == []
72
+
73
+ @config.selected_federation_uris = :everything
74
+ @config.selected_federation_uris.should == []
75
+
76
+ end
77
+
78
+ it "should allow selection of all sources/federations by passing a nil or false to indicate no preference" do
79
+
80
+ @config.selected_federation_uris = nil
81
+ @config.selected_federation_uris.should == []
82
+
83
+ @config.selected_federation_uris = false
84
+ @config.selected_federation_uris.should == []
85
+
86
+ end
87
+
88
+ it "should allow selection of all sources/federations by passing an empty array or hash" do
89
+
90
+ @config.selected_federation_uris = []
91
+ @config.selected_federation_uris.should == []
92
+
93
+ @config.selected_federation_uris = {}
94
+ @config.selected_federation_uris.should == []
95
+
96
+ end
97
+
98
+ it "should allow selection of source one source group by name" do
99
+
100
+ @config.selected_groups = "spec_set_1"
101
+ @config.selected_groups.should =~ ['spec_set_1']
102
+
103
+ end
104
+
105
+ it "should allow selection of a list of source groups by an array of names" do
106
+
107
+ @config.selected_groups = ["spec_set_1", "spec_set_2"]
108
+ @config.selected_groups.should =~ ["spec_set_1", "spec_set_2"]
109
+
110
+ end
111
+
112
+ it "selected source groups should always be returned as an array" do
113
+
114
+ @config.selected_groups = ["spec_set_1", "spec_set_2"]
115
+ @config.selected_groups.should be_kind_of Array
116
+
117
+ @config.selected_groups = "spec_set_1"
118
+ @config.selected_groups.should be_kind_of Array
119
+
120
+ end
121
+
122
+
123
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ ## Testing a singleton is tricky! Make a copy of the class each time
4
+ before(:each) do
5
+ @config_class = Shibkit::MetaMeta::Config.clone
6
+ @config = @config_class.instance
7
+ end
8
+
@@ -0,0 +1,91 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe Shibkit::MetaMeta::Config, "logging settings" do
4
+
5
+ ## Testing a singleton is tricky! Make a copy of the class each time
6
+ before(:each) do
7
+ @config_class = Shibkit::MetaMeta::Config.clone
8
+ @config = @config_class.instance
9
+ end
10
+
11
+ subject { @config }
12
+
13
+ it { should respond_to :logger= }
14
+ it { should respond_to :logger }
15
+ it { should respond_to :verbose_downloads= }
16
+ it { should respond_to :verbose_downloads? }
17
+ it { should respond_to :downloads_logger= }
18
+ it { should respond_to :downloads_logger }
19
+
20
+ it "should allow any standard Ruby logger to be set as #logger" do
21
+
22
+ log_to_stdout = Logger.new(STDOUT)
23
+ expect { @config.logger = log_to_stdout }.should_not raise_error
24
+
25
+ end
26
+
27
+ it "should allow normal logger options to be set on logger" do
28
+
29
+ expect { @config.logger.level = ::Logger::DEBUG }.should_not raise_error
30
+
31
+ end
32
+
33
+ it "should allow a standard Ruby logger to be set as the download logger" do
34
+
35
+ mrlog = Logger.new(STDOUT)
36
+ expect { @config.downloads_logger = mrlog }.should_not raise_error
37
+
38
+ end
39
+
40
+ it "should allow normal logging options to be set on the download logger" do
41
+
42
+ expect { @config.logger.level = ::Logger::DEBUG }.should_not raise_error
43
+
44
+ end
45
+
46
+ it "should allow the downloads logger to be set to the main logger" do
47
+
48
+ expect { @config.downloads_logger = @config.logger }.should_not raise_error
49
+ expect { @config.downloads_logger.info "Boo" }
50
+
51
+ end
52
+
53
+ context "by default" do
54
+
55
+ it "should have verbose downloads turned off" do
56
+
57
+ @config.verbose_downloads?.should be_false
58
+
59
+ end
60
+
61
+ it "should not have a download logger specified" do
62
+
63
+ @config.downloads_logger.should be_nil
64
+
65
+ end
66
+
67
+ it "should have a default logger" do
68
+
69
+ @config.logger.should be_kind_of Logger
70
+
71
+ end
72
+
73
+ end
74
+
75
+ describe "The default logger" do
76
+
77
+ it "should output to STDOUT"
78
+
79
+ it "should be set to INFO output level" do
80
+
81
+ @config.logger.level.should == Logger::INFO
82
+
83
+ end
84
+
85
+ it "should name the application as MetaMeta"
86
+ it "should include severity/loglevel in output"
87
+ it "should include data/time in output"
88
+
89
+ end
90
+
91
+ end
@@ -0,0 +1,110 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe Shibkit::MetaMeta::Config, "Smartcache settings behavior" do
4
+
5
+ ## Testing a singleton is tricky! Make a copy of the class each time
6
+ before(:each) do
7
+ @config_class = Shibkit::MetaMeta::Config.clone
8
+ @config = @config_class.instance
9
+ end
10
+
11
+ subject { @config }
12
+
13
+ it { should respond_to :smartcache_expiry= }
14
+ it { should respond_to :smartcache_expiry }
15
+ it { should respond_to :smartcache_active= }
16
+ it { should respond_to :smartcache_active? }
17
+ it { should respond_to :smartcache_object_file }
18
+ it { should respond_to :smartcache_info_file }
19
+
20
+ it "should allow the #smartcache_expiry time to be set in seconds, with integer or string" do
21
+
22
+ @config.smartcache_expiry = 600
23
+ @config.smartcache_expiry.should == 600
24
+ @config.smartcache_expiry = "700"
25
+ @config.smartcache_expiry.should == 700
26
+ @config.smartcache_expiry = "800s"
27
+ @config.smartcache_expiry.should == 800
28
+
29
+ end
30
+
31
+ it "should return the #smartcache_expiry time to be returned as an integer" do
32
+
33
+ @config.smartcache_expiry = 400
34
+ @config.smartcache_expiry.should be_a_kind_of Fixnum
35
+
36
+ end
37
+
38
+ it "should allow the smartcache to be enabled or disabled" do
39
+
40
+ @config.smartcache_active = true
41
+ @config.smartcache_active?.should be_true
42
+
43
+ @config.smartcache_active = false
44
+ @config.smartcache_active?.should be_false
45
+
46
+ @config.smartcache_active = nil
47
+ @config.smartcache_active?.should be_false
48
+
49
+ end
50
+
51
+ it "should return if the smartcache is enabled or disabled" do
52
+ @config.smartcache_active = true
53
+ @config.smartcache_active?.should be_true
54
+
55
+ @config.smartcache_active = false
56
+ @config.smartcache_active?.should be_false
57
+
58
+ end
59
+
60
+ it "should return the location of the smartcache object data" do
61
+
62
+ @config.smartcache_object_file.should be_kind_of String
63
+ @config.smartcache_object_file.should match /\/smartcache.marshal$/
64
+
65
+ end
66
+
67
+ it "should return the location of the smartcache metadata" do
68
+
69
+ @config.smartcache_info_file.should be_kind_of String
70
+ @config.smartcache_info_file.should match /\/smartcache.yml$/
71
+
72
+ end
73
+
74
+ it "should save smartcache files in the cache_root, even if it changes" do
75
+
76
+ @config.smartcache_object_file.should include @config.cache_root
77
+ @config.smartcache_object_file.should include @config.cache_root
78
+
79
+ @config.cache_root = "/tmp/another_root"
80
+
81
+ @config.smartcache_object_file.should include @config.cache_root
82
+ @config.smartcache_object_file.should include @config.cache_root
83
+
84
+
85
+ end
86
+
87
+ context "by default" do
88
+
89
+ it "should have smartcache enabled" do
90
+
91
+ @config.smartcache_active?.should == true
92
+
93
+ end
94
+
95
+ it "should have smartcache set to expire in two hours" do
96
+
97
+ @config.smartcache_expiry.should == 3600
98
+
99
+ end
100
+
101
+ it "should save smartcache files in the default cache_root" do
102
+
103
+ @config.smartcache_object_file.should include @config.cache_root
104
+ @config.smartcache_object_file.should include @config.cache_root
105
+
106
+ end
107
+
108
+ end
109
+
110
+ end