socialcast 1.3.1 → 1.3.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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjNhNDIwYjFlZTRhZTk4MDE4MWI3YzE2NmNkMmJkZDU0ZWZhYTUyNw==
5
+ data.tar.gz: !binary |-
6
+ MjNhYzZiMDlhN2VjZDZhNjUzNDRiODFjNTZhYmQ0N2Q1NWVkMmM0OQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YWE3ZTdlMDNhMjk5ZTA2Mjc3NjkxOGNlYzkwOWYxNjMyNDU3NDllY2U3MmI5
10
+ ODBjNDM2NjllNDNjMjM0MmY1OTM0NmE1NjBhYWNjODQ1NDVlNTk0M2EyNGQw
11
+ MmNiMjQzOGJiYWQ1MDg3NTBjOWRkZDYwYjczODM2ZWRmMDQ2Yjc=
12
+ data.tar.gz: !binary |-
13
+ Y2M0MTZkM2Q3YTlhOTQwNDBlOGI2NWJmYTIwYWZkODg4ODQ0NTBkNjM1YTZm
14
+ NjUzMmUzZDkxM2U3MjI3NjA1YWQwNjY3OWFiNTEwZTMxYjRjN2U3OWEyZmZh
15
+ ZTA1ZGVmZmY5NTFiMWRmM2Y2ODhiMjQ1ZDIyYjU1NDQyNzE3ODc=
@@ -115,6 +115,15 @@ module Socialcast
115
115
  each_ldap_entry do |ldap, entry, attr_mappings, _|
116
116
  email = grab(entry, attr_mappings['email'])
117
117
  if profile_photo_data = grab(entry, attr_mappings['profile_photo'])
118
+ if profile_photo_data.start_with?('http')
119
+ begin
120
+ profile_photo_data = RestClient.get(profile_photo_data)
121
+ rescue => e
122
+ puts "Unable to download photo #{profile_photo_data} for #{email}"
123
+ puts e.response
124
+ next
125
+ end
126
+ end
118
127
  profile_photo_data = profile_photo_data.force_encoding('binary')
119
128
 
120
129
  user_search_response = search_users_resource.get(:params => { :q => email, :per_page => 1 }, :accept => :json)
@@ -1,5 +1,5 @@
1
1
  module Socialcast
2
2
  module CommandLine
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.2"
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ connections:
11
11
 
12
12
 
13
13
  # LDAP attribute mappings
14
- mappings:
14
+ mappings:
15
15
  first_name: givenName
16
16
  last_name: sn
17
17
  email: mail
@@ -1,4 +1,4 @@
1
- ---
1
+ ---
2
2
  connections:
3
3
  example_connection_1:
4
4
  username: "cn=Directory Manager"
@@ -9,7 +9,7 @@ connections:
9
9
  filter: "(mail=*)"
10
10
 
11
11
  # LDAP attribute mappings
12
- mappings:
12
+ mappings:
13
13
  first_name: givenName
14
14
  last_name: sn
15
15
  email: mail
@@ -15,6 +15,7 @@ describe Socialcast::CommandLine::Provision do
15
15
  let!(:ldap_with_plugin_mapping_config) { YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'ldap_with_plugin_mapping.yml')) }
16
16
  let!(:ldap_with_roles_without_account_type_config) { YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'ldap_with_roles_without_account_type.yml')) }
17
17
  let!(:ldap_with_unique_identifier_config) { YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'ldap_with_unique_identifier.yml')) }
18
+ let!(:ldap_with_profile_photo) { YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'ldap_with_profile_photo.yml')) }
18
19
  let!(:ldap_without_account_type_or_roles_config) { YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'ldap_without_account_type_or_roles.yml')) }
19
20
  let!(:ldap_without_filter_config) { YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'ldap_without_filter.yml')) }
20
21
 
@@ -586,4 +587,71 @@ describe Socialcast::CommandLine::Provision do
586
587
  end
587
588
  end
588
589
  end
