openfire 0.0.1
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 +7 -0
- data/.gitignore +43 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/openfire_api.iml +185 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +22 -0
- data/README.md +77 -0
- data/Rakefile +17 -0
- data/VERSION +1 -0
- data/lib/openfire.rb +14 -0
- data/lib/openfire/client.rb +28 -0
- data/lib/openfire/service/base.rb +56 -0
- data/lib/openfire/service/group.rb +44 -0
- data/lib/openfire/service/room.rb +46 -0
- data/lib/openfire/service/user.rb +44 -0
- data/lib/openfire/version.rb +3 -0
- data/openfire.gemspec +32 -0
- data/spec/room_service_spec.rb +67 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/user_service_spec.rb +88 -0
- metadata +156 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: e575931ddb539d8f73f44cee2efc0f7eb656935f
|
|
4
|
+
data.tar.gz: df8bf9de81ab90449faf5b4b810a5b9bd153679d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ef8469f4d24e2d56c70cec34f715580b164901090ff966429c4bfffcab3a702dca94312ebcd20853136f43515885012daf5cfcf997f180bf829c3bedd3eaaa29
|
|
7
|
+
data.tar.gz: d004602e1309108aad83c618ee4d5c0d82a94ae38a64424030d80fd0ba05a125d8562ccfbc70203ea952c11010acfa46b5ee77d1a2097f2ae2daaba81824bbe0
|
data/.gitignore
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# rcov generated
|
|
2
|
+
coverage
|
|
3
|
+
|
|
4
|
+
# rdoc generated
|
|
5
|
+
rdoc
|
|
6
|
+
|
|
7
|
+
# yard generated
|
|
8
|
+
doc
|
|
9
|
+
.yardoc
|
|
10
|
+
.rspec
|
|
11
|
+
|
|
12
|
+
# bundler
|
|
13
|
+
.bundle
|
|
14
|
+
|
|
15
|
+
# jeweler generated
|
|
16
|
+
pkg
|
|
17
|
+
|
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
|
19
|
+
#
|
|
20
|
+
# * Create a file at ~/.gitignore
|
|
21
|
+
# * Include files you want ignored
|
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
|
23
|
+
#
|
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
|
26
|
+
#
|
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
|
28
|
+
#
|
|
29
|
+
# For MacOS:
|
|
30
|
+
#
|
|
31
|
+
#.DS_Store
|
|
32
|
+
#
|
|
33
|
+
# For TextMate
|
|
34
|
+
#*.tmproj
|
|
35
|
+
#tmtags
|
|
36
|
+
#
|
|
37
|
+
# For emacs:
|
|
38
|
+
#*~
|
|
39
|
+
#\#*
|
|
40
|
+
#.\#*
|
|
41
|
+
#
|
|
42
|
+
# For vim:
|
|
43
|
+
#*.swp
|
data/.idea/encodings.xml
ADDED
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/openfire_api.iml" filepath="$PROJECT_DIR$/.idea/openfire_api.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
9
|
+
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
|
3
|
+
<component name="FacetManager">
|
|
4
|
+
<facet type="gem" name="Gem">
|
|
5
|
+
<configuration>
|
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$/../openfire_api" />
|
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/../openfire_api/lib" />
|
|
9
|
+
</configuration>
|
|
10
|
+
</facet>
|
|
11
|
+
</component>
|
|
12
|
+
<component name="ModuleRunConfigurationManager">
|
|
13
|
+
<configuration default="false" name="All tests in openfire_api_ruby: openfire_api" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest" temporary="true">
|
|
14
|
+
<predefined_log_file id="RUBY_TESTUNIT" enabled="true" />
|
|
15
|
+
<module name="openfire_api" />
|
|
16
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
|
17
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$/lib/openfire_api_ruby" />
|
|
18
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
|
19
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
|
20
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
|
21
|
+
<envs>
|
|
22
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
|
23
|
+
</envs>
|
|
24
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
|
25
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
|
26
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
|
27
|
+
<COVERAGE_PATTERN ENABLED="true">
|
|
28
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
|
29
|
+
</COVERAGE_PATTERN>
|
|
30
|
+
</EXTENSION>
|
|
31
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
|
32
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$/lib/openfire_api_ruby" />
|
|
33
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
|
|
34
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/{*_test,test_*}.rb" />
|
|
35
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
|
|
36
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="ALL_IN_FOLDER" />
|
|
37
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
|
38
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
|
39
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_OPTIONS" VALUE="" />
|
|
40
|
+
<RunnerSettings RunnerId="RubyDebugRunner" />
|
|
41
|
+
<ConfigurationWrapper RunnerId="RubyDebugRunner" />
|
|
42
|
+
<method />
|
|
43
|
+
</configuration>
|
|
44
|
+
<configuration default="false" name="All tests in openfire_api_ruby: openfire_api (1)" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest" temporary="true">
|
|
45
|
+
<predefined_log_file id="RUBY_TESTUNIT" enabled="true" />
|
|
46
|
+
<module name="openfire_api" />
|
|
47
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
|
48
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
|
49
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
|
50
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
|
51
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
|
52
|
+
<envs>
|
|
53
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
|
54
|
+
</envs>
|
|
55
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
|
56
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
|
57
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
|
58
|
+
<COVERAGE_PATTERN ENABLED="true">
|
|
59
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
|
60
|
+
</COVERAGE_PATTERN>
|
|
61
|
+
</EXTENSION>
|
|
62
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
|
63
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$" />
|
|
64
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
|
|
65
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/{*_test,test_*}.rb" />
|
|
66
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
|
|
67
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="ALL_IN_FOLDER" />
|
|
68
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
|
69
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
|
70
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_OPTIONS" VALUE="" />
|
|
71
|
+
<RunnerSettings RunnerId="RubyDebugRunner" />
|
|
72
|
+
<ConfigurationWrapper RunnerId="RubyDebugRunner" />
|
|
73
|
+
<method />
|
|
74
|
+
</configuration>
|
|
75
|
+
<configuration default="false" name="Run spec 'room_service_spec': openfire_api" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
|
76
|
+
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
|
77
|
+
<module name="openfire_api" />
|
|
78
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
|
79
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
|
80
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
|
81
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
|
82
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
|
83
|
+
<envs>
|
|
84
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
|
85
|
+
</envs>
|
|
86
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
|
87
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
|
88
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
|
89
|
+
<COVERAGE_PATTERN ENABLED="true">
|
|
90
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
|
91
|
+
</COVERAGE_PATTERN>
|
|
92
|
+
</EXTENSION>
|
|
93
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
|
94
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
|
95
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/room_service_spec.rb" />
|
|
96
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
|
97
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
|
98
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
|
99
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
|
100
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
|
101
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
|
102
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
|
|
103
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
|
104
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
|
105
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
|
106
|
+
<RunnerSettings RunnerId="RubyRunner" />
|
|
107
|
+
<ConfigurationWrapper RunnerId="RubyRunner" />
|
|
108
|
+
<method />
|
|
109
|
+
</configuration>
|
|
110
|
+
<configuration default="false" name="spec_helper" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
|
|
111
|
+
<module name="openfire_api" />
|
|
112
|
+
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
|
113
|
+
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/spec" />
|
|
114
|
+
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
|
|
115
|
+
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
|
|
116
|
+
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
|
117
|
+
<envs />
|
|
118
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
|
119
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
|
120
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
|
121
|
+
<COVERAGE_PATTERN ENABLED="true">
|
|
122
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
|
123
|
+
</COVERAGE_PATTERN>
|
|
124
|
+
</EXTENSION>
|
|
125
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
|
126
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/spec_helper.rb" />
|
|
127
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
|
128
|
+
<RunnerSettings RunnerId="RubyRunner" />
|
|
129
|
+
<ConfigurationWrapper RunnerId="RubyRunner" />
|
|
130
|
+
<method />
|
|
131
|
+
</configuration>
|
|
132
|
+
<configuration default="false" name="Run spec 'user_service_spec': openfire_api" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
|
133
|
+
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
|
134
|
+
<module name="openfire_api" />
|
|
135
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
|
136
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
|
137
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
|
138
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
|
139
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
|
140
|
+
<envs>
|
|
141
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
|
142
|
+
</envs>
|
|
143
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
|
144
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
|
145
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
|
146
|
+
<COVERAGE_PATTERN ENABLED="true">
|
|
147
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
|
148
|
+
</COVERAGE_PATTERN>
|
|
149
|
+
</EXTENSION>
|
|
150
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
|
151
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
|
152
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/user_service_spec.rb" />
|
|
153
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
|
154
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
|
155
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
|
156
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
|
157
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
|
158
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
|
159
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
|
|
160
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
|
161
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
|
162
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
|
163
|
+
<RunnerSettings RunnerId="RubyRunner" />
|
|
164
|
+
<ConfigurationWrapper RunnerId="RubyRunner" />
|
|
165
|
+
<method />
|
|
166
|
+
</configuration>
|
|
167
|
+
</component>
|
|
168
|
+
<component name="NewModuleRootManager">
|
|
169
|
+
<content url="file://$MODULE_DIR$" />
|
|
170
|
+
<orderEntry type="inheritedJdk" />
|
|
171
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
172
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.5, ruby-2.0.0-p247) [gem]" level="application" />
|
|
173
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.1.2, ruby-2.0.0-p247) [gem]" level="application" />
|
|
174
|
+
<orderEntry type="library" scope="PROVIDED" name="fakeweb (v1.3.0, ruby-2.0.0-p247) [gem]" level="application" />
|
|
175
|
+
<orderEntry type="library" scope="PROVIDED" name="git (v1.2.5, ruby-2.0.0-p247) [gem]" level="application" />
|
|
176
|
+
<orderEntry type="library" scope="PROVIDED" name="jeweler (v1.5.2, ruby-2.0.0-p247) [gem]" level="application" />
|
|
177
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v0.9.2, ruby-2.0.0-p247) [gem]" level="application" />
|
|
178
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v2.6.0, ruby-2.0.0-p247) [gem]" level="application" />
|
|
179
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.6.4, ruby-2.0.0-p247) [gem]" level="application" />
|
|
180
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.6.0, ruby-2.0.0-p247) [gem]" level="application" />
|
|
181
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.6.0, ruby-2.0.0-p247) [gem]" level="application" />
|
|
182
|
+
<orderEntry type="library" scope="PROVIDED" name="shoulda (v2.11.3, ruby-2.0.0-p247) [gem]" level="application" />
|
|
183
|
+
</component>
|
|
184
|
+
</module>
|
|
185
|
+
|
data/.idea/vcs.xml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
openfire (0.0.1)
|
|
5
|
+
activesupport (> 3)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activesupport (4.1.4)
|
|
11
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
12
|
+
json (~> 1.7, >= 1.7.7)
|
|
13
|
+
minitest (~> 5.1)
|
|
14
|
+
thread_safe (~> 0.1)
|
|
15
|
+
tzinfo (~> 1.1)
|
|
16
|
+
diff-lcs (1.1.2)
|
|
17
|
+
fakeweb (1.3.0)
|
|
18
|
+
i18n (0.6.11)
|
|
19
|
+
json (1.8.1)
|
|
20
|
+
minitest (5.4.0)
|
|
21
|
+
rake (10.3.2)
|
|
22
|
+
rspec (2.6.0)
|
|
23
|
+
rspec-core (~> 2.6.0)
|
|
24
|
+
rspec-expectations (~> 2.6.0)
|
|
25
|
+
rspec-mocks (~> 2.6.0)
|
|
26
|
+
rspec-core (2.6.4)
|
|
27
|
+
rspec-expectations (2.6.0)
|
|
28
|
+
diff-lcs (~> 1.1.2)
|
|
29
|
+
rspec-mocks (2.6.0)
|
|
30
|
+
shoulda (2.11.3)
|
|
31
|
+
thread_safe (0.3.4)
|
|
32
|
+
tzinfo (1.2.1)
|
|
33
|
+
thread_safe (~> 0.1)
|
|
34
|
+
|
|
35
|
+
PLATFORMS
|
|
36
|
+
ruby
|
|
37
|
+
|
|
38
|
+
DEPENDENCIES
|
|
39
|
+
bundler
|
|
40
|
+
fakeweb
|
|
41
|
+
openfire!
|
|
42
|
+
rake
|
|
43
|
+
rspec
|
|
44
|
+
shoulda
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Chris Bielinski
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Openfire
|
|
2
|
+
|
|
3
|
+
A Ruby client for accessing Openfire's User, Room, and Group service API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add it to your Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'openfire'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And `bundle install`.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Connect to the API by providing the endpoint URL and secret token:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
client = Openfire::Client.new 'http://localhost:9090/', 'ABC123DEF456'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Register a New User
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
client.add_user! username: 'john', password: 'sup3rs3cr3t!'
|
|
27
|
+
client.add_user! username: 'john', password: 'sup3rs3cr3t!', :name => ..., :email => ..., :groups => ...
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Update an Existing User
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
client.update_user! username: 'john', password: 'sup3rs3cr3t!'
|
|
34
|
+
client.update_user! username: 'john', password: 'sup3rs3cr3t!', :name => ..., :email => ..., :groups => ...
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Delete a User
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
client.delete_user! username: 'john'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Lock a User
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
api.lock_user! username: 'john'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Unlock a User
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
client.unlock_user! username: 'john'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Create a Room
|
|
56
|
+
|
|
57
|
+
```ruby
|
|
58
|
+
client.add_room! roomname: 'general', :jid => "jid", :subdomain => "generalchat"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Delete a Room
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
client.delete_room! roomname: 'general', :subdomain => "generalchat"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Create a MUC (multi-user chat) Service
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
client.add_muc_service! :subdomain => 'demo-service', :description => 'this is a demo muc service'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Delete a MUC Service
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
client.delete_muc_service! :subdomain => 'demo-service'
|
|
77
|
+
```
|
data/Rakefile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
Bundler.setup(:default, :development)
|
|
6
|
+
rescue Bundler::BundlerError => e
|
|
7
|
+
$stderr.puts e.message
|
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
9
|
+
exit e.status_code
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require 'rspec/core/rake_task'
|
|
13
|
+
|
|
14
|
+
desc "Run all examples"
|
|
15
|
+
task RSpec::Core::RakeTask.new('spec')
|
|
16
|
+
|
|
17
|
+
task default: :spec
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.3.0
|
data/lib/openfire.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
|
|
4
|
+
require 'active_support/configurable'
|
|
5
|
+
require 'active_support/inflector'
|
|
6
|
+
|
|
7
|
+
require 'openfire/client'
|
|
8
|
+
require 'openfire/service/base'
|
|
9
|
+
require 'openfire/service/user'
|
|
10
|
+
require 'openfire/service/room'
|
|
11
|
+
require 'openfire/service/group'
|
|
12
|
+
|
|
13
|
+
module Openfire
|
|
14
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Openfire
|
|
2
|
+
class Client
|
|
3
|
+
include ActiveSupport::Configurable
|
|
4
|
+
|
|
5
|
+
config.services = [ 'Group', 'Room', 'User' ]
|
|
6
|
+
|
|
7
|
+
def initialize(url,secret)
|
|
8
|
+
@services = config.services.map { |s| "Openfire::Service::#{s}".constantize.new url: url, secret: secret }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def get_service(service)
|
|
12
|
+
klass_name = "Openfire::Service::#{service.to_s.classify}"
|
|
13
|
+
klass = klass_name.constantize rescue nil
|
|
14
|
+
@services.each { |s| return s if s.is_a?(klass) }
|
|
15
|
+
raise "unknown service: #{service}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def method_missing(meth, *args, &block)
|
|
19
|
+
@services.each do |service|
|
|
20
|
+
if service.respond_to?(meth)
|
|
21
|
+
return service.send meth, *args
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Openfire
|
|
2
|
+
module Service
|
|
3
|
+
class Base
|
|
4
|
+
include ActiveSupport::Configurable
|
|
5
|
+
|
|
6
|
+
config.path = '/'
|
|
7
|
+
config.exceptions = []
|
|
8
|
+
|
|
9
|
+
def initialize(options={})
|
|
10
|
+
@options = { path: config.path }.merge(options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def build_query(params)
|
|
16
|
+
"#{build_query_uri.to_s}?#{build_query_params(params)}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def build_query_uri
|
|
20
|
+
uri = URI.parse(@options[:url])
|
|
21
|
+
uri.path = File.join(uri.path,config.path)
|
|
22
|
+
uri
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def build_query_params(params)
|
|
26
|
+
params.merge!(:secret => @options[:secret])
|
|
27
|
+
params.to_a.map{ |p| "#{p[0]}=#{p[1]}" }.join('&')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def submit_request(params)
|
|
31
|
+
data = submit_http_request(build_query_uri, build_query_params(params))
|
|
32
|
+
parse_response(data)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def submit_http_request(uri, params_as_string)
|
|
36
|
+
uri.query = URI.encode(params_as_string)
|
|
37
|
+
res = Net::HTTP.get_response(uri)
|
|
38
|
+
|
|
39
|
+
return res.body
|
|
40
|
+
rescue Exception => e
|
|
41
|
+
raise HTTPException, e.to_s
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def parse_response(data)
|
|
45
|
+
error = data.match(/<error>(.*)<\/error>/)
|
|
46
|
+
if error && config.exceptions.include?(error[1])
|
|
47
|
+
exception_klass = "#{self.class}::#{error[1].gsub('Exception', '')}Exception"
|
|
48
|
+
raise exception_klass.constantize
|
|
49
|
+
end
|
|
50
|
+
raise InvalidResponseException unless data.match(/<result>ok<\/result>/)
|
|
51
|
+
return true
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Openfire
|
|
2
|
+
module Service
|
|
3
|
+
class Group < Base
|
|
4
|
+
|
|
5
|
+
config.path = 'plugins/groupService/groupservice'
|
|
6
|
+
config.exceptions = [
|
|
7
|
+
'GroupServiceDisabled',
|
|
8
|
+
'RequestNotAuthorised',
|
|
9
|
+
'IllegalArgumentException',
|
|
10
|
+
'GroupNotFoundException',
|
|
11
|
+
'GroupAlreadyExistsException'
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
class HTTPException < StandardError; end
|
|
15
|
+
class InvalidResponseException < StandardError; end
|
|
16
|
+
class GroupServiceDisabledException < StandardError; end
|
|
17
|
+
class RequestNotAuthorisedException < StandardError; end
|
|
18
|
+
class IllegalArgumentException < StandardError; end
|
|
19
|
+
class GroupNotFoundException < StandardError; end
|
|
20
|
+
class GroupAlreadyExistsException < StandardError; end
|
|
21
|
+
|
|
22
|
+
def add_group!(opts)
|
|
23
|
+
submit_request(opts.merge(:type => :add))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def delete_group!(opts)
|
|
27
|
+
submit_request(opts.merge(:type => :delete))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update_group!(opts)
|
|
31
|
+
submit_request(opts.merge(:type => :update))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def lock_group!(opts)
|
|
35
|
+
submit_request(opts.merge(:type => :disable))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def unlock_group!(opts)
|
|
39
|
+
submit_request(opts.merge(:type => :enable))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Openfire
|
|
2
|
+
module Service
|
|
3
|
+
class Room < Base
|
|
4
|
+
|
|
5
|
+
config.path = 'plugins/roomService/roomservice'
|
|
6
|
+
config.exceptions = [
|
|
7
|
+
'RoomServiceDisabled',
|
|
8
|
+
'RequestNotAuthorised',
|
|
9
|
+
'NotAllowedException',
|
|
10
|
+
'IllegalArgumentException',
|
|
11
|
+
'AlreadyExistsException',
|
|
12
|
+
'NotFoundException'
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
class HTTPException < StandardError; end
|
|
16
|
+
class InvalidResponseException < StandardError; end
|
|
17
|
+
class RoomServiceDisabledException < StandardError; end
|
|
18
|
+
class RequestNotAuthorisedException < StandardError; end
|
|
19
|
+
class NotAllowedException < StandardError; end
|
|
20
|
+
class IllegalArgumentException < StandardError; end
|
|
21
|
+
class AlreadyExistsException < StandardError; end
|
|
22
|
+
class NotFoundException < StandardError; end
|
|
23
|
+
|
|
24
|
+
def add_room!(opts)
|
|
25
|
+
submit_request(opts.merge(:type => :add))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def delete_room!(opts)
|
|
29
|
+
submit_request(opts.merge(:type => :delete))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def create_muc_service!(opts)
|
|
33
|
+
submit_request(opts.merge(:type => :createMultiUserChatService))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def rename_muc_service!(opts)
|
|
37
|
+
submit_request(opts.merge(:type => :updateMultiUserChatService))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def delete_muc_service!(opts)
|
|
41
|
+
submit_request(opts.merge(:type => :removeMultiUserChatService))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Openfire
|
|
2
|
+
module Service
|
|
3
|
+
class User < Base
|
|
4
|
+
|
|
5
|
+
config.path = 'plugins/userService/userservice'
|
|
6
|
+
config.exceptions = [
|
|
7
|
+
'UserServiceDisabled',
|
|
8
|
+
'RequestNotAuthorised',
|
|
9
|
+
'IllegalArgumentException',
|
|
10
|
+
'UserNotFoundException',
|
|
11
|
+
'UserAlreadyExistsException'
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
class HTTPException < StandardError; end
|
|
15
|
+
class InvalidResponseException < StandardError; end
|
|
16
|
+
class UserServiceDisabledException < StandardError; end
|
|
17
|
+
class RequestNotAuthorisedException < StandardError; end
|
|
18
|
+
class IllegalArgumentException < StandardError; end
|
|
19
|
+
class UserNotFoundException < StandardError; end
|
|
20
|
+
class UserAlreadyExistsException < StandardError; end
|
|
21
|
+
|
|
22
|
+
def add_user!(opts)
|
|
23
|
+
submit_request(opts.merge(:type => :add))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def delete_user!(opts)
|
|
27
|
+
submit_request(opts.merge(:type => :delete))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update_user!(opts)
|
|
31
|
+
submit_request(opts.merge(:type => :update))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def lock_user!(opts)
|
|
35
|
+
submit_request(opts.merge(:type => :disable))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def unlock_user!(opts)
|
|
39
|
+
submit_request(opts.merge(:type => :enable))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/openfire.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "openfire/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = %q{openfire}
|
|
7
|
+
|
|
8
|
+
s.version = Openfire::VERSION
|
|
9
|
+
s.platform = Gem::Platform::RUBY
|
|
10
|
+
|
|
11
|
+
s.summary = %q{Ruby client for the Openfire API}
|
|
12
|
+
s.description = %q{Ruby client for the Openfire API. Provides access to Group, User, and Room service APIs.}
|
|
13
|
+
|
|
14
|
+
s.authors = [ 'Chris Bielinski' ]
|
|
15
|
+
s.email = [ 'chris@shadowreactor.com' ]
|
|
16
|
+
s.homepage = 'http://github.com/chrisb/openfire'
|
|
17
|
+
|
|
18
|
+
s.license = 'MIT'
|
|
19
|
+
|
|
20
|
+
s.add_dependency 'activesupport', '>3'
|
|
21
|
+
|
|
22
|
+
s.add_development_dependency 'rake'
|
|
23
|
+
s.add_development_dependency 'rspec'
|
|
24
|
+
s.add_development_dependency 'fakeweb'
|
|
25
|
+
s.add_development_dependency 'shoulda'
|
|
26
|
+
s.add_development_dependency 'bundler'
|
|
27
|
+
|
|
28
|
+
s.files = `git ls-files`.split("\n")
|
|
29
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
30
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
31
|
+
s.require_paths = [ 'lib' ]
|
|
32
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Room Service" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@client = Openfire::Client.new 'http://fakehost.int:2323/', 'bigsecret'
|
|
7
|
+
@room_service = @client.get_service :room
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should build query urls" do
|
|
11
|
+
url = @room_service.send(:build_query_uri)
|
|
12
|
+
url.to_s.should == "http://fakehost.int:2323/plugins/roomService/roomservice"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should build query params" do
|
|
16
|
+
params = @room_service.send(:build_query_params, :type => :add, :roomname => "room", :subdomain => "groupchat")
|
|
17
|
+
params.should include("type=add")
|
|
18
|
+
params.should include("roomname=room")
|
|
19
|
+
params.should include("subdomain=groupchat")
|
|
20
|
+
params.should include("secret=bigsecret")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should build queries" do
|
|
24
|
+
url = @room_service.send(:build_query, :type => :add, :roomname => "room", :subdomain => "groupchat")
|
|
25
|
+
url.should include("http://fakehost.int:2323/plugins/roomService/roomservice?")
|
|
26
|
+
url.should include("type=add")
|
|
27
|
+
url.should include("roomname=room")
|
|
28
|
+
url.should include("subdomain=groupchat")
|
|
29
|
+
url.should include("secret=bigsecret")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should submit requests" do
|
|
33
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/roomService/roomservice?type=add&roomname=room&subdomain=groupchat&secret=bigsecret", :body => "<result>ok</result>")
|
|
34
|
+
@room_service.send(:submit_request, :type => :add, :roomname => "room", :subdomain => "groupchat").should == true
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should add rooms" do
|
|
38
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/roomService/roomservice?type=add&roomname=room&subdomain=groupchat&secret=bigsecret", :body => "<result>ok</result>")
|
|
39
|
+
@room_service.add_room!(:roomname => "room", :subdomain => "groupchat").should == true
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should delete rooms" do
|
|
43
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/roomService/roomservice?type=delete&roomname=room&subdomain=groupchat&secret=bigsecret", :body => "<result>ok</result>")
|
|
44
|
+
@room_service.delete_room!(:roomname => "room", :subdomain => "groupchat").should == true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should handle the error: room service disabled" do
|
|
48
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/roomService/roomservice?roomname=room1&type=add&secret=bigsecret", :body => "<error>RoomServiceDisabled</error>")
|
|
49
|
+
lambda{ @room_service.add_room!(:roomname => "room1") }.should raise_error(Openfire::Service::Room::RoomServiceDisabledException)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should handle the error: request not authorized" do
|
|
53
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/roomService/roomservice?roomname=room1&type=add&secret=bigsecret", :body => "<error>RequestNotAuthorised</error>")
|
|
54
|
+
lambda{ @room_service.add_room!(:roomname => "room1") }.should raise_error(Openfire::Service::Room::RequestNotAuthorisedException)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should handle the error: not allowed" do
|
|
58
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/roomService/roomservice?roomname=room1&type=add&secret=bigsecret", :body => "<error>NotAllowedException</error>")
|
|
59
|
+
lambda{ @room_service.add_room!(:roomname => "room1") }.should raise_error(Openfire::Service::Room::NotAllowedException)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should handle the error: illegal argument" do
|
|
63
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/roomService/roomservice?roomname=room1&type=add&secret=bigsecret", :body => "<error>IllegalArgumentException</error>")
|
|
64
|
+
lambda{ @room_service.add_room!(:roomname => "room1") }.should raise_error(Openfire::Service::Room::IllegalArgumentException)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
require ::File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
describe "User Service" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@client = Openfire::Client.new 'http://fakehost.int:2323/', 'bigsecret'
|
|
7
|
+
@user_service = @client.get_service :user
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should build query urls" do
|
|
11
|
+
url = @user_service.send(:build_query_uri)
|
|
12
|
+
url.to_s.should == "http://fakehost.int:2323/plugins/userService/userservice"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should build query params" do
|
|
16
|
+
params = @user_service.send(:build_query_params, :type => :add, :username => "user", :password => "pw")
|
|
17
|
+
params.should include("type=add")
|
|
18
|
+
params.should include("username=user")
|
|
19
|
+
params.should include("password=pw")
|
|
20
|
+
params.should include("secret=bigsecret")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should build queries" do
|
|
24
|
+
url = @user_service.send(:build_query, :type => :add, :username => "user", :password => "pw")
|
|
25
|
+
url.should include("http://fakehost.int:2323/plugins/userService/userservice?")
|
|
26
|
+
url.should include("type=add")
|
|
27
|
+
url.should include("type=add")
|
|
28
|
+
url.should include("username=user")
|
|
29
|
+
url.should include("password=pw")
|
|
30
|
+
url.should include("secret=bigsecret")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should submit requests" do
|
|
34
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?type=add&username=user&password=pw&secret=bigsecret", :body => "<result>ok</result>")
|
|
35
|
+
@user_service.send(:submit_request, :type => :add, :username => "user", :password => "pw").should == true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should add users" do
|
|
39
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?type=add&username=user&password=pw&secret=bigsecret", :body => "<result>ok</result>")
|
|
40
|
+
@user_service.add_user!(:username => "user", :password => "pw").should == true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should delete users" do
|
|
44
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?type=delete&username=user&secret=bigsecret", :body => "<result>ok</result>")
|
|
45
|
+
@user_service.delete_user!(:username => "user").should == true
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should update users" do
|
|
49
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?type=update&username=user&password=pw&name=horst&secret=bigsecret", :body => "<result>ok</result>")
|
|
50
|
+
@user_service.update_user!(:username => "user", :password => "pw", :name => "horst").should == true
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should lock users" do
|
|
54
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?type=disable&username=user&secret=bigsecret", :body => "<result>ok</result>")
|
|
55
|
+
@user_service.lock_user!(:username => "user").should == true
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should unlock users" do
|
|
59
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?type=enable&username=user&secret=bigsecret", :body => "<result>ok</result>")
|
|
60
|
+
@user_service.unlock_user!(:username => "user").should == true
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should handle the error: user service disabled" do
|
|
64
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?username=user1&type=disable&secret=bigsecret", :body => "<error>UserServiceDisabled</error>")
|
|
65
|
+
lambda{ @user_service.lock_user!(:username => "user1") }.should raise_error(Openfire::Service::User::UserServiceDisabledException)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should handle the error: request not authorized" do
|
|
69
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?username=user1&type=disable&secret=bigsecret", :body => "<error>RequestNotAuthorised</error>")
|
|
70
|
+
lambda{ @user_service.lock_user!(:username => "user1") }.should raise_error(Openfire::Service::User::RequestNotAuthorisedException)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should handle the error: illegal argument" do
|
|
74
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?username=user1&type=disable&secret=bigsecret", :body => "<error>IllegalArgumentException</error>")
|
|
75
|
+
lambda{ @user_service.lock_user!(:username => "user1") }.should raise_error(Openfire::Service::User::IllegalArgumentException)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should handle the error: user not found" do
|
|
79
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?username=user1&type=disable&secret=bigsecret", :body => "<error>UserNotFoundException</error>")
|
|
80
|
+
lambda{ @user_service.lock_user!(:username => "user1") }.should raise_error(Openfire::Service::User::UserNotFoundException)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should handle the error: user already exists" do
|
|
84
|
+
FakeWeb.register_uri(:get, "http://fakehost.int:2323/plugins/userService/userservice?username=user1&type=disable&secret=bigsecret", :body => "<error>UserAlreadyExistsException</error>")
|
|
85
|
+
lambda{ @user_service.lock_user!(:username => "user1") }.should raise_error(Openfire::Service::User::UserAlreadyExistsException)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: openfire
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Chris Bielinski
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: activesupport
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '3'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '3'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: fakeweb
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: shoulda
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: bundler
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: Ruby client for the Openfire API. Provides access to Group, User, and
|
|
98
|
+
Room service APIs.
|
|
99
|
+
email:
|
|
100
|
+
- chris@shadowreactor.com
|
|
101
|
+
executables: []
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".idea/encodings.xml"
|
|
107
|
+
- ".idea/misc.xml"
|
|
108
|
+
- ".idea/modules.xml"
|
|
109
|
+
- ".idea/openfire_api.iml"
|
|
110
|
+
- ".idea/scopes/scope_settings.xml"
|
|
111
|
+
- ".idea/vcs.xml"
|
|
112
|
+
- Gemfile
|
|
113
|
+
- Gemfile.lock
|
|
114
|
+
- LICENSE
|
|
115
|
+
- README.md
|
|
116
|
+
- Rakefile
|
|
117
|
+
- VERSION
|
|
118
|
+
- lib/openfire.rb
|
|
119
|
+
- lib/openfire/client.rb
|
|
120
|
+
- lib/openfire/service/base.rb
|
|
121
|
+
- lib/openfire/service/group.rb
|
|
122
|
+
- lib/openfire/service/room.rb
|
|
123
|
+
- lib/openfire/service/user.rb
|
|
124
|
+
- lib/openfire/version.rb
|
|
125
|
+
- openfire.gemspec
|
|
126
|
+
- spec/room_service_spec.rb
|
|
127
|
+
- spec/spec_helper.rb
|
|
128
|
+
- spec/user_service_spec.rb
|
|
129
|
+
homepage: http://github.com/chrisb/openfire
|
|
130
|
+
licenses:
|
|
131
|
+
- MIT
|
|
132
|
+
metadata: {}
|
|
133
|
+
post_install_message:
|
|
134
|
+
rdoc_options: []
|
|
135
|
+
require_paths:
|
|
136
|
+
- lib
|
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
|
+
requirements:
|
|
139
|
+
- - ">="
|
|
140
|
+
- !ruby/object:Gem::Version
|
|
141
|
+
version: '0'
|
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
|
+
requirements:
|
|
144
|
+
- - ">="
|
|
145
|
+
- !ruby/object:Gem::Version
|
|
146
|
+
version: '0'
|
|
147
|
+
requirements: []
|
|
148
|
+
rubyforge_project:
|
|
149
|
+
rubygems_version: 2.2.2
|
|
150
|
+
signing_key:
|
|
151
|
+
specification_version: 4
|
|
152
|
+
summary: Ruby client for the Openfire API
|
|
153
|
+
test_files:
|
|
154
|
+
- spec/room_service_spec.rb
|
|
155
|
+
- spec/spec_helper.rb
|
|
156
|
+
- spec/user_service_spec.rb
|