openfire_admin 0.0.1 → 0.0.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 +2 -0
- data/README.md +1 -3
- data/lib/openfire_admin/admin_client.rb +24 -0
- data/lib/openfire_admin/client.rb +63 -0
- data/lib/openfire_admin/http_client.rb +2 -1
- data/lib/openfire_admin/plugin.rb +132 -0
- data/lib/openfire_admin/property_map.rb +76 -0
- data/lib/openfire_admin/response_exception.rb +2 -0
- data/lib/openfire_admin/system_cache.rb +39 -0
- data/lib/openfire_admin/user_admin.rb +32 -0
- data/lib/openfire_admin/version.rb +1 -1
- data/lib/openfire_admin.rb +4 -308
- data/openfire_admin.gemspec +3 -0
- data/spec/fixtures/plugin-admin.jsp +584 -0
- data/spec/fixtures/server-properties.jsp +483 -0
- data/spec/fixtures/server-properties_password.jsp +640 -0
- data/spec/fixtures/system-cache.jsp +1315 -0
- data/spec/fixtures/system-cache_success.jsp +1327 -0
- data/spec/fixtures/versions.xml +32 -0
- data/spec/openfire_admin_spec.rb +198 -0
- data/spec/spec_helper.rb +91 -0
- metadata +46 -6
@@ -0,0 +1,32 @@
|
|
1
|
+
<available>
|
2
|
+
<plugin name="Client Control"
|
3
|
+
description="Controls clients allowed to connect and available features"
|
4
|
+
url="http://www.igniterealtime.org/projects/openfire/plugins/clientControl.jar"
|
5
|
+
icon="http://www.igniterealtime.org/projects/openfire/plugins/cache/clientcontrol.gif"
|
6
|
+
readme="http://www.igniterealtime.org/projects/openfire/plugins/clientcontrol/readme.html"
|
7
|
+
changelog="http://www.igniterealtime.org/projects/openfire/plugins/clientcontrol/changelog.html"
|
8
|
+
latest="1.1.0"
|
9
|
+
author="Jive Software"
|
10
|
+
minServerVersion="3.7.0"
|
11
|
+
fileSize="102487"/>
|
12
|
+
|
13
|
+
|
14
|
+
<plugin name="SIP Phone Plugin"
|
15
|
+
description="Provides support for SIP account management"
|
16
|
+
url="http://www.igniterealtime.org/projects/openfire/plugins/sip.jar"
|
17
|
+
icon="http://www.igniterealtime.org/projects/openfire/plugins/cache/sip.gif"
|
18
|
+
readme="http://www.igniterealtime.org/projects/openfire/plugins/sip/readme.html"
|
19
|
+
changelog="http://www.igniterealtime.org/projects/openfire/plugins/sip/changelog.html"
|
20
|
+
latest="1.0.6"
|
21
|
+
author="Ignite Realtime"
|
22
|
+
minServerVersion="3.7.0"
|
23
|
+
fileSize="192647"/>
|
24
|
+
<plugin name="Registration"
|
25
|
+
description="Performs various actions whenever a new user account is created."
|
26
|
+
url="http://www.igniterealtime.org/projects/openfire/plugins/registration.jar"
|
27
|
+
icon="http://www.igniterealtime.org/projects/openfire/plugins/cache/registration.gif"
|
28
|
+
readme="http://www.igniterealtime.org/projects/openfire/plugins/registration/readme.html"
|
29
|
+
changelog="http://www.igniterealtime.org/projects/openfire/plugins/registration/changelog.html"
|
30
|
+
latest="1.5.0" author="Ryan Graham" minServerVersion="3.7.0"
|
31
|
+
fileSize="26897"/>
|
32
|
+
</available>
|
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'openfire_admin'
|
3
|
+
|
4
|
+
describe OpenfireAdmin::Client do
|
5
|
+
it "can new instance" do
|
6
|
+
OpenfireAdmin.new.should be_a_kind_of(OpenfireAdmin::Client)
|
7
|
+
end
|
8
|
+
describe "can operate plugins" do
|
9
|
+
it "can read availables and do install" do
|
10
|
+
rplugin = nil
|
11
|
+
expect_get(OpenfireAdmin::PluginList::PLUGIN_LIST_URL, "/versions.xml" ){
|
12
|
+
av = OpenfireAdmin.new.available_plugins
|
13
|
+
av.should be_a_kind_of(OpenfireAdmin::PluginList)
|
14
|
+
av.size.should be(3)
|
15
|
+
rplugin = av["registration"]
|
16
|
+
rplugin.should be_a_kind_of(OpenfireAdmin::AvailablePlugin)
|
17
|
+
}
|
18
|
+
|
19
|
+
expect_post("/dwr/exec/downloader.installPlugin.dwr",{ },
|
20
|
+
:body => "s0.successfull=true" ){
|
21
|
+
rplugin.install
|
22
|
+
}
|
23
|
+
end
|
24
|
+
it "can read installed plugins and do uninstall" do
|
25
|
+
splugin = nil
|
26
|
+
expect_get( "/plugin-admin.jsp", "/plugin-admin.jsp"){
|
27
|
+
av = OpenfireAdmin.new.installed_plugins
|
28
|
+
av.should be_a_kind_of(OpenfireAdmin::PluginList)
|
29
|
+
av.size.should be(4)
|
30
|
+
splugin = av["search"]
|
31
|
+
splugin.should be_a_kind_of(OpenfireAdmin::InstalledPlugin)
|
32
|
+
}
|
33
|
+
|
34
|
+
expect_get( "/plugin-admin.jsp?deleteplugin=search",
|
35
|
+
redirect_to("/plugin-admin.jsp?deletesuccess=true")){
|
36
|
+
splugin.uninstall
|
37
|
+
}
|
38
|
+
|
39
|
+
expect_get( "/plugin-admin.jsp?reloadplugin=search",
|
40
|
+
redirect_to("/plugin-admin.jsp?reloadsuccess=true")){
|
41
|
+
splugin.reload
|
42
|
+
}
|
43
|
+
|
44
|
+
expect_get( "/plugin-admin.jsp?deleteplugin=search",
|
45
|
+
redirect_to("/plugin-admin.jsp?deletesuccess=true")){
|
46
|
+
splugin.uninstall
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
it "can login" do
|
51
|
+
client = OpenfireAdmin.new
|
52
|
+
client.logined?.should be_false
|
53
|
+
expect_post( "/login.jsp",{
|
54
|
+
"login"=>"true",
|
55
|
+
"password"=>"bbb",
|
56
|
+
"username"=>"aaa"},
|
57
|
+
redirect_to("/hoge")){
|
58
|
+
client.login("aaa","bbb")
|
59
|
+
}
|
60
|
+
client.logined?.should be_true
|
61
|
+
end
|
62
|
+
it "can operate setup mode" do
|
63
|
+
client = OpenfireAdmin.new
|
64
|
+
expect_get( "/login.jsp", :body=>"hoge"){
|
65
|
+
client.setup_mode?.should be_false
|
66
|
+
}
|
67
|
+
expect_get( "/login.jsp", redirect_to("/setup/xxx.jsp")){
|
68
|
+
client.setup_mode?.should be_true
|
69
|
+
}
|
70
|
+
|
71
|
+
w = client.setup_wizard
|
72
|
+
w.should be_a_kind_of(OpenfireAdmin::SetupWizard)
|
73
|
+
|
74
|
+
expect_get( "/setup/index.jsp?localeCode=en&save=Continue",
|
75
|
+
redirect_to("/setup/xxx.jsp")) do
|
76
|
+
w.language("en").should be_a_kind_of(OpenfireAdmin::SetupWizard)
|
77
|
+
end
|
78
|
+
|
79
|
+
expect_post( "/setup/setup-host-settings.jsp",{
|
80
|
+
"continue"=>"Continue",
|
81
|
+
"domain"=>"hoge.domain",
|
82
|
+
"embeddedPort"=>"9090",
|
83
|
+
"securePort"=>"9091"
|
84
|
+
}, redirect_to("/setup/xxx.jsp")) do
|
85
|
+
w.server("hoge.domain").should be_a_kind_of(OpenfireAdmin::SetupWizard)
|
86
|
+
end
|
87
|
+
|
88
|
+
expect_get( "/setup/setup-datasource-settings.jsp?next=true&mode=embedded&continue=Continue", redirect_to("/setup/xxx.jsp")) do
|
89
|
+
w.database().should be_a_kind_of(OpenfireAdmin::SetupWizard)
|
90
|
+
end
|
91
|
+
expect_requests([
|
92
|
+
[:get, "/setup/setup-datasource-settings.jsp?next=true&mode=standard&continue=Continue", redirect_to("/setup/xxx.jsp")],
|
93
|
+
[:post,"/setup/setup-datasource-standard.jsp", redirect_to("/setup/xxx.jsp")]
|
94
|
+
]){
|
95
|
+
w.database_standard("hoge.driver","jdbc:mysql://huge/?url","user","pass").should be_a_kind_of(OpenfireAdmin::SetupWizard)
|
96
|
+
}
|
97
|
+
last_post_is "connectionTimeout" => "1.0",
|
98
|
+
"continue"=>"Continue",
|
99
|
+
"driver"=>"hoge.driver",
|
100
|
+
"maxConnections"=>"25",
|
101
|
+
"minConnections"=>"5",
|
102
|
+
"password"=>"pass",
|
103
|
+
"serverURL"=>"jdbc:mysql://huge/?url",
|
104
|
+
"username"=>"user"
|
105
|
+
expect_post("/setup/setup-profile-settings.jsp",{
|
106
|
+
"mode"=>"default", "continue"=>"Continue"
|
107
|
+
},redirect_to("/setup/xxxx.jsp")){
|
108
|
+
w.profile().should be_a_kind_of(OpenfireAdmin::SetupWizard)
|
109
|
+
}
|
110
|
+
expect_requests([
|
111
|
+
[:get, "/setup/setup-admin-settings.jsp", {:body=>"ok"}],
|
112
|
+
[:post,"/setup/setup-admin-settings.jsp", redirect_to("/setup/xxx.jsp")]
|
113
|
+
]){
|
114
|
+
w.admin("em","pass").should be_a_kind_of(OpenfireAdmin::SetupWizard)
|
115
|
+
}
|
116
|
+
last_post_is "email"=>"em",
|
117
|
+
"newPassword"=>"pass",
|
118
|
+
"newPasswordConfirm"=>"pass",
|
119
|
+
"password"=>"pass"
|
120
|
+
expect_get("/setup/setup-finished.jsp",:body => "ok"){
|
121
|
+
w.finish()
|
122
|
+
}
|
123
|
+
end
|
124
|
+
it "can operate system properties" do
|
125
|
+
client = OpenfireAdmin.new
|
126
|
+
s = nil
|
127
|
+
expect_get("/server-properties.jsp","/server-properties.jsp"){
|
128
|
+
s = client.system_properties
|
129
|
+
s.should be_a_kind_of(OpenfireAdmin::PropertyMap)
|
130
|
+
s["clustering.enabled"].should == "true"
|
131
|
+
s["xmpp.socket.ssl.active"].should == "true"
|
132
|
+
s["not.exists.key"].should be_nil
|
133
|
+
}
|
134
|
+
expect_post("/server-properties.jsp",{
|
135
|
+
"edit"=>"true",
|
136
|
+
"propName"=>"jdbcAuthProvider.passwordSQL",
|
137
|
+
},"/server-properties_password.jsp"){
|
138
|
+
s["jdbcAuthProvider.passwordSQL"].should == "SELECT psw as password FROM users WHERE jid = ?"
|
139
|
+
}
|
140
|
+
|
141
|
+
expect_post("/server-properties.jsp",{
|
142
|
+
"save"=>"Save Property",
|
143
|
+
"propName"=>"jdbcAuthProvider.passwordSQL",
|
144
|
+
"propValue"=>"hoge"
|
145
|
+
},redirect_to("/server-properties.jsp")){
|
146
|
+
s["jdbcAuthProvider.passwordSQL"]="hoge"
|
147
|
+
}
|
148
|
+
|
149
|
+
expect_post("/server-properties.jsp",{
|
150
|
+
"del"=>"true",
|
151
|
+
"propName"=>"jdbcAuthProvider.passwordSQL"
|
152
|
+
},redirect_to("/server-properties.jsp?deletesuccess=true")){
|
153
|
+
s.remove "jdbcAuthProvider.passwordSQL"
|
154
|
+
}
|
155
|
+
|
156
|
+
end
|
157
|
+
it "can operate system cache" do
|
158
|
+
client = OpenfireAdmin.new
|
159
|
+
pi = nil
|
160
|
+
expect_get("/system-cache.jsp","/system-cache.jsp"){
|
161
|
+
s = client.system_cache
|
162
|
+
pi = s.find{|a| a.name=="Published Items" }
|
163
|
+
pi.should be_a_kind_of(OpenfireAdmin::SystemCache)
|
164
|
+
}
|
165
|
+
expect_post("/system-cache.jsp",{
|
166
|
+
"cacheID"=>pi.cacheID.to_str,
|
167
|
+
"clear"=>"Clear"
|
168
|
+
},"/system-cache_success.jsp"){
|
169
|
+
pi.clear
|
170
|
+
}
|
171
|
+
end
|
172
|
+
it "can operate users" do
|
173
|
+
c = OpenfireAdmin.new
|
174
|
+
c = c.users
|
175
|
+
c.should be_a_kind_of(OpenfireAdmin::UserAdmin)
|
176
|
+
|
177
|
+
expect_post("/user-create.jsp",{
|
178
|
+
"create"=>"Create User",
|
179
|
+
"email"=> "em@example.com",
|
180
|
+
"name"=> "hoge huge",
|
181
|
+
"password"=> "pass",
|
182
|
+
"passwordConfirm"=>"pass",
|
183
|
+
"username"=>"hoge"
|
184
|
+
},redirect_to("/uesr-create.jsp?createsuccess=true")){
|
185
|
+
c.create("hoge","pass","hoge huge","em@example.com")
|
186
|
+
}
|
187
|
+
expect_get("/user-delete.jsp?username=hoge&delete=Delete+User",
|
188
|
+
redirect_to("/user-delete.jsp?deletesuccess=true")){
|
189
|
+
c.delete("hoge")
|
190
|
+
}
|
191
|
+
expect_get("/user-password.jsp?username=hoge", "ok"){
|
192
|
+
c.exists?("hoge").should be_true
|
193
|
+
}
|
194
|
+
expect_get("/user-password.jsp?username=hoge", :status=>["404"]){
|
195
|
+
c.exists?("hoge").should be_false
|
196
|
+
}
|
197
|
+
end
|
198
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'openfire_admin'
|
5
|
+
require 'fakeweb'
|
6
|
+
|
7
|
+
module FakeWebHelper
|
8
|
+
def path_of(url)
|
9
|
+
"http://localhost:9090#{url}"
|
10
|
+
end
|
11
|
+
def fixture(path)
|
12
|
+
File.join(File.dirname(__FILE__),"fixtures",path)
|
13
|
+
end
|
14
|
+
def read_fixture(path)
|
15
|
+
open(fixture(path)).read
|
16
|
+
end
|
17
|
+
def redirect_to(path)
|
18
|
+
{
|
19
|
+
:status=>["302"],
|
20
|
+
:location=>path
|
21
|
+
}
|
22
|
+
end
|
23
|
+
def register_uri(method,url,option)
|
24
|
+
url = path_of(url) if url =~ %r[^/]
|
25
|
+
if option.is_a?(String)
|
26
|
+
if option =~ %r[^/]
|
27
|
+
option = { :body => read_fixture(option) }
|
28
|
+
else
|
29
|
+
option = { :body => option }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
FakeWeb.register_uri(method,url,option)
|
33
|
+
end
|
34
|
+
def get_last_form
|
35
|
+
Hash[URI.decode_www_form(FakeWeb.last_request.body)]
|
36
|
+
end
|
37
|
+
def last_post_is form_values
|
38
|
+
FakeWeb.last_request.should be_a_kind_of(Net::HTTP::Post)
|
39
|
+
begin
|
40
|
+
ex = get_last_form
|
41
|
+
ex.should include(form_values)
|
42
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
43
|
+
ret = [e.message]
|
44
|
+
form_values.keys.each{|k|
|
45
|
+
unless form_values[k]==ex[k]
|
46
|
+
if ex[k].nil?
|
47
|
+
ret << "#{k}: '#{form_values[k]}' != nil"
|
48
|
+
else
|
49
|
+
ret << "#{k}: '#{form_values[k]}' != '#{ex[k]}'"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
}
|
53
|
+
raise RSpec::Expectations::ExpectationNotMetError.new( "#{ret.join("\n")}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
def access
|
57
|
+
FakeWeb.clean_registry
|
58
|
+
FakeWeb.last_request = nil
|
59
|
+
FakeWeb.allow_net_connect = false
|
60
|
+
ret = yield
|
61
|
+
FakeWeb.clean_registry
|
62
|
+
ret
|
63
|
+
end
|
64
|
+
def expect_get(path,option)
|
65
|
+
access{
|
66
|
+
register_uri(:get,path,option)
|
67
|
+
ret = yield
|
68
|
+
FakeWeb.last_request.should be_a_kind_of(Net::HTTP::Get)
|
69
|
+
ret
|
70
|
+
}
|
71
|
+
end
|
72
|
+
def expect_post(path,form_values,option)
|
73
|
+
access{
|
74
|
+
register_uri(:post,path,option)
|
75
|
+
ret = yield
|
76
|
+
last_post_is form_values
|
77
|
+
ret
|
78
|
+
}
|
79
|
+
end
|
80
|
+
def expect_requests(expects)
|
81
|
+
access{
|
82
|
+
expects.each{|ex| register_uri(*ex) }
|
83
|
+
yield
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
RSpec.configure do |config|
|
89
|
+
config.include FakeWebHelper
|
90
|
+
# some (optional) config here
|
91
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openfire_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nazoking
|
@@ -9,10 +9,29 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-08 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: fakeweb
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
16
35
|
description: Manipurate Openfire admin console
|
17
36
|
email:
|
18
37
|
- nazoking@gmai.com
|
@@ -29,11 +48,25 @@ files:
|
|
29
48
|
- README.md
|
30
49
|
- Rakefile
|
31
50
|
- lib/openfire_admin.rb
|
51
|
+
- lib/openfire_admin/admin_client.rb
|
52
|
+
- lib/openfire_admin/client.rb
|
32
53
|
- lib/openfire_admin/http_client.rb
|
54
|
+
- lib/openfire_admin/plugin.rb
|
55
|
+
- lib/openfire_admin/property_map.rb
|
33
56
|
- lib/openfire_admin/response_exception.rb
|
34
57
|
- lib/openfire_admin/setup_wizard.rb
|
58
|
+
- lib/openfire_admin/system_cache.rb
|
59
|
+
- lib/openfire_admin/user_admin.rb
|
35
60
|
- lib/openfire_admin/version.rb
|
36
61
|
- openfire_admin.gemspec
|
62
|
+
- spec/fixtures/plugin-admin.jsp
|
63
|
+
- spec/fixtures/server-properties.jsp
|
64
|
+
- spec/fixtures/server-properties_password.jsp
|
65
|
+
- spec/fixtures/system-cache.jsp
|
66
|
+
- spec/fixtures/system-cache_success.jsp
|
67
|
+
- spec/fixtures/versions.xml
|
68
|
+
- spec/openfire_admin_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
37
70
|
has_rdoc: false
|
38
71
|
homepage: ""
|
39
72
|
post_install_message:
|
@@ -60,5 +93,12 @@ rubygems_version: 1.3.1
|
|
60
93
|
signing_key:
|
61
94
|
specification_version: 2
|
62
95
|
summary: ""
|
63
|
-
test_files:
|
64
|
-
|
96
|
+
test_files:
|
97
|
+
- spec/fixtures/plugin-admin.jsp
|
98
|
+
- spec/fixtures/server-properties.jsp
|
99
|
+
- spec/fixtures/server-properties_password.jsp
|
100
|
+
- spec/fixtures/system-cache.jsp
|
101
|
+
- spec/fixtures/system-cache_success.jsp
|
102
|
+
- spec/fixtures/versions.xml
|
103
|
+
- spec/openfire_admin_spec.rb
|
104
|
+
- spec/spec_helper.rb
|