590
+
591
+ describe '#sync_photos' do
592
+ let(:user_search_resource) { double(:user_search_resource) }
593
+ let(:search_api_response) do
594
+ {
595
+ 'users' => [
596
+ {
597
+ 'id' => 7,
598
+ 'avatars' => {
599
+ 'is_system_default' => true
600
+ }
601
+ }
602
+ ]
603
+ }
604
+ end
605
+ before do
606
+ entry = create_entry :mail => 'user@example.com', :givenName => 'first name', :sn => 'last name', :jpegPhoto => photo_data
607
+ Net::LDAP.any_instance.should_receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'jpegPhoto', 'memberof'])).and_yield(entry)
608
+
609
+ Socialcast::CommandLine.stub(:resource_for_path).with('/api/users/search', anything).and_return(user_search_resource)
610
+ end
611
+ let(:sync_photos) { Socialcast::CommandLine::Provision.new(ldap_with_profile_photo, {}).sync_photos }
612
+
613
+ context 'for when it does successfully post the photo' do
614
+ before do
615
+ user_search_resource.should_receive(:get).and_return(search_api_response.to_json)
616
+ user_resource = double(:user_resource)
617
+ user_resource.should_receive(:put) do |data|
618
+ uploaded_data = data[:user][:profile_photo][:data]
619
+ uploaded_data.path.should =~ /\.png\Z/
620
+ end
621
+ Socialcast::CommandLine.stub(:resource_for_path).with('/api/users/7', anything).and_return(user_resource)
622
+ end
623
+ context 'for a binary file' do
624
+ let(:photo_data) { "\x89PNGabc" }
625
+ before do
626
+ RestClient.should_not_receive(:get)
627
+ sync_photos
628
+ end
629
+ it 'uses the original binary to upload the photo' do end
630
+ end
631
+ context 'for an image file' do
632
+ let(:photo_data) { "http://socialcast.com/someimage.png" }
633
+ context 'when it successfully downloads' do
634
+ before do
635
+ RestClient.should_receive(:get).with(photo_data).and_return("\x89PNGabc")
636
+ sync_photos
637
+ end
638
+ it 'downloads the image form the web to upload the photo' do end
639
+ end
640
+ end
641
+ end
642
+
643
+ context 'for when it does not successfully post the photo' do
644
+ context 'for an image file' do
645
+ let(:photo_data) { "http://socialcast.com/someimage.png" }
646
+ before do
647
+ user_search_resource.should_not_receive(:get)
648
+ RestClient.should_receive(:get).with(photo_data).and_raise(RestClient::ResourceNotFound)
649
+ sync_photos
650
+ end
651
+ it 'tries to download the image from the web and rescues 404' do end
652
+ end
653
+ end
654
+
655
+ end
656
+
589
657
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
5
- prerelease:
4
+ version: 1.3.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Sonnek
@@ -11,12 +10,11 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2014-03-27 00:00:00.000000000 Z
13
+ date: 2014-04-08 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rest-client
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
19
  - - ~>
22
20
  - !ruby/object:Gem::Version
@@ -24,7 +22,6 @@ dependencies:
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
26
  - - ~>
30
27
  - !ruby/object:Gem::Version
@@ -32,7 +29,6 @@ dependencies:
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: json
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
33
  - - ~>
38
34
  - !ruby/object:Gem::Version
@@ -43,7 +39,6 @@ dependencies:
43
39
  type: :runtime
44
40
  prerelease: false
45
41
  version_requirements: !ruby/object:Gem::Requirement
46
- none: false
47
42
  requirements:
48
43
  - - ~>
49
44
  - !ruby/object:Gem::Version
@@ -54,7 +49,6 @@ dependencies:
54
49
  - !ruby/object:Gem::Dependency
55
50
  name: thor
56
51
  requirement: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
53
  - - ~>
60
54
  - !ruby/object:Gem::Version
@@ -65,7 +59,6 @@ dependencies:
65
59
  type: :runtime
66
60
  prerelease: false
67
61
  version_requirements: !ruby/object:Gem::Requirement
68
- none: false
69
62
  requirements:
70
63
  - - ~>
71
64
  - !ruby/object:Gem::Version
@@ -76,7 +69,6 @@ dependencies:
76
69
  - !ruby/object:Gem::Dependency
77
70
  name: highline
78
71
  requirement: !ruby/object:Gem::Requirement
79
- none: false
80
72
  requirements:
81
73
  - - ~>
82
74
  - !ruby/object:Gem::Version
@@ -87,7 +79,6 @@ dependencies:
87
79
  type: :runtime
88
80
  prerelease: false
89
81
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
82
  requirements:
92
83
  - - ~>
93
84
  - !ruby/object:Gem::Version
@@ -98,7 +89,6 @@ dependencies:
98
89
  - !ruby/object:Gem::Dependency
99
90
  name: socialcast-net-ldap
100
91
  requirement: !ruby/object:Gem::Requirement
101
- none: false
102
92
  requirements:
103
93
  - - ~>
104
94
  - !ruby/object:Gem::Version
@@ -109,7 +99,6 @@ dependencies:
109
99
  type: :runtime
110
100
  prerelease: false
111
101
  version_requirements: !ruby/object:Gem::Requirement
112
- none: false
113
102
  requirements:
114
103
  - - ~>
