zm-ruby-client 0.14.0 → 0.17.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.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +1 -0
  4. data/README.md +6 -0
  5. data/lib/zm/client/account/account.rb +29 -17
  6. data/lib/zm/client/account/account_jsns_initializer.rb +44 -0
  7. data/lib/zm/client/account/accounts_builder.rb +6 -3
  8. data/lib/zm/client/account/accounts_collection.rb +11 -20
  9. data/lib/zm/client/account.rb +1 -0
  10. data/lib/zm/client/ace/ace.rb +22 -9
  11. data/lib/zm/client/ace/ace_jsns_builder.rb +38 -0
  12. data/lib/zm/client/ace/ace_jsns_initializer.rb +26 -0
  13. data/lib/zm/client/ace/aces_builder.rb +6 -9
  14. data/lib/zm/client/ace/aces_collection.rb +23 -9
  15. data/lib/zm/client/ace.rb +2 -0
  16. data/lib/zm/client/appointment/appointment.rb +9 -6
  17. data/lib/zm/client/appointment/appointments_collection.rb +6 -90
  18. data/lib/zm/client/backup/backup.rb +8 -4
  19. data/lib/zm/client/base/account_object.rb +34 -0
  20. data/lib/zm/client/base/account_objects_collection.rb +14 -0
  21. data/lib/zm/client/base/account_search_objects_collection.rb +125 -0
  22. data/lib/zm/client/base/admin_object.rb +6 -0
  23. data/lib/zm/client/base/admin_objects_collection.rb +65 -0
  24. data/lib/zm/client/base/base_jsns_builder.rb +19 -0
  25. data/lib/zm/client/base/base_jsns_initializer.rb +29 -0
  26. data/lib/zm/client/base/folder_object.rb +41 -0
  27. data/lib/zm/client/base/ldap_filter.rb +33 -0
  28. data/lib/zm/client/base/object.rb +19 -0
  29. data/lib/zm/client/base/objects_builder.rb +4 -0
  30. data/lib/zm/client/base/objects_collection.rb +11 -32
  31. data/lib/zm/client/base/zimbra_attribute.rb +119 -0
  32. data/lib/zm/client/base/zimbra_attributes_collection.rb +38 -0
  33. data/lib/zm/client/base.rb +15 -0
  34. data/lib/zm/client/cluster/cluster.rb +43 -7
  35. data/lib/zm/client/cluster/cluster_config.rb +19 -17
  36. data/lib/zm/client/connector/rest_account.rb +0 -3
  37. data/lib/zm/client/connector/soap_account.rb +66 -123
  38. data/lib/zm/client/connector/soap_admin.rb +28 -16
  39. data/lib/zm/client/connector/soap_base.rb +11 -3
  40. data/lib/zm/client/contact/contact.rb +2 -1
  41. data/lib/zm/client/contact/contacts_builder.rb +3 -13
  42. data/lib/zm/client/contact/contacts_collection.rb +6 -12
  43. data/lib/zm/client/cos/cos.rb +9 -5
  44. data/lib/zm/client/cos/coses_builder.rb +1 -16
  45. data/lib/zm/client/cos/coses_collection.rb +6 -9
  46. data/lib/zm/client/distributionlist/distributionlist.rb +44 -6
  47. data/lib/zm/client/distributionlist/distributionlists_builder.rb +2 -17
  48. data/lib/zm/client/distributionlist/distributionlists_collection.rb +4 -11
  49. data/lib/zm/client/distributionlist/dls_membership_collection.rb +24 -0
  50. data/lib/zm/client/distributionlist.rb +1 -0
  51. data/lib/zm/client/document/document.rb +7 -9
  52. data/lib/zm/client/domain/domain.rb +11 -6
  53. data/lib/zm/client/domain/domain_accounts_collection.rb +13 -0
  54. data/lib/zm/client/domain/domains_builder.rb +1 -19
  55. data/lib/zm/client/domain/domains_collection.rb +7 -10
  56. data/lib/zm/client/domain.rb +1 -0
  57. data/lib/zm/client/folder/folder.rb +50 -124
  58. data/lib/zm/client/folder/folder_grant.rb +44 -22
  59. data/lib/zm/client/folder/folder_grant_jsns_builder.rb +43 -0
  60. data/lib/zm/client/folder/folder_grants_collection.rb +35 -0
  61. data/lib/zm/client/folder/folder_jsns_builder.rb +132 -0
  62. data/lib/zm/client/folder/folder_jsns_initializer.rb +49 -0
  63. data/lib/zm/client/folder/folder_retention_policies_collection.rb +40 -0
  64. data/lib/zm/client/folder/folder_retention_policy.rb +8 -30
  65. data/lib/zm/client/folder/folders_builder.rb +2 -2
  66. data/lib/zm/client/folder/folders_collection.rb +21 -19
  67. data/lib/zm/client/folder/folders_jsns_builder.rb +22 -0
  68. data/lib/zm/client/folder.rb +6 -0
  69. data/lib/zm/client/identity/identities_builder.rb +4 -15
  70. data/lib/zm/client/identity/identities_collection.rb +7 -13
  71. data/lib/zm/client/identity/identity.rb +7 -5
  72. data/lib/zm/client/message/message.rb +111 -21
  73. data/lib/zm/client/message/messages_builder.rb +1 -1
  74. data/lib/zm/client/message/messages_collection.rb +10 -92
  75. data/lib/zm/client/mountpoint/mountpoint.rb +15 -68
  76. data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +100 -0
  77. data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +33 -0
  78. data/lib/zm/client/mountpoint/mountpoints_builder.rb +1 -1
  79. data/lib/zm/client/mountpoint/mountpoints_collection.rb +14 -23
  80. data/lib/zm/client/mountpoint.rb +2 -0
  81. data/lib/zm/client/resource/resource.rb +5 -5
  82. data/lib/zm/client/resource/resources_builder.rb +1 -16
  83. data/lib/zm/client/resource/resources_collection.rb +5 -13
  84. data/lib/zm/client/search_folder/search_folder.rb +19 -39
  85. data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +86 -0
  86. data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +33 -0
  87. data/lib/zm/client/search_folder/search_folders_builder.rb +7 -11
  88. data/lib/zm/client/search_folder/search_folders_collection.rb +7 -15
  89. data/lib/zm/client/search_folder.rb +2 -0
  90. data/lib/zm/client/server/server.rb +7 -14
  91. data/lib/zm/client/server/server_accounts_collection.rb +19 -0
  92. data/lib/zm/client/server/servers_builder.rb +4 -16
  93. data/lib/zm/client/server/servers_collection.rb +5 -10
  94. data/lib/zm/client/server.rb +1 -0
  95. data/lib/zm/client/share/share.rb +2 -9
  96. data/lib/zm/client/share/shares_builder.rb +3 -12
  97. data/lib/zm/client/signature/signature.rb +17 -13
  98. data/lib/zm/client/signature/signature_jsns_builder.rb +5 -1
  99. data/lib/zm/client/signature/signature_jsns_initializer.rb +25 -0
  100. data/lib/zm/client/signature/signatures_builder.rb +7 -11
  101. data/lib/zm/client/signature/signatures_collection.rb +6 -14
  102. data/lib/zm/client/signature.rb +1 -0
  103. data/lib/zm/client/tag/tag.rb +27 -20
  104. data/lib/zm/client/tag/tag_jsns_builder.rb +55 -0
  105. data/lib/zm/client/tag/tag_jsns_initializer.rb +26 -0
  106. data/lib/zm/client/tag/tags_builder.rb +6 -9
  107. data/lib/zm/client/tag/tags_collection.rb +6 -12
  108. data/lib/zm/client/tag.rb +2 -0
  109. data/lib/zm/client/task/tasks_collection.rb +6 -90
  110. data/lib/zm/client/upload/upload.rb +1 -1
  111. data/lib/zm/client/version.rb +2 -2
  112. data/lib/zm/modules/common/dl_common.rb +3 -1
  113. data/lib/zm/modules/common/zimbra-attrs.json.bak +1 -0
  114. data/lib/zm/modules/zm_logger.rb +24 -0
  115. data/lib/zm/modules/zm_model.rb +41 -0
  116. data/test/accounts.rb +15 -1
  117. data/test/ace.rb +50 -0
  118. data/test/cluster.rb +41 -0
  119. data/test/cluster_zimbra_attributes.rb +38 -0
  120. data/test/folder.rb +125 -0
  121. data/test/folder_grant.rb +51 -0
  122. data/test/mountpoint.rb +49 -0
  123. data/test/retention_policies.rb +40 -0
  124. data/test/search_folder.rb +67 -0
  125. data/test/signature.rb +53 -0
  126. data/test/tag.rb +65 -0
  127. data/test/zimbra_attributes.rb +35 -0
  128. data/zm-ruby-client.gemspec +1 -0
  129. metadata +59 -3
