crowd-client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/crowd-client.rb +2 -1
- data/lib/crowd-client/logger.rb +30 -0
- data/lib/crowd-client/user.rb +3 -3
- data/lib/crowd-client/version.rb +1 -1
- metadata +21 -20
data/lib/crowd-client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "crowd-client/version"
|
2
|
+
require "crowd-client/logger"
|
2
3
|
require "crowd-client/exceptions"
|
3
4
|
require "ostruct"
|
4
5
|
require "faraday"
|
@@ -68,7 +69,7 @@ module Crowd
|
|
68
69
|
:user_agent => "Crowd Client for Ruby/#{VERSION}"
|
69
70
|
) do |builder|
|
70
71
|
builder.request :json
|
71
|
-
builder.use
|
72
|
+
builder.use Crowd::Client::Logger, config.logger if config.logger
|
72
73
|
builder.use Faraday::Response::ParseJson
|
73
74
|
builder.adapter :patron
|
74
75
|
end.tap {|connection| connection.basic_auth config.application, config.password }
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
class Crowd::Client::Logger < Faraday::Response::Middleware
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def initialize(app, logger = nil)
|
6
|
+
super(app)
|
7
|
+
@logger = logger || begin
|
8
|
+
require 'logger'
|
9
|
+
::Logger.new(STDOUT)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def_delegators :@logger, :debug, :info, :warn, :error, :fatal
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
info "#{env[:method]} #{env[:url].to_s}"
|
17
|
+
debug "------ Request ------\n#{dump_headers env[:request_headers]}\nBody: #{env[:body]}"
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def on_complete(env)
|
22
|
+
info "Status: #{env[:status].to_s}"
|
23
|
+
debug "------ Response ------\n#{dump_headers env[:response_headers]}\nBody: #{env[:response].body}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def dump_headers(headers)
|
28
|
+
headers.map { |k, v| "#{k}: #{v.inspect}" }.join("\n")
|
29
|
+
end
|
30
|
+
end
|
data/lib/crowd-client/user.rb
CHANGED
@@ -62,7 +62,7 @@ class Crowd::Client::User
|
|
62
62
|
if new_record
|
63
63
|
response = connection.post('user', {'name' => username, 'active' => true}.merge(@attributes))
|
64
64
|
self.new_record = false
|
65
|
-
raise ::Crowd::Client::Exception::UnknownError.new(response.body
|
65
|
+
raise ::Crowd::Client::Exception::UnknownError.new(response.body) if response.status != 201
|
66
66
|
else
|
67
67
|
response = connection.put('user', {'name' => username}.merge(@attributes)) do |request|
|
68
68
|
request.params[:username] = username
|
@@ -77,7 +77,7 @@ class Crowd::Client::User
|
|
77
77
|
request.params[:username] = username
|
78
78
|
end
|
79
79
|
raise ::Crowd::Client::Exception::NotFound.new("User '#{user.username}' was not found") if response.status == 404
|
80
|
-
raise ::Crowd::Client::Exception::UnknownError.new(response.body
|
80
|
+
raise ::Crowd::Client::Exception::UnknownError.new(response.body) if response.status != 204
|
81
81
|
end
|
82
82
|
|
83
83
|
def authenticate?(password)
|
@@ -92,7 +92,7 @@ class Crowd::Client::User
|
|
92
92
|
request.params[:username] = username
|
93
93
|
end
|
94
94
|
raise ::Crowd::Client::Exception::NotFound.new("User '#{user.username}' was not found") if response.status == 404
|
95
|
-
raise ::Crowd::Client::Exception::UnknownError.new(response.body
|
95
|
+
raise ::Crowd::Client::Exception::UnknownError.new(response.body) if response.status != 204
|
96
96
|
end
|
97
97
|
|
98
98
|
private
|
data/lib/crowd-client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowd-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70105850018200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70105850018200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vcr
|
27
|
-
requirement: &
|
27
|
+
requirement: &70105850017700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.0.0.rc1
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70105850017700
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: webmock
|
38
|
-
requirement: &
|
38
|
+
requirement: &70105850017180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.7.8
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70105850017180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ruby-debug19
|
49
|
-
requirement: &
|
49
|
+
requirement: &70105850016760 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70105850016760
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: faraday
|
60
|
-
requirement: &
|
60
|
+
requirement: &70105850016200 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.7.5
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70105850016200
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: faraday_middleware
|
71
|
-
requirement: &
|
71
|
+
requirement: &70105850015700 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.7.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70105850015700
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: patron
|
82
|
-
requirement: &
|
82
|
+
requirement: &70105850015220 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.4.16
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70105850015220
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: json
|
93
|
-
requirement: &
|
93
|
+
requirement: &70105850014480 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.6.1
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70105850014480
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: activesupport
|
104
|
-
requirement: &
|
104
|
+
requirement: &70105850014020 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: 3.1.0
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70105850014020
|
113
113
|
description: A simple rest client for Crowd
|
114
114
|
email:
|
115
115
|
- paul@webpowerdesign.net
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/crowd-client.rb
|
126
126
|
- lib/crowd-client/exceptions.rb
|
127
127
|
- lib/crowd-client/group.rb
|
128
|
+
- lib/crowd-client/logger.rb
|
128
129
|
- lib/crowd-client/user.rb
|
129
130
|
- lib/crowd-client/version.rb
|
130
131
|
- spec/cassettes/Crowd_Client/_in_group_/should_confirm_users_are_in_groups.yml
|