115
104
  - !ruby/object:Gem::Version
@@ -120,7 +109,6 @@ dependencies:
120
109
  - !ruby/object:Gem::Dependency
121
110
  name: activeresource
122
111
  requirement: !ruby/object:Gem::Requirement
123
- none: false
124
112
  requirements:
125
113
  - - ~>
126
114
  - !ruby/object:Gem::Version
@@ -128,7 +116,6 @@ dependencies:
128
116
  type: :runtime
129
117
  prerelease: false
130
118
  version_requirements: !ruby/object:Gem::Requirement
131
- none: false
132
119
  requirements:
133
120
  - - ~>
134
121
  - !ruby/object:Gem::Version
@@ -136,7 +123,6 @@ dependencies:
136
123
  - !ruby/object:Gem::Dependency
137
124
  name: activesupport
138
125
  requirement: !ruby/object:Gem::Requirement
139
- none: false
140
126
  requirements:
141
127
  - - ~>
142
128
  - !ruby/object:Gem::Version
@@ -144,7 +130,6 @@ dependencies:
144
130
  type: :runtime
145
131
  prerelease: false
146
132
  version_requirements: !ruby/object:Gem::Requirement
147
- none: false
148
133
  requirements:
149
134
  - - ~>
150
135
  - !ruby/object:Gem::Version
@@ -152,7 +137,6 @@ dependencies:
152
137
  - !ruby/object:Gem::Dependency
153
138
  name: rspec
154
139
  requirement: !ruby/object:Gem::Requirement
155
- none: false
156
140
  requirements:
157
141
  - - ~>
158
142
  - !ruby/object:Gem::Version
@@ -160,7 +144,6 @@ dependencies:
160
144
  type: :development
161
145
  prerelease: false
162
146
  version_requirements: !ruby/object:Gem::Requirement
163
- none: false
164
147
  requirements:
165
148
  - - ~>
166
149
  - !ruby/object:Gem::Version
@@ -168,7 +151,6 @@ dependencies:
168
151
  - !ruby/object:Gem::Dependency
169
152
  name: webmock
170
153
  requirement: !ruby/object:Gem::Requirement
171
- none: false
172
154
  requirements:
173
155
  - - ~>
174
156
  - !ruby/object:Gem::Version
@@ -179,7 +161,6 @@ dependencies:
179
161
  type: :development
180
162
  prerelease: false
181
163
  version_requirements: !ruby/object:Gem::Requirement
182
- none: false
183
164
  requirements:
184
165
  - - ~>
185
166
  - !ruby/object:Gem::Version
@@ -190,7 +171,6 @@ dependencies:
190
171
  - !ruby/object:Gem::Dependency
191
172
  name: rake
192
173
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
174
  requirements:
195
175
  - - '='
196
176
  - !ruby/object:Gem::Version
@@ -198,7 +178,6 @@ dependencies:
198
178
  type: :development
199
179
  prerelease: false
200
180
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
181
  requirements:
203
182
  - - '='
204
183
  - !ruby/object:Gem::Version
@@ -206,7 +185,6 @@ dependencies:
206
185
  - !ruby/object:Gem::Dependency
207
186
  name: pry
208
187
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
188
  requirements:
211
189
  - - ~>
212
190
  - !ruby/object:Gem::Version
@@ -214,7 +192,6 @@ dependencies:
214
192
  type: :development
215
193
  prerelease: false
216
194
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
195
  requirements:
219
196
  - - ~>
220
197
  - !ruby/object:Gem::Version
@@ -275,27 +252,26 @@ files:
275
252
  homepage: http://github.com/socialcast/socialcast-command-line
276
253
  licenses:
277
254
  - MIT
255
+ metadata: {}
278
256
  post_install_message:
279
257
  rdoc_options: []
280
258
  require_paths:
281
259
  - lib
282
260
  required_ruby_version: !ruby/object:Gem::Requirement
283
- none: false
284
261
  requirements:
285
262
  - - ! '>='
286
263
  - !ruby/object:Gem::Version
287
264
  version: '0'
288
265
  required_rubygems_version: !ruby/object:Gem::Requirement
289
- none: false
290
266
  requirements:
291
267
  - - ! '>='
292
268
  - !ruby/object:Gem::Version
293
269
  version: '0'
294
270
  requirements: []
295
271
  rubyforge_project: socialcast
296
- rubygems_version: 1.8.23
272
+ rubygems_version: 2.2.2
297
273
  signing_key:
298
- specification_version: 3
274
+ specification_version: 4
299
275
  summary: command line interface to socialcast api
300
276
  test_files:
301
277
  - spec/fixtures/credentials.yml