socialcast 1.2.1.RC1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ pkg
22
22
  Gemfile.lock
23
23
  pkg/*
24
24
 
25
+ users.xml.gz
@@ -135,12 +135,28 @@ module Socialcast
135
135
 
136
136
  permission_mappings = config.fetch 'permission_mappings', {}
137
137
  membership_attribute = permission_mappings.fetch 'attribute_name', 'memberof'
138
- attributes = mappings.values
138
+ attributes = mappings.values.map do |mapping_value|
139
+ mapping_value = begin
140
+ mapping_value.camelize.constantize
141
+ rescue NameError
142
+ mapping_value
143
+ end
144
+ case mapping_value
145
+ when Hash
146
+ dup_mapping_value = mapping_value.dup
147
+ dup_mapping_value.delete("value")
148
+ dup_mapping_value.values
149
+ when String
150
+ mapping_value
151
+ when Class, Module
152
+ fail "Please add the attributes method to #{mapping_value}" unless mapping_value.respond_to?(:attributes)
153
+ mapping_value.attributes
154
+ end
155
+ end.flatten
139
156
  attributes << membership_attribute
140
-
141
157
  user_identifier_list = %w{email unique_identifier employee_number}
142
158
  user_whitelist = Set.new
143
- count = 0
159
+ count = 0
144
160
  output_file = File.join Dir.pwd, options[:output]
145
161
  Zlib::GzipWriter.open(output_file) do |gz|
146
162
  xml = Builder::XmlMarkup.new(:target => gz, :indent => 1)
@@ -1,5 +1,7 @@
1
1
  require 'active_resource'
2
2
 
3
+ ActiveResource::Base.include_root_in_json = true
4
+
3
5
  module Socialcast
4
6
  class Message < ActiveResource::Base
5
7
  headers['Accept'] = 'application/json'
@@ -6,15 +6,16 @@ class Net::LDAP::Entry
6
6
  # abstracts away ldap multivalue attributes
7
7
  def grab(attribute)
8
8
  attribute = begin
9
- attribute.classify.constantize
9
+ attribute.camelize.constantize
10
10
  rescue NameError
11
11
  attribute
12
12
  end
13
13
 
14
14
  case attribute
15
15
  when Hash
16
- value = attribute.delete("value")
17
- value % Hash[attribute.map {|k,v| [k, grab(v)]}].symbolize_keys
16
+ dup_attribute = attribute.dup
17
+ value = dup_attribute.delete("value")
18
+ value % Hash[dup_attribute.map {|k,v| [k, grab(v)]}].symbolize_keys
18
19
  when String
19
20
  Array.wrap(self[attribute]).compact.first
20
21
  when Class, Module
@@ -1,3 +1,3 @@
1
1
  module Socialcast
2
- VERSION = "1.2.1.RC1"
2
+ VERSION = "1.2.2"
3
3
  end
data/socialcast.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.description = %q{publish messages to your stream from a command line interface}
14
14
 
15
15
  s.rubyforge_project = "socialcast"
16
-
16
+
17
17
  s.add_runtime_dependency 'rest-client', '>= 1.4.0'
18
18
  s.add_runtime_dependency 'json', '>= 1.4.6'
19
19
  s.add_runtime_dependency 'thor', '>= 0.14.6'
data/spec/cli_spec.rb CHANGED
@@ -7,8 +7,7 @@ describe Socialcast::CLI do
7
7
  before do
8
8
  Socialcast.stub(:credentials).and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'credentials.yml')))
9
9
  stub_request(:post, "https://ryan%40socialcast.com:foo@test.staging.socialcast.com/api/messages.json").
10
- with(:body => /message\_type\"\:null/).
11
- with(:body => /testing/).
10
+ with(:body => { "message" => { "body" => "testing", "url" => nil, "message_type" => nil, "attachment_ids" => [], "group_id" => nil }}).
12
11
  with(:headers => {'Accept' => 'application/json'}).
13
12
  to_return(:status => 200, :body => "", :headers => {})
14
13
 
@@ -175,14 +174,16 @@ describe Socialcast::CLI do
175
174
  @result = ''
176
175
  Zlib::GzipWriter.stub(:open).and_yield(@result)
177
176
  Socialcast.stub(:credentials).and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'credentials.yml')))
178
- Socialcast::CLI.any_instance.should_receive(:load_configuration).with('/my/path/to/ldap.yml').and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'ldap_without_permission_mappings.yml')))
177
+ Socialcast::CLI.any_instance.should_receive(:load_configuration).with('/my/path/to/ldap.yml').and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'ldap_with_plugin_mapping.yml')))
179
178
  File.should_receive(:exists?).with('/my/path/to/ldap.yml').and_return(true)
180
179
  File.stub(:open).with(/users.xml.gz/, anything).and_yield(@result)
181
180
  RestClient::Resource.any_instance.stub(:post)
182
181
 
183
182
  Socialcast::CLI.start ['provision', '-c', '/my/path/to/ldap.yml', '--plugins', [File.join(File.dirname(__FILE__), 'fixtures', 'fake_attribute_map')]]
184
183
  end
185
- it 'successfully processes' do end # see expectations
184
+ it 'successfully processes' do
185
+ @result.should =~ %r{rybn@exbmple.com}
186
+ end # see expectations
186
187
  end
187
188
  context 'with ldap.yml configuration excluding permission_mappings' do
188
189
  before do
@@ -1,5 +1,8 @@
1
1
  module Socialcast
2
2
  class FakeAttributeMap
3
+ def self.attributes
4
+ %w{mail}
5
+ end
3
6
  def self.run(entry)
4
7
  return "#{entry[:mail].first.gsub(/a/,'b')}"
5
8
  end
@@ -0,0 +1,53 @@
1
+ ---
2
+ # LDAP connections
3
+ connections:
4
+ example_connection_1:
5
+ username: "cn=Directory Manager"
6
+ password: "test"
7
+ host: localhost
8
+ port: 1389
9
+ basedn: "dc=example,dc=com"
10
+ filter: "(mail=*)"
11
+
12
+
13
+ # LDAP attribute mappings
14
+ mappings:
15
+ first_name: socialcast/fake_attribute_map
16
+ last_name: sn
17
+ email: mail
18
+ # only use employee_number if the email is unknown
19
+ # employee_number: emp_id
20
+ # only use unique_identifier if you do not wish to use email as the main user identification method
21
+ # unique_identifier: samaccountname
22
+
23
+
24
+ # Map LDAP Group Memberships to Socialcast Permissions
25
+ # permission_mappings:
26
+ # # configure LDAP field for group memberships (ex: memberof, isMemberOf, etc)
27
+ # attribute_name: isMemberOf
28
+ # account_types:
29
+ # external: "cn=External,dc=example,dc=com"
30
+ # roles:
31
+ # tenant_admin: "cn=Admins,dc=example,dc=com"
32
+ # sbi_admin: "cn=SbiAdmins,dc=example,dc=com"
33
+ # reach_admin: "cn=ReachAdmins,dc=example,dc=com"
34
+ # town_hall_admin: "cn=TownHallAdmins,dc=example,dc=com"
35
+
36
+
37
+ # general script options
38
+ options:
39
+ # cleanup the extracted ldap data file after run is complete
40
+ delete_users_file: false
41
+ # skip sending emails to newly activated users
42
+ skip_emails: true
43
+ # do not actually provision accounts
44
+ # useful during testing
45
+ test: true
46
+
47
+
48
+ # http options for connecting to Socialcast servers
49
+ http:
50
+ timeout: 660
51
+ # optional setting if script must connect to Socialcast server through a proxy
52
+ # proxy: "http://username:password@proxy.company.com:3128"
53
+
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1.RC1
5
- prerelease: 6
4
+ version: 1.2.2
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Sonnek
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-18 00:00:00.000000000 Z
13
+ date: 2013-08-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -192,6 +192,7 @@ files:
192
192
  - spec/fixtures/ldap_with_array_permission_mapping.yml
193
193
  - spec/fixtures/ldap_with_interpolated_values.yml
194
194
  - spec/fixtures/ldap_with_manager_attribute.yml
195
+ - spec/fixtures/ldap_with_plugin_mapping.yml
195
196
  - spec/fixtures/ldap_without_permission_mappings.yml
196
197
  - spec/net_ldap_ext_spec.rb
197
198
  - spec/spec_helper.rb
@@ -209,13 +210,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
210
  version: '0'
210
211
  segments:
211
212
  - 0
212
- hash: -357253051264046673
213
+ hash: 4299609609478338183
213
214
  required_rubygems_version: !ruby/object:Gem::Requirement
214
215
  none: false
215
216
  requirements:
216
- - - ! '>'
217
+ - - ! '>='
217
218
  - !ruby/object:Gem::Version
218
- version: 1.3.1
219
+ version: '0'
220
+ segments:
221
+ - 0
222
+ hash: 4299609609478338183
219
223
  requirements: []
220
224
  rubyforge_project: socialcast
221
225
  rubygems_version: 1.8.25
@@ -231,6 +235,7 @@ test_files:
231
235
  - spec/fixtures/ldap_with_array_permission_mapping.yml
232
236
  - spec/fixtures/ldap_with_interpolated_values.yml
233
237
  - spec/fixtures/ldap_with_manager_attribute.yml
238
+ - spec/fixtures/ldap_with_plugin_mapping.yml
234
239
  - spec/fixtures/ldap_without_permission_mappings.yml
235
240
  - spec/net_ldap_ext_spec.rb
236
241
  - spec/spec_helper.rb