data/test/cluster.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'minitest/autorun'
2
+
3
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require './lib/zm/client'
6
+
7
+ class TestCluster < Minitest::Test
8
+
9
+ def setup
10
+ @config = Zm::Client::ClusterConfig.new('./test/fixtures/config.json')
11
+ @admin = Zm::Client::Cluster.new(@config)
12
+ @admin.login
13
+ end
14
+
15
+ def test_login
16
+ assert @admin.logged?
17
+ end
18
+
19
+ def test_alive?
20
+ assert @admin.alive?
21
+ end
22
+
23
+ def test_not_alive?
24
+ admin = Zm::Client::Cluster.new(@config)
25
+ admin.soap_admin_connector.token = '12345'
26
+ assert !admin.alive?
27
+ end
28
+
29
+ def test_info
30
+ @admin.infos!
31
+
32
+ assert !@admin.type.nil?
33
+ assert !@admin.version.nil?
34
+ assert !@admin.release.nil?
35
+ assert !@admin.buildDate.nil?
36
+ assert !@admin.host.nil?
37
+ assert !@admin.majorversion.nil?
38
+ assert !@admin.minorversion.nil?
39
+ assert !@admin.microversion.nil?
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ require 'minitest/autorun'
2
+
3
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require './lib/zm/client'
6
+
7
+ class TestZimbraAttributes < Minitest::Test
8
+
9
+ def setup
10
+ @config = Zm::Client::ClusterConfig.new('./test/fixtures/config.json')
11
+ @admin = Zm::Client::Cluster.new(@config)
12
+ end
13
+
14
+ def test_all
15
+ assert @admin.zimbra_attributes.all.is_a?(Array)
16
+ end
17
+
18
+ def test_not_empty
19
+ assert !@admin.zimbra_attributes.all.empty?
20
+ end
21
+
22
+ def test_all_account
23
+ assert !@admin.zimbra_attributes.all_account_attrs.empty?
24
+ end
25
+
26
+ def test_all_account_version
27
+ version = '8.6.0'
28
+ attrs = @admin.zimbra_attributes.all_account_attrs_version(version)
29
+
30
+ assert attrs.length < @admin.zimbra_attributes.all_account_attrs.length
31
+ end
32
+
33
+ def test_all_account_version_by_info
34
+ @admin.login
35
+ @admin.infos!
36
+ assert !@admin.zimbra_attributes.all_account_attrs_version(@admin.version).empty?
37
+ end
38
+ end
data/test/folder.rb ADDED
@@ -0,0 +1,125 @@
1
+ require 'minitest/autorun'
2
+ require 'yaml'
3
+
4
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require './lib/zm/client'
7
+
8
+ class TestSearchFolder < Minitest::Test
9
+
10
+ def setup
11
+ @admin = Zm::Client::Cluster.new(Zm::Client::ClusterConfig.new('./test/fixtures/config.yml'))
12
+ # @admin.logger.debug!
13
+ @admin.login
14
+
15
+ @fixture_accounts = YAML.load(File.read('./test/fixtures/accounts.yml'))
16
+ @account = @admin.accounts.find_by name: @fixture_accounts['accounts']['maxime']['email']
17
+ @account.login
18
+ end
19
+
20
+ def test_all
21
+ folders = @account.folders.all
22
+ assert folders.is_a?(Array)
23
+ end
24
+
25
+ def test_find
26
+ folder = @account.folders.find(10)
27
+ assert folder.id.to_i == 10
28
+ end
29
+
30
+ def test_create
31
+ folder = @account.folders.new do |f|
32
+ f.name = "Test #{Time.now.to_i}"
33
+ f.color = 5
34
+ end
35
+ folder.create!
36
+ assert !folder.id.nil?
37
+ end
38
+
39
+ def test_modify
40
+ folder = @account.folders.first
41
+ folder.color = (1..5).to_a.sample
42
+
43
+ begin
44
+ is_modified = folder.modify!
45
+ rescue StandardError => _
46
+ is_modified = false
47
+ end
48
+
49
+ assert is_modified
50
+ end
51
+
52
+ def test_update
53
+ folder = @account.folders.first
54
+ colors = (1..5).to_a
55
+ colors.delete(folder.color)
56
+ selected_color = colors.sample
57
+
58
+ begin
59
+ is_modified = folder.update!(color: selected_color)
60
+ rescue StandardError => _
61
+ is_modified = false
62
+ end
63
+
64
+ assert is_modified
65
+ assert selected_color == folder.color
66
+ end
67
+
68
+ def test_reload
69
+ folder = @account.folders.first
70
+ id = folder.id
71
+ folder.reload!
72
+
73
+ assert id == folder.id
74
+ end
75
+
76
+ def test_color
77
+ folder = @account.folders.first
78
+ folder.color = (1..5).to_a.sample
79
+
80
+ begin
81
+ is_modified = folder.color!
82
+ rescue StandardError => _
83
+ is_modified = false
84
+ end
85
+
86
+ assert is_modified
87
+ end
88
+
89
+ def test_move
90
+ folder = @account.folders.all.find { |f| !f.is_immutable? && f.l.to_i != 2 }
91
+ folder.l = 2
92
+
93
+ begin
94
+ is_modified = folder.move!
95
+ rescue StandardError => _
96
+ is_modified = false
97
+ end
98
+
99
+ assert is_modified
100
+ end
101
+
102
+ def test_empty
103
+ folder = @account.folders.first
104
+ folder.empty!
105
+ assert folder.nb_items.zero?
106
+ end
107
+
108
+ def test_delete
109
+ folder = @account.folders.all.find { |f| !f.is_immutable? }
110
+ folder.delete!
111
+ assert folder.id.nil?
112
+ end
113
+
114
+ def test_rename
115
+ folder = @account.folders.all.find { |f| !f.is_immutable? }
116
+ new_name = "Test #{Time.now.to_i}"
117
+ folder.name = new_name
118
+ folder.rename!
119
+
120
+ folders = @account.folders.all!
121
+ folder2 = folders.find { |f| f.name == new_name }
122
+
123
+ assert !folder2.nil?
124
+ end
125
+ end
@@ -0,0 +1,51 @@
1
+ require 'minitest/autorun'
2
+ require 'yaml'
3
+
4
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require './lib/zm/client'
7
+
8
+ class TestFolderGrant < Minitest::Test
9
+
10
+ def setup
11
+ @admin = Zm::Client::Cluster.new(Zm::Client::ClusterConfig.new('./test/fixtures/config.yml'))
12
+ # @admin.logger.debug!
13
+ @admin.login
14
+
15
+ @fixture_accounts = YAML.load(File.read('./test/fixtures/accounts.yml'))
16
+ @account = @admin.accounts.find_by name: @fixture_accounts['accounts']['maxime']['email']
17
+ @account.login
18
+ end
19
+
20
+ def test_all
21
+ folders_with_grants = @account.folders.all.reject { |f| f.grants.all.empty? }
22
+ folders_with_grants.each do |folder|
23
+ assert folder.grants.all.is_a?(Array)
24
+
25
+ folder.grants.all.each do |grant|
26
+ assert grant.is_a?(Zm::Client::FolderGrant)
27
+ end
28
+ end
29
+ end
30
+
31
+ def test_delete
32
+ folders_with_grants = @account.folders.all.reject { |f| f.grants.all.empty? }
33
+ folders_with_grants.each do |folder|
34
+ folder.grants.all.each do |grant|
35
+ if grant.is_external? || grant.is_dom?
36
+ grant.delete!
37
+ assert !folder.grants.all.include?(grant)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def test_create
44
+ folder = @account.folders.all.select { |f| f.grants.all.empty? }.sample
45
+ grant = folder.grants.new(@fixture_accounts['accounts']['maxime2']['id'], 'usr', 'r', @fixture_accounts['accounts']['maxime2']['email'])
46
+ grant.save!
47
+
48
+ folder_ids_with_grants = @account.folders.all!.reject { |f| f.grants.all.empty? }.map(&:id)
49
+ assert folder_ids_with_grants.include?(folder.id)
50
+ end
51
+ end
@@ -0,0 +1,49 @@
1
+ require 'minitest/autorun'
2
+ require 'yaml'
3
+
4
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require './lib/zm/client'
7
+
8
+ class TestMountPoint < Minitest::Test
9
+
10
+ def setup
11
+ @admin = Zm::Client::Cluster.new(Zm::Client::ClusterConfig.new('./test/fixtures/config.yml'))
12
+ # @admin.logger.debug!
13
+ @admin.login
14
+
15
+ @fixture_accounts = YAML.load(File.read('./test/fixtures/accounts.yml'))
16
+ @account = @admin.accounts.find_by name: @fixture_accounts['accounts']['maxime']['email']
17
+ @account.login
18
+ end
19
+
20
+ def test_all
21
+ mountpoints = @account.mountpoints.all
22
+ assert mountpoints.is_a?(Array)
23
+ end
24
+
25
+ def test_color
26
+ mountpoint = @account.mountpoints.first
27
+ mountpoint.color = (1..5).to_a.sample
28
+
29
+ begin
30
+ is_modified = mountpoint.color!
31
+ rescue StandardError => _
32
+ is_modified = false
33
+ end
34
+
35
+ assert is_modified
36
+ end
37
+
38
+ def test_rename
39
+ mountpoint = @account.mountpoints.all.sample
40
+ new_name = "Test #{Time.now.to_i}"
41
+ mountpoint.name = new_name
42
+ mountpoint.rename!
43
+
44
+ mountpoints = @account.mountpoints.all!
45
+ mountpoint2 = mountpoints.find { |f| f.name == new_name }
46
+
47
+ assert !mountpoint2.nil?
48
+ end
49
+ end
@@ -0,0 +1,40 @@
1
+ require 'minitest/autorun'
2
+ require 'yaml'
3
+
4
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require './lib/zm/client'
7
+
8
+ class TestRetentionPolicy < Minitest::Test
9
+
10
+ def setup
11
+ @admin = Zm::Client::Cluster.new(Zm::Client::ClusterConfig.new('./test/fixtures/config.yml'))
12
+ # @admin.logger.debug!
13
+ @admin.login
14
+
15
+ @fixture_accounts = YAML.load(File.read('./test/fixtures/accounts.yml'))
16
+ @account = @admin.accounts.find_by name: @fixture_accounts['accounts']['maxime']['email']
17
+ @account.login
18
+ end
19
+
20
+ def test_all
21
+ folders_with_retention_policies = @account.folders.all.reject { |f| f.retention_policies.all.empty? }
22
+ folders_with_retention_policies.each do |folder|
23
+ assert folder.retention_policies.all.is_a?(Array)
24
+ end
25
+ end
26
+
27
+ def test_update
28
+ lifetime = "#{(1..300).to_a.sample}d"
29
+ folder = @account.folders.all.reject { |f| f.retention_policies.all.empty? }.sample
30
+ folder.retention_policies.all.each do |rp|
31
+ rp.lifetime = lifetime
32
+ end
33
+ folder.retention_policies.save!
34
+
35
+ folder2 = @account.folders.all!.find { |f| f.id == folder.id }
36
+ folder2.retention_policies.all.each do |rp|
37
+ assert rp.lifetime == lifetime
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,67 @@
1
+ require 'minitest/autorun'
2
+ require 'yaml'
3
+
4
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require './lib/zm/client'
7
+
8
+ class TestSearchFolder < Minitest::Test
9
+
10
+ def setup
11
+ @admin = Zm::Client::Cluster.new(Zm::Client::ClusterConfig.new('./test/fixtures/config.yml'))
12
+ # @admin.logger.debug!
13
+ @admin.login
14
+
15
+ @fixture_accounts = YAML.load(File.read('./test/fixtures/accounts.yml'))
16
+ @account = @admin.accounts.find_by name: @fixture_accounts['accounts']['maxime']['email']
17
+ @account.login
18
+ end
19
+
20
+ def test_all
21
+ search_folders = @account.search_folders.all
22
+ assert search_folders.is_a?(Array)
23
+ end
24
+
25
+ def test_create
26
+ search_folder = @account.search_folders.new do |sf|
27
+ sf.name = "Not read #{Time.now.to_i}"
28
+ sf.query = 'is:unread'
29
+ end
30
+ search_folder.create!
31
+ assert !search_folder.id.nil?
32
+ end
33
+
34
+ def test_modify
35
+ search_folder = @account.search_folders.first
36
+ search_folder.color = (1..5).to_a.sample
37
+ search_folder.query = 'is:unread in:inbox'
38
+ # assert search_folder.color_changed?
39
+ # assert search_folder.query_changed?
40
+
41
+ begin
42
+ is_modified = search_folder.modify!
43
+ rescue StandardError => _
44
+ is_modified = false
45
+ end
46
+
47
+ assert is_modified
48
+ end
49
+
50
+ def test_delete
51
+ search_folder = @account.search_folders.first
52
+ search_folder.delete!
53
+ assert search_folder.id.nil?
54
+ end
55
+
56
+ def test_rename
57
+ search_folder = @account.search_folders.first
58
+ new_name = "Not read #{Time.now.to_i}"
59
+ search_folder.name = new_name
60
+ search_folder.rename!
61
+
62
+ sfs = @account.search_folders.all!
63
+ sf2 = sfs.find { |t| t.name == new_name }
64
+
65
+ assert !sf2.nil?
66
+ end
67
+ end
data/test/signature.rb ADDED
@@ -0,0 +1,53 @@
1
+ require 'minitest/autorun'
2
+ require 'yaml'
3
+
4
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require './lib/zm/client'
7
+
8
+ class TestSignature < Minitest::Test
9
+
10
+ def setup
11
+ @admin = Zm::Client::Cluster.new(Zm::Client::ClusterConfig.new('./test/fixtures/config.yml'))
12
+ # @admin.logger.debug!
13
+ @admin.login
14
+
15
+ @fixture_accounts = YAML.load(File.read('./test/fixtures/accounts.yml'))
16
+ @account = @admin.accounts.find_by name: @fixture_accounts['accounts']['maxime']['email']
17
+ @account.login
18
+ end
19
+
20
+ def test_all
21
+ signatures = @account.signatures.all
22
+ assert signatures.is_a?(Array)
23
+ end
24
+
25
+ def test_create
26
+ signature = @account.signatures.new do |sf|
27
+ sf.name = "test signature #{Time.now.to_i}"
28
+ sf.txt = "ceci est un test de création"
29
+ end
30
+ signature.create!
31
+ assert !signature.id.nil?
32
+ end
33
+
34
+ def test_modify
35
+ signature = @account.signatures.first
36
+ signature.txt = "ceci est un test de modification"
37
+ assert signature.txt_changed?
38
+
39
+ begin
40
+ is_modified = signature.modify!
41
+ rescue StandardError => _
42
+ is_modified = false
43
+ end
44
+
45
+ assert is_modified
46
+ end
47
+
48
+ def test_delete
49
+ signature = @account.signatures.first
50
+ signature.delete!
51
+ assert signature.id.nil?
52
+ end
53
+ end
data/test/tag.rb ADDED
@@ -0,0 +1,65 @@
1
+ require 'minitest/autorun'
2
+ require 'yaml'
3
+
4
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require './lib/zm/client'
7
+
8
+ class TestTAg < Minitest::Test
9
+
10
+ def setup
11
+ @admin = Zm::Client::Cluster.new(Zm::Client::ClusterConfig.new('./test/fixtures/config.yml'))
12
+ # @admin.logger.debug!
13
+ @admin.login
14
+
15
+ @fixture_accounts = YAML.load(File.read('./test/fixtures/accounts.yml'))
16
+ @account = @admin.accounts.find_by name: @fixture_accounts['accounts']['maxime']['email']
17
+ @account.login
18
+ end
19
+
20
+ def test_all
21
+ tags = @account.tags.all
22
+ assert tags.is_a?(Array)
23
+ end
24
+
25
+ def test_create
26
+ tag = @account.tags.new do |sf|
27
+ sf.name = "test #{Time.now.to_i}"
28
+ sf.color = 4
29
+ end
30
+ tag.create!
31
+ assert !tag.id.nil?
32
+ end
33
+
34
+ def test_modify
35
+ tag = @account.tags.first
36
+ tag.color = (1..5).to_a.sample
37
+
38
+ begin
39
+ is_modified = tag.modify!
40
+ rescue StandardError => _
41
+ is_modified = false
42
+ end
43
+
44
+ assert is_modified
45
+ end
46
+
47
+ def test_delete
48
+ tag = @account.tags.first
49
+ tag.delete!
50
+ assert tag.id.nil?
51
+ end
52
+
53
+ def test_rename
54
+ tag = @account.tags.first
55
+ new_name = "test rename #{Time.now.to_i}"
56
+ tag.name = new_name
57
+ assert tag.name_changed?
58
+ tag.save!
59
+
60
+ tags = @account.tags.all!
61
+ tag2 = tags.find { |t| t.name == new_name }
62
+
63
+ assert !tag2.nil?
64
+ end
65
+ end
@@ -0,0 +1,35 @@
1
+ require 'minitest/autorun'
2
+
3
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require './lib/zm/client'
6
+
7
+ class TestZimbraAttributes < Minitest::Test
8
+
9
+ def setup
10
+
11
+ end
12
+
13
+ def test_all
14
+ zac = Zm::Client::Base::ZimbraAttributesCollection.new
15
+ assert zac.all.is_a?(Array)
16
+ end
17
+
18
+ def test_not_empty
19
+ zac = Zm::Client::Base::ZimbraAttributesCollection.new
20
+ assert !zac.all.empty?
21
+ end
22
+
23
+ def test_all_account
24
+ zac = Zm::Client::Base::ZimbraAttributesCollection.new
25
+ assert !zac.all_account_attrs.empty?
26
+ end
27
+
28
+ def test_all_account_version
29
+ zac = Zm::Client::Base::ZimbraAttributesCollection.new
30
+ version = '8.6.0'
31
+ attrs = zac.all_account_attrs_version(version)
32
+
33
+ assert attrs.length < zac.all_account_attrs.length
34
+ end
35
+ end
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency('curb', ['~> 0.9.7'])
22
22
  s.add_dependency('nokogiri', ['~> 1.10.1'])
23
23
  s.add_dependency('gyoku', ['~> 1.3.1'])
24
+ s.add_dependency('version_sorter', ['~> 2.3.0'])
24
25
  end