zimbra_intercepting_proxy 0.0.4.4 → 0.0.5
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 +4 -4
- data/.gitignore +1 -0
- data/README.md +9 -0
- data/lib/zimbra_intercepting_proxy.rb +1 -0
- data/lib/zimbra_intercepting_proxy/user.rb +7 -1
- data/lib/zimbra_intercepting_proxy/version.rb +1 -1
- data/lib/zimbra_intercepting_proxy/yamler.rb +18 -0
- data/test/fixtures/users.yml +1 -1
- data/test/test_helper.rb +18 -1
- data/test/test_user.rb +11 -0
- data/test/test_yamler.rb +24 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b534962352a26c91cff6e4d3d26d4dc32b19e748
|
4
|
+
data.tar.gz: 31bcc78a7af08640193d35afb7ad6597c3a57de5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f23053a8336cf6754cfca338692c294caa388fe209c88ddcd79540288bdf99b3ffb1df9a515545976291540e39455d188769b6f4f39dc4c5f2ffcdbadd96cce5
|
7
|
+
data.tar.gz: a3015c1dcdd6f7795b46549d9aeca17b0083ac07503900ef9b425590321d8f54e0a8f5e3050ef47d82717c49fb9f28812132d048914331877134a367a40a79fe
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -129,12 +129,21 @@ watson@example.com: "251b1902-2250-4477-bdd1-8a101f7e7e4e"
|
|
129
129
|
sherlock@example.com: "7b562dd0-be97-0132-9a66-482a1423458f"
|
130
130
|
```
|
131
131
|
|
132
|
+
Updating the file does **not require** a restart.
|
133
|
+
|
132
134
|
You can get the `zimbraId` with:
|
133
135
|
|
134
136
|
```
|
135
137
|
$ zmprov ga watson@example.com zimbraId
|
136
138
|
```
|
137
139
|
|
140
|
+
##### Error in Map File
|
141
|
+
If you have an error in your file, `ZIP` will return the on memory Map, this way we can keep the service up. In this event you should see this on `STDOUT`:
|
142
|
+
|
143
|
+
```shel
|
144
|
+
ERROR Yaml File: (./test/fixtures/users.yml): could not find expected ':' while scanning a simple key at line 7
|
145
|
+
```
|
146
|
+
|
138
147
|
## Thanks
|
139
148
|
|
140
149
|
* To the Zimbra folks for a great product, and
|
@@ -13,6 +13,7 @@ require "zimbra_intercepting_proxy/request"
|
|
13
13
|
require "zimbra_intercepting_proxy/server"
|
14
14
|
require "zimbra_intercepting_proxy/debug"
|
15
15
|
require "zimbra_intercepting_proxy/connection"
|
16
|
+
require "zimbra_intercepting_proxy/yamler"
|
16
17
|
|
17
18
|
module ZimbraInterceptingProxy
|
18
19
|
|
@@ -3,6 +3,8 @@ module ZimbraInterceptingProxy
|
|
3
3
|
class User
|
4
4
|
attr_accessor :email, :zimbraId
|
5
5
|
|
6
|
+
@@db = {}
|
7
|
+
|
6
8
|
# user_identifier can be an email address, zimbraId UUID or just the
|
7
9
|
# local part of an email address, like user in user@example.com
|
8
10
|
def initialize(user_identifier)
|
@@ -34,12 +36,16 @@ module ZimbraInterceptingProxy
|
|
34
36
|
!zimbraId.nil?
|
35
37
|
end
|
36
38
|
|
39
|
+
# Return the old DB if the YAML file has error
|
37
40
|
def self.load_migrated_users
|
38
|
-
|
41
|
+
data = ZimbraInterceptingProxy::Yamler.db
|
42
|
+
return @@db unless data
|
43
|
+
@@db = data
|
39
44
|
end
|
40
45
|
|
41
46
|
def self.DB
|
42
47
|
load_migrated_users
|
48
|
+
@@db
|
43
49
|
end
|
44
50
|
|
45
51
|
private
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ZimbraInterceptingProxy
|
2
|
+
|
3
|
+
module Yamler
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
def self.db
|
7
|
+
begin
|
8
|
+
YAML.load_file ZimbraInterceptingProxy::Config.migrated_users_file
|
9
|
+
rescue Psych::SyntaxError => e
|
10
|
+
puts "ERROR Yaml File: #{e}"
|
11
|
+
return false
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/test/fixtures/users.yml
CHANGED
@@ -3,4 +3,4 @@ max@example.com: "7b562c60-be97-0132-9a66-482a1423458f"
|
|
3
3
|
moliery@example.com: "7b562ce0-be97-0132-9a66-482a1423458f"
|
4
4
|
watson@example.com: "251b1902-2250-4477-bdd1-8a101f7e7e4e"
|
5
5
|
sherlock@example.com: "7b562dd0-be97-0132-9a66-482a1423458f"
|
6
|
-
pbruna@itlinux.cl: "cfd6e914-4f00-440c-9a57-e1a9327128b9"
|
6
|
+
pbruna@itlinux.cl: "cfd6e914-4f00-440c-9a57-e1a9327128b9"
|
data/test/test_helper.rb
CHANGED
@@ -9,4 +9,21 @@ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new # spec-like progr
|
|
9
9
|
ZimbraInterceptingProxy::Config.domain="example.com"
|
10
10
|
ZimbraInterceptingProxy::Config.migrated_users_file="./test/fixtures/users.yml"
|
11
11
|
ZimbraInterceptingProxy::Config.old_backend = "old-mailbox.example.com"
|
12
|
-
ZimbraInterceptingProxy::Config.new_backend = "new-mailbox.zboxapp.com"
|
12
|
+
ZimbraInterceptingProxy::Config.new_backend = "new-mailbox.zboxapp.com"
|
13
|
+
|
14
|
+
def add_error_line
|
15
|
+
f = File.open ZimbraInterceptingProxy::Config.migrated_users_file, "a"
|
16
|
+
f.puts "juan :94949494-9494949-040404"
|
17
|
+
f.close
|
18
|
+
end
|
19
|
+
|
20
|
+
def restore_map_file
|
21
|
+
backup_file = "./test/fixtures/users.yml.org"
|
22
|
+
FileUtils.cp(backup_file, ZimbraInterceptingProxy::Config.migrated_users_file)
|
23
|
+
FileUtils.rm "./test/fixtures/users.yml.org"
|
24
|
+
end
|
25
|
+
|
26
|
+
def backup_map_file
|
27
|
+
backup_file = "./test/fixtures/users.yml.org"
|
28
|
+
FileUtils.cp(ZimbraInterceptingProxy::Config.migrated_users_file, backup_file)
|
29
|
+
end
|
data/test/test_user.rb
CHANGED
@@ -57,4 +57,15 @@ class User < Minitest::Test
|
|
57
57
|
assert(!u.migrated?, "Failure message.")
|
58
58
|
end
|
59
59
|
|
60
|
+
|
61
|
+
def test_return_old_db_if_yamler_db_is_false
|
62
|
+
backup_map_file # backup users.yml
|
63
|
+
yaml_1 = ZimbraInterceptingProxy::User.DB.inspect
|
64
|
+
add_error_line
|
65
|
+
yaml_2 = ZimbraInterceptingProxy::User.DB.inspect
|
66
|
+
restore_map_file
|
67
|
+
assert_equal(Digest::MD5.digest(yaml_1), Digest::MD5.digest(yaml_2))
|
68
|
+
end
|
69
|
+
|
70
|
+
|
60
71
|
end
|
data/test/test_yamler.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'digest'
|
3
|
+
|
4
|
+
class Yamler < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
backup_map_file
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
restore_map_file
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_yamler_db_must_return_the_yaml_file_hash
|
15
|
+
db = ZimbraInterceptingProxy::Yamler.db
|
16
|
+
assert_equal("251b1902-2250-4477-bdd1-8a101f7e7e4e", db["watson@example.com"])
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_return_false_if_updated_files_has_error
|
20
|
+
add_error_line
|
21
|
+
assert(!ZimbraInterceptingProxy::Yamler.db, "Failure message.")
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zimbra_intercepting_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio Bruna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-proxy
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/zimbra_intercepting_proxy/server.rb
|
160
160
|
- lib/zimbra_intercepting_proxy/user.rb
|
161
161
|
- lib/zimbra_intercepting_proxy/version.rb
|
162
|
+
- lib/zimbra_intercepting_proxy/yamler.rb
|
162
163
|
- test/fixtures/auth_80.txt
|
163
164
|
- test/fixtures/route_7072.txt
|
164
165
|
- test/fixtures/users.yml
|
@@ -167,6 +168,7 @@ files:
|
|
167
168
|
- test/test_helper.rb
|
168
169
|
- test/test_request.rb
|
169
170
|
- test/test_user.rb
|
171
|
+
- test/test_yamler.rb
|
170
172
|
- zimbra_intercepting_proxy.gemspec
|
171
173
|
homepage: https://github.com/pbruna/zimbra_intercepting_proxy
|
172
174
|
licenses:
|
@@ -201,4 +203,5 @@ test_files:
|
|
201
203
|
- test/test_helper.rb
|
202
204
|
- test/test_request.rb
|
203
205
|
- test/test_user.rb
|
206
|
+
- test/test_yamler.rb
|
204
207
|
has_rdoc:
|