socialcast 1.3.16 → 1.3.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/config/ldap.yml +3 -0
- data/lib/socialcast/command_line/provision_user.rb +22 -2
- data/lib/socialcast/command_line/version.rb +1 -1
- data/lib/socialcast.rb +4 -1
- data/socialcast.gemspec +2 -2
- data/spec/socialcast/command_line/authenticate_spec.rb +5 -5
- data/spec/socialcast/command_line/cli_spec.rb +110 -110
- data/spec/socialcast/command_line/ldap_connector_spec.rb +45 -45
- data/spec/socialcast/command_line/provision_photo_spec.rb +35 -35
- data/spec/socialcast/command_line/provision_user_spec.rb +97 -71
- data/spec/socialcast/socialcast_spec.rb +32 -10
- data/spec/spec_helper.rb +1 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dbbca03d19c73c3c76248ca1157e7f6d47d7354
|
4
|
+
data.tar.gz: 5fd8567b4330e9d8a9afe217f1465a20cd31a7c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0020b41df43901a27516b982bc6ef70b11c5c8c085cc63b4e296b022aa5fa70bf4df3ca7e4d9c03917e53f241e2cc81cbbd3e4c36cae42e70834e2dfe2d5547d
|
7
|
+
data.tar.gz: c84885daf855d714b402be2c7100dd69c73169789fd8cb8f06ab0d135092c359f49640db07f8fcd77daa338828628c17640ede31a30cf4da79a365ebfba2878b
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.2
|
data/.travis.yml
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -56,5 +56,5 @@ See [CONTRIBUTORS.txt](https://github.com/socialcast/socialcast-command-line/blo
|
|
56
56
|
|
57
57
|
## Copyright
|
58
58
|
|
59
|
-
Copyright (c) 2011 -
|
59
|
+
Copyright (c) 2011 - 2015 VMware Inc.
|
60
60
|
See [LICENSE.txt](https://github.com/socialcast/socialcast-command-line/blob/master/LICENSE.txt) for details.
|
data/config/ldap.yml
CHANGED
@@ -89,3 +89,6 @@ options:
|
|
89
89
|
# http options for connecting to Socialcast servers
|
90
90
|
http:
|
91
91
|
timeout: 660
|
92
|
+
# Skip validation of the SSL certificate on the socialcast server. Default=false
|
93
|
+
# WARNING: enabling this could allow an unauthorized party to view your data
|
94
|
+
# skip_ssl_validation: false
|
@@ -2,6 +2,7 @@ require 'zlib'
|
|
2
2
|
require 'builder'
|
3
3
|
require 'set'
|
4
4
|
require 'fileutils'
|
5
|
+
require 'active_support/core_ext/string/strip'
|
5
6
|
|
6
7
|
module Socialcast
|
7
8
|
module CommandLine
|
@@ -55,13 +56,32 @@ module Socialcast
|
|
55
56
|
request_params[:add_only] = 'true' if (@ldap_config.fetch('options', {})['add_only'] || @options[:add_only])
|
56
57
|
resource.post request_params, :accept => :json
|
57
58
|
end
|
58
|
-
rescue RestClient::Unauthorized => e
|
59
|
-
raise ProvisionError.new
|
59
|
+
rescue RestClient::Unauthorized, RestClient::Forbidden => e
|
60
|
+
raise ProvisionError.new provision_error_message(e)
|
60
61
|
end
|
61
62
|
log "Finished"
|
62
63
|
end
|
63
64
|
File.delete(output_file) if (@ldap_config.fetch('options', {})['delete_users_file'] || @options[:delete_users_file])
|
64
65
|
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def provision_error_message(error)
|
70
|
+
case error
|
71
|
+
when RestClient::Unauthorized
|
72
|
+
<<-EOS.strip_heredoc
|
73
|
+
Received an "Unauthorized" error from the Socialcast server. Please check the following:
|
74
|
+
* Community has basic authentication enabled
|
75
|
+
* User has administration privileges
|
76
|
+
* User or External System is active
|
77
|
+
* Credentials and community domain are correct in #{Socialcast::CommandLine.credentials_file}
|
78
|
+
EOS
|
79
|
+
when RestClient::Forbidden
|
80
|
+
<<-EOS.strip_heredoc
|
81
|
+
Received a "Forbidden" error from the Socialcast server. Please check that your community has directory integration enabled.
|
82
|
+
EOS
|
83
|
+
end
|
84
|
+
end
|
65
85
|
end
|
66
86
|
end
|
67
87
|
end
|
data/lib/socialcast.rb
CHANGED
@@ -40,8 +40,11 @@ module Socialcast
|
|
40
40
|
def self.resource_for_path(path, options = {}, debug = true)
|
41
41
|
RestClient.log = Logger.new(STDOUT) if debug
|
42
42
|
RestClient.proxy = credentials[:proxy] if credentials[:proxy]
|
43
|
+
|
44
|
+
rest_client_options = options.merge(authentication(options))
|
45
|
+
rest_client_options[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE if rest_client_options.delete('skip_ssl_validation')
|
43
46
|
url = ['https://', credentials[:domain], path].join
|
44
|
-
RestClient::Resource.new url,
|
47
|
+
RestClient::Resource.new url, rest_client_options
|
45
48
|
end
|
46
49
|
|
47
50
|
def self.authentication(options)
|
data/socialcast.gemspec
CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_runtime_dependency 'socialcast-net-ldap', '~> 0.1', '>= 0.1.6'
|
23
23
|
s.add_runtime_dependency 'activeresource', '~> 4.0'
|
24
24
|
s.add_runtime_dependency 'activesupport', '~> 4.0'
|
25
|
-
s.add_development_dependency
|
26
|
-
s.add_development_dependency
|
25
|
+
s.add_development_dependency 'rspec', '~> 3.3'
|
26
|
+
s.add_development_dependency 'webmock', '~> 1.7', '>= 1.7.7'
|
27
27
|
s.add_development_dependency 'rake', '0.9.2.2'
|
28
28
|
s.add_development_dependency 'pry', '~> 0.9'
|
29
29
|
|
@@ -7,9 +7,9 @@ describe Socialcast::CommandLine::Authenticate do
|
|
7
7
|
|
8
8
|
describe '#request' do
|
9
9
|
before do
|
10
|
-
RestClient::Resource.
|
11
|
-
RestClient::Resource.
|
12
|
-
authenticate.
|
10
|
+
expect(RestClient::Resource).to receive(:new).with(url, {}).and_call_original
|
11
|
+
expect_any_instance_of(RestClient::Resource).to receive(:post).with(subject.params, :accept => :json)
|
12
|
+
expect(authenticate).to receive(:set_default_credentials).and_return(true)
|
13
13
|
authenticate.request
|
14
14
|
end
|
15
15
|
context 'for a regular user' do
|
@@ -39,13 +39,13 @@ describe Socialcast::CommandLine::Authenticate do
|
|
39
39
|
let(:stubbed_config_dir) { File.join(File.dirname(__FILE__), '..', '..', 'fixtures') }
|
40
40
|
let(:current_user_stub) { { :user => { :id => 123 } } }
|
41
41
|
let(:current_user_error) { { :error => "Failed to authenticate due to password" } }
|
42
|
-
before { Socialcast::CommandLine.
|
42
|
+
before { allow(Socialcast::CommandLine).to receive(:config_dir).and_return(stubbed_config_dir) }
|
43
43
|
context 'as a successfull authenticated user' do
|
44
44
|
before do
|
45
45
|
stub_request(:get, "https://ryan%40socialcast.com:foo@test.staging.socialcast.com/api/userinfo.json").
|
46
46
|
to_return(:status => 200, :body => current_user_stub.to_json)
|
47
47
|
end
|
48
|
-
it { current_user['id'].
|
48
|
+
it { expect(current_user['id']).to eq(123) }
|
49
49
|
end
|
50
50
|
context 'when you not authenticated properly' do
|
51
51
|
before do
|