lucid_works 0.7.9 → 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,8 @@ module LucidWorks
|
|
20
20
|
"filterer.class" => "com.lucid.security.WindowsACLQueryFilterer",
|
21
21
|
"provider.class" => "com.lucid.security.ad.ADACLTagProvider",
|
22
22
|
}
|
23
|
-
|
23
|
+
MAGIC_ACL_ONLY_FILTER_SETTING = {'should.clause' => '*:* -data_source_type:smb'}
|
24
|
+
|
24
25
|
validates_presence_of :name
|
25
26
|
|
26
27
|
def destroyable?
|
@@ -140,6 +141,12 @@ module LucidWorks
|
|
140
141
|
assert_components_include_ad_xor_role
|
141
142
|
return self.components.include?(AD_FILTERING)
|
142
143
|
end
|
144
|
+
|
145
|
+
def acl_only?
|
146
|
+
filterer_config = self.filtering_settings['filterer.config']
|
147
|
+
return false if filterer_config.nil?
|
148
|
+
return self.filtering_settings['filterer.config'] != MAGIC_ACL_ONLY_FILTER_SETTING #rescue false
|
149
|
+
end
|
143
150
|
|
144
151
|
def assert_components_include_ad_xor_role
|
145
152
|
# require 'ruby-debug'; debugger
|
@@ -163,7 +170,8 @@ module LucidWorks
|
|
163
170
|
opts[:config]['java.naming.provider.url'] = "ldap://#{opts[:config]['java.naming.provider.url']}"
|
164
171
|
end
|
165
172
|
filtering_settings = STATIC_ACL_CONFIG.merge('provider.config' => opts[:config])
|
166
|
-
|
173
|
+
filtering_settings["filterer.config"] = opts[:acl_only] ? {} : MAGIC_ACL_ONLY_FILTER_SETTING
|
174
|
+
|
167
175
|
errors = {}
|
168
176
|
method = RestClient.send(:get, uri+'/filtering')['adfiltering'] ? :put : :post
|
169
177
|
begin
|
@@ -7,6 +7,7 @@ describe "LucidWorks::Collection ACL configuration utility methods" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "ACL filtering configuration" do
|
10
|
+
MAGIC_ACL_ONLY_FILTER_SETTING = {'should.clause' => '*:* -data_source_type:smb'}
|
10
11
|
before :all do
|
11
12
|
@collection = @server.create_collection(:name => 'collection_for_acl_config_testing', :parent => @server)
|
12
13
|
@initial_components = [
|
@@ -135,7 +136,7 @@ describe "LucidWorks::Collection ACL configuration utility methods" do
|
|
135
136
|
}
|
136
137
|
|
137
138
|
@collection_for_configure.filtering_settings.should be_blank
|
138
|
-
@collection_for_configure.configure_filtering(:config => @settings, :enabled => 'true')
|
139
|
+
@collection_for_configure.configure_filtering(:config => @settings, :enabled => 'true', :acl_only => true)
|
139
140
|
@collection_for_configure.filtering_settings.should == final_settings
|
140
141
|
end
|
141
142
|
|
@@ -160,6 +161,52 @@ describe "LucidWorks::Collection ACL configuration utility methods" do
|
|
160
161
|
@collection_for_configure.configure_filtering(:config => settings, :enabled => 'true')
|
161
162
|
}.should raise_error {|e| e.messages.keys.first.should =~ /url\.no_url/} # because url is required
|
162
163
|
end
|
164
|
+
|
165
|
+
it "should add the filterer.config parameter if acl_only is false" do
|
166
|
+
settings = @settings.clone
|
167
|
+
|
168
|
+
@collection_for_configure.configure_filtering(:config => settings, :enabled => 'true', :acl_only => false)
|
169
|
+
@collection_for_configure.filtering_settings['filterer.config'].should == MAGIC_ACL_ONLY_FILTER_SETTING
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should remove the filterer.config parameter if acl_only is true" do
|
173
|
+
settings = @settings.clone
|
174
|
+
filterer_config = {}
|
175
|
+
|
176
|
+
@collection_for_configure.configure_filtering(:config => settings, :enabled => 'true', :acl_only => true)
|
177
|
+
@collection_for_configure.filtering_settings['filterer.config'].should == filterer_config
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe '#acl_only?' do
|
182
|
+
before :all do
|
183
|
+
@collection_for_acl_only = @server.create_collection(:name => 'collection_for_acl_only_testing', :parent => @server)
|
184
|
+
@settings = {
|
185
|
+
"java.naming.provider.url"=>"ldap://184.72.197.18/",
|
186
|
+
"java.naming.security.principal"=>"wma@corp.lucid.com",
|
187
|
+
"java.naming.security.credentials"=>"secret",
|
188
|
+
}
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should default to false for a new collection" do
|
192
|
+
@collection_for_acl_only_default = @server.create_collection(:name => 'collection_for_acl_only_default_testing', :parent => @server)
|
193
|
+
@collection_for_acl_only.acl_only?.should be_false
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should return true if the if configured with acl_only => true" do
|
197
|
+
settings = @settings.clone
|
198
|
+
|
199
|
+
@collection_for_acl_only.configure_filtering(:config => settings, :enabled => 'true', :acl_only => true)
|
200
|
+
@collection_for_acl_only.acl_only?.should be_true
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should return false if configured with acl_only => false" do
|
204
|
+
settings = @settings.clone
|
205
|
+
|
206
|
+
@collection_for_acl_only.configure_filtering(:config => settings, :enabled => 'true', :acl_only => false)
|
207
|
+
@collection_for_acl_only.acl_only?.should be_false
|
208
|
+
end
|
209
|
+
|
163
210
|
end
|
164
211
|
end
|
165
212
|
end
|