confluence-soap 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/confluence-soap.gemspec +1 -1
- data/lib/confluence-soap.rb +30 -10
- data/spec/confluence-soap_spec.rb +116 -93
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05235a53aeb95b8019306a7550602d9177d84407
|
4
|
+
data.tar.gz: 9db7f2a153e4b1ab49a38fedcf580d271efa453c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d6e0c7787d416a1fdbbfafd015936221b37f49a503dc68e2fad905bfa6e3914875bb9b2b1f0a900e2b97b3e4e8db3c9cf32399c8e833da24179e23acb5e5cce
|
7
|
+
data.tar.gz: a679505d6e4380d034075115ee506073df8a1e116c60573dfb2d02d04cc18f873a5367677df90f01800e2330cf145d166dd6867c16d556bffcea6bd69964f5df
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/confluence-soap.gemspec
CHANGED
data/lib/confluence-soap.rb
CHANGED
@@ -34,34 +34,36 @@ class ConfluenceSoap
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def get_pages space
|
37
|
-
response = @client.call :get_pages,
|
37
|
+
response = @client.call :get_pages, auth_message({in1: space})
|
38
38
|
pages = parse_array_response :get_pages, response
|
39
39
|
pages.map { |page| Page.from_hash(page) }
|
40
40
|
end
|
41
41
|
|
42
42
|
def get_page page_id
|
43
|
-
response = @client.call :get_page,
|
43
|
+
response = @client.call :get_page, auth_message({in1: page_id})
|
44
44
|
Page.from_hash parse_response :get_page, response
|
45
45
|
end
|
46
46
|
|
47
47
|
def get_children page_id
|
48
|
-
response = @client.call :get_children,
|
48
|
+
response = @client.call :get_children, auth_message({in1: page_id})
|
49
49
|
pages = parse_array_response :get_children, response
|
50
50
|
pages.map { |page| Page.from_hash(page) }
|
51
51
|
end
|
52
52
|
|
53
53
|
def store_page page
|
54
|
-
response = @client.call :store_page,
|
54
|
+
response = @client.call :store_page, auth_message({in1: page.to_soap})
|
55
55
|
Page.from_hash parse_response :store_page, response
|
56
56
|
end
|
57
57
|
|
58
58
|
def update_page page
|
59
|
-
response =
|
59
|
+
response =
|
60
|
+
@client.call(:update_page,
|
61
|
+
auth_message({in1: page.to_soap, in2: {minorEdit: true} }))
|
60
62
|
Page.from_hash parse_response :update_page, response
|
61
63
|
end
|
62
64
|
|
63
65
|
def remove_page page_id
|
64
|
-
response = @client.call :remove_page,
|
66
|
+
response = @client.call :remove_page, auth_message({in1: page_id})
|
65
67
|
Page.from_hash parse_response :remove_page, response
|
66
68
|
end
|
67
69
|
|
@@ -69,15 +71,29 @@ class ConfluenceSoap
|
|
69
71
|
limit = criteria.delete(:limit) || 20
|
70
72
|
criteria = criteria.map { |k, v| {key: k, value: v} }
|
71
73
|
response =
|
72
|
-
@client.call(:search,
|
73
|
-
|
74
|
+
@client.call(:search,
|
75
|
+
auth_message({in1: term, in2: {item: criteria}, in3: limit}))
|
74
76
|
pages = parse_array_response :search, response
|
75
77
|
pages.map { |page| Page.from_hash(page) }
|
76
78
|
end
|
77
79
|
|
78
|
-
def
|
80
|
+
def add_label_by_name(label, page_id)
|
81
|
+
response =
|
82
|
+
@client.call(:add_label_by_name, auth_message({in1: label, in2: page_id}))
|
83
|
+
|
84
|
+
parse_response(:add_label_by_name, response)
|
85
|
+
end
|
86
|
+
|
87
|
+
def remove_label_by_name(label, page_id)
|
79
88
|
response =
|
80
|
-
@client.call(:
|
89
|
+
@client.call(:remove_label_by_name,
|
90
|
+
auth_message({in1: label, in2: page_id}))
|
91
|
+
|
92
|
+
parse_response(:remove_label_by_name, response)
|
93
|
+
end
|
94
|
+
|
95
|
+
def has_user user
|
96
|
+
response = @client.call(:has_user, auth_message({in1: user}))
|
81
97
|
parse_response(:has_user, response)
|
82
98
|
end
|
83
99
|
|
@@ -98,6 +114,10 @@ class ConfluenceSoap
|
|
98
114
|
parse_response(method, response)["#{method}_return".to_sym] || []
|
99
115
|
end
|
100
116
|
|
117
|
+
def auth_message(params = {})
|
118
|
+
{message: {in0: @token}.merge(params)}
|
119
|
+
end
|
120
|
+
|
101
121
|
def parse_response method, response
|
102
122
|
response.body["#{method}_response".to_sym]["#{method}_return".to_sym]
|
103
123
|
end
|
@@ -36,126 +36,149 @@ describe ConfluenceSoap do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe '
|
40
|
-
|
41
|
-
before (:each) do
|
39
|
+
describe 'with an authenticated user' do
|
40
|
+
before(:each) do
|
42
41
|
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
43
|
-
subject.client.should_receive(:call)
|
44
|
-
.with(:get_pages, message: {in0: 'token', in1: space})
|
45
|
-
.and_return(double(:response, body: {get_pages_response: {get_pages_return: {get_pages_return: []}}}))
|
46
42
|
end
|
47
43
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
44
|
+
describe '#get_pages' do
|
45
|
+
let(:space) { 'SpaceName' }
|
46
|
+
before (:each) do
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
subject.client.should_receive(:call)
|
58
|
-
.with(:get_page, message: {in0: 'token', in1: page_id})
|
59
|
-
.and_return(double(:response, body: {get_page_response: {get_page_return: {}}}))
|
60
|
-
end
|
48
|
+
subject.client.should_receive(:call)
|
49
|
+
.with(:get_pages, message: {in0: 'token', in1: space})
|
50
|
+
.and_return(double(:response, body: {get_pages_response: {get_pages_return: {get_pages_return: []}}}))
|
51
|
+
end
|
61
52
|
|
62
|
-
|
63
|
-
|
53
|
+
it 'should return the pages in the space' do
|
54
|
+
subject.get_pages(space).should == []
|
55
|
+
end
|
64
56
|
end
|
65
|
-
end
|
66
57
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
58
|
+
describe '#get_page' do
|
59
|
+
let(:page_id) { '123456' }
|
60
|
+
before (:each) do
|
61
|
+
subject.client.should_receive(:call)
|
62
|
+
.with(:get_page, message: {in0: 'token', in1: page_id})
|
63
|
+
.and_return(double(:response, body: {get_page_response: {get_page_return: {}}}))
|
64
|
+
end
|
75
65
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
describe '#get_children' do
|
81
|
-
before (:each) do
|
82
|
-
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
83
|
-
subject.client.should_receive(:call)
|
84
|
-
.with(:get_children, message: {in0: 'token', in1: 'page_id'})
|
85
|
-
.and_return(double(:response, body: {get_children_response: {get_children_return: {get_children_return: []}}}))
|
66
|
+
it 'should return the page' do
|
67
|
+
subject.get_page page_id
|
68
|
+
end
|
86
69
|
end
|
87
70
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
71
|
+
describe '#get_page' do
|
72
|
+
let(:page_id) { '123456' }
|
73
|
+
before (:each) do
|
74
|
+
subject.client.should_receive(:call)
|
75
|
+
.with(:remove_page, message: {in0: 'token', in1: page_id})
|
76
|
+
.and_return(double(:response, body: {remove_page_response: {remove_page_return: {}}}))
|
77
|
+
end
|
92
78
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
parent_id: 'parent_id', permissions: 0})
|
79
|
+
it 'should return the page' do
|
80
|
+
subject.remove_page page_id
|
81
|
+
end
|
97
82
|
end
|
83
|
+
describe '#get_children' do
|
84
|
+
before (:each) do
|
85
|
+
subject.client.should_receive(:call)
|
86
|
+
.with(:get_children, message: {in0: 'token', in1: 'page_id'})
|
87
|
+
.and_return(double(:response, body: {get_children_response: {get_children_return: {get_children_return: []}}}))
|
88
|
+
end
|
98
89
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
.with(:store_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
|
103
|
-
space: 'Space Name', parent_id: 'parent_id', permissions: 0}})
|
104
|
-
.and_return(double(:response, body: {store_page_response: {store_page_return: {}}}))
|
90
|
+
it 'should return array of child pages' do
|
91
|
+
subject.get_children('page_id').should == []
|
92
|
+
end
|
105
93
|
end
|
106
94
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
95
|
+
describe '#store_page' do
|
96
|
+
let(:page) do
|
97
|
+
ConfluenceSoap::Page.from_hash({content: 'test', title: 'Testing API ', space: 'Space Name',
|
98
|
+
parent_id: 'parent_id', permissions: 0})
|
99
|
+
end
|
111
100
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
101
|
+
before (:each) do
|
102
|
+
subject.client.should_receive(:call)
|
103
|
+
.with(:store_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
|
104
|
+
space: 'Space Name', parent_id: 'parent_id', permissions: 0}})
|
105
|
+
.and_return(double(:response, body: {store_page_response: {store_page_return: {}}}))
|
106
|
+
end
|
117
107
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
.with(:update_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
|
122
|
-
space: 'Space Name', parent_id: 'parent_id', permissions: 0},
|
123
|
-
in2: {minorEdit: true}})
|
124
|
-
.and_return(double(:response, body: {update_page_response: {update_page_return: {}}}))
|
108
|
+
it 'should store page with savon' do
|
109
|
+
subject.store_page(page)
|
110
|
+
end
|
125
111
|
end
|
126
112
|
|
127
|
-
|
128
|
-
|
113
|
+
describe '#update_page' do
|
114
|
+
let(:page) do
|
115
|
+
ConfluenceSoap::Page.from_hash({content: 'test', title: 'Testing API ', space: 'Space Name',
|
116
|
+
parent_id: 'parent_id', permissions: 0})
|
117
|
+
end
|
118
|
+
|
119
|
+
before (:each) do
|
120
|
+
subject.client.should_receive(:call)
|
121
|
+
.with(:update_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
|
122
|
+
space: 'Space Name', parent_id: 'parent_id', permissions: 0},
|
123
|
+
in2: {minorEdit: true}})
|
124
|
+
.and_return(double(:response, body: {update_page_response: {update_page_return: {}}}))
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should store page with savon' do
|
128
|
+
subject.update_page(page)
|
129
|
+
end
|
129
130
|
end
|
130
|
-
end
|
131
131
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
132
|
+
describe '#search' do
|
133
|
+
let(:term) { 'search term' }
|
134
|
+
let(:criteria) { {item: [{key: :space_key, value: 'SpaceName'}]} }
|
135
|
+
before (:each) do
|
136
|
+
subject.client.should_receive(:call)
|
137
|
+
.with(:search,
|
138
|
+
message: {in0: 'token', in1: term, in2: criteria, in3: 20})
|
139
|
+
.and_return(double(:response, body: {search_response: {search_return: {search_return: []}}}))
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should search with savon' do
|
143
|
+
subject.search(term, space_key: 'SpaceName').should == []
|
144
|
+
end
|
141
145
|
end
|
142
146
|
|
143
|
-
|
144
|
-
|
147
|
+
describe '#add_label_by_name' do
|
148
|
+
before(:each) do
|
149
|
+
subject.client.should_receive(:call)
|
150
|
+
.with(:add_label_by_name, message: {in0: 'token', in1: 'faq', in2: 1})
|
151
|
+
.and_return(double(:response, body: {add_label_by_name_response: {add_label_by_name_return: true}}))
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should add a label to the page' do
|
155
|
+
subject.add_label_by_name('faq', 1).should == true
|
156
|
+
end
|
145
157
|
end
|
146
|
-
end
|
147
158
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
159
|
+
describe '#remove_label_by_name' do
|
160
|
+
before(:each) do
|
161
|
+
subject.client.should_receive(:call)
|
162
|
+
.with(:remove_label_by_name, message: {in0: 'token', in1: 'faq', in2: 1})
|
163
|
+
.and_return(double(:response, body: {remove_label_by_name_response: {remove_label_by_name_return: true}}))
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'should remove a label from the page' do
|
167
|
+
subject.remove_label_by_name('faq', 1).should == true
|
168
|
+
end
|
152
169
|
end
|
153
170
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
171
|
+
describe '#execute' do
|
172
|
+
before (:each) do
|
173
|
+
subject.should_receive(:login)
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'should reconnect when session is invalid' do
|
177
|
+
Savon::SOAPFault.any_instance.stub(:to_hash).and_return({fault: {faultstring: 'InvalidSessionException'}})
|
178
|
+
ex = Savon::SOAPFault.new nil, nil
|
179
|
+
subject.execute do |x|
|
180
|
+
raise ex if x.is_a? ConfluenceSoap
|
181
|
+
end
|
159
182
|
end
|
160
183
|
end
|
161
184
|
end
|