mailinator_client 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/LICENSE +1 -1
- data/README.md +13 -1
- data/docs/domains.md +26 -0
- data/docs/messages.md +170 -14
- data/lib/mailinator_client/client.rb +12 -2
- data/lib/mailinator_client/domains.rb +60 -1
- data/lib/mailinator_client/error.rb +1 -1
- data/lib/mailinator_client/messages.rb +327 -16
- data/lib/mailinator_client/rules.rb +1 -1
- data/lib/mailinator_client/stats.rb +1 -1
- data/lib/mailinator_client/utils.rb +1 -1
- data/lib/mailinator_client/version.rb +25 -25
- data/lib/mailinator_client.rb +3 -1
- data/mailinator_client.gemspec +25 -25
- data/test/mailinator_client_api_test.rb +125 -25
- metadata +6 -8
@@ -11,12 +11,33 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
11
11
|
@messageIdWithAttachment = "MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"
|
12
12
|
@attachmentId = "MAILINATOR_TEST_ATTACHMENT_ID"
|
13
13
|
@deleteDomain = "MAILINATOR_TEST_DELETE_DOMAIN"
|
14
|
+
@webhookTokenPrivateDomain= "MAILINATOR_TEST_WEBHOOKTOKEN_PRIVATEDOMAIN"
|
15
|
+
@webhookTokenCustomService = "MAILINATOR_TEST_WEBHOOKTOKEN_CUSTOMSERVICE"
|
16
|
+
@authSecret = "MAILINATOR_TEST_AUTH_SECRET"
|
17
|
+
@authId = "MAILINATOR_TEST_AUTH_ID"
|
18
|
+
@webhookInbox = "MAILINATOR_TEST_WEBHOOK_INBOX"
|
19
|
+
@webhookCustomService = "MAILINATOR_TEST_WEBHOOK_CUSTOMSERVICE"
|
14
20
|
end
|
15
21
|
|
16
22
|
it "should correctly do manipulation with mailinator data" do
|
17
23
|
|
18
24
|
client = MailinatorClient::Client.new(auth_token: @auth_token)
|
19
25
|
|
26
|
+
response = client.authenticators.instant_totp_2fa_code(totpSecretKey: @authSecret)
|
27
|
+
assert response != nil, "Expected instant totp 2fa code response to not be nil"
|
28
|
+
|
29
|
+
response = client.authenticators.get_authenticators()
|
30
|
+
assert response != nil, "Expected get authenticators response to not be nil"
|
31
|
+
|
32
|
+
response = client.authenticators.get_authenticators_by_id(id: @authId)
|
33
|
+
assert response != nil, "Expected get authenticators by id response to not be nil"
|
34
|
+
|
35
|
+
response = client.authenticators.get_authenticator()
|
36
|
+
assert response != nil, "Expected get authenticator response to not be nil"
|
37
|
+
|
38
|
+
response = client.authenticators.get_authenticator_by_id(id: @authId)
|
39
|
+
assert response != nil, "Expected get authenticator by id response to not be nil"
|
40
|
+
|
20
41
|
response = client.domains.get_domains
|
21
42
|
assert response != nil, "Expected get domains response to not be nil"
|
22
43
|
assert response["domains"] != nil, "Expected response domains to not be nil"
|
@@ -24,13 +45,24 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
24
45
|
@domainId = @domain["_id"]
|
25
46
|
@domainName = @domain["name"]
|
26
47
|
|
27
|
-
response = client.domains.get_domain(domainId:@
|
48
|
+
response = client.domains.get_domain(domainId:@domainName)
|
28
49
|
assert response != nil, "Expected get domain response to not be nil"
|
29
50
|
|
51
|
+
@domainNameToAdd = "testruby.testinator.com"
|
52
|
+
|
53
|
+
response = client.domains.create_domain(domainId:@domainNameToAdd)
|
54
|
+
assert response != nil, "Expected create domain response to not be nil"
|
55
|
+
#assert response["status"] == "ok", "Expected create domain response to be ok"
|
56
|
+
|
57
|
+
response = client.domains.delete_domain(domainId:@domainNameToAdd)
|
58
|
+
assert response != nil, "Expected delete domain response to not be nil"
|
59
|
+
#assert response["status"] == "ok", "Expected delete domain response to be ok"
|
60
|
+
|
61
|
+
random_string = SecureRandom.hex(4)
|
30
62
|
ruleToPost = {
|
31
|
-
name: "
|
63
|
+
name: "RuleName_RubyTest_#{random_string}",
|
32
64
|
priority: 15,
|
33
|
-
description: "
|
65
|
+
description: "Description_RubyTest_#{random_string}",
|
34
66
|
conditions: [
|
35
67
|
{
|
36
68
|
operation: "PREFIX",
|
@@ -52,54 +84,94 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
52
84
|
]
|
53
85
|
}
|
54
86
|
|
55
|
-
response = client.rules.create_rule(domainId:@
|
87
|
+
response = client.rules.create_rule(domainId:@domainName, ruleToPost: ruleToPost)
|
56
88
|
assert response != nil, "Expected get create rule response to not be nil"
|
57
89
|
assert response["_id"] != nil, "Expected response rule id to not be nil"
|
58
90
|
|
59
|
-
response = client.rules.get_all_rules(domainId:@
|
91
|
+
response = client.rules.get_all_rules(domainId:@domainName)
|
60
92
|
assert response != nil, "Expected get all rules response to not be nil"
|
61
93
|
assert response["rules"] != nil, "Expected response rules to not be nil"
|
62
94
|
@rule = response["rules"][0]
|
63
95
|
@ruleId = @rule["_id"]
|
64
96
|
|
65
|
-
response = client.rules.enable_rule(domainId:@
|
97
|
+
response = client.rules.enable_rule(domainId:@domainName, ruleId: @ruleId)
|
66
98
|
assert response != nil, "Expected enable rule response to not be nil"
|
67
99
|
assert response["status"] == "ok", "Expected enable rule response to be ok"
|
68
100
|
|
69
|
-
response = client.rules.disable_rule(domainId:@
|
101
|
+
response = client.rules.disable_rule(domainId:@domainName, ruleId: @ruleId)
|
70
102
|
assert response != nil, "Expected disable rule response to not be nil"
|
71
103
|
assert response["status"] == "ok", "Expected disable rule response to be ok"
|
72
104
|
|
73
|
-
response = client.rules.get_rule(domainId:@
|
105
|
+
response = client.rules.get_rule(domainId:@domainName, ruleId: @ruleId)
|
74
106
|
assert response != nil, "Expected disable rule response to not be nil"
|
75
|
-
assert response["_id"] != nil, "Expected get rule response to not be nil"
|
107
|
+
assert response["_id"] != nil, "Expected get rule response id to not be nil"
|
76
108
|
|
77
109
|
response = client.rules.delete_rule(domainId:@deleteDomain, ruleId: @ruleId)
|
78
110
|
assert response != nil, "Expected delete rule response to not be nil"
|
79
111
|
assert response["status"] == "ok", "Expected delete rule response to be ok"
|
80
112
|
|
113
|
+
messageToPost = {
|
114
|
+
subject:"Testing ruby message",
|
115
|
+
from:"test_email_ruby@test.com",
|
116
|
+
text:"I love Ruby!"
|
117
|
+
}
|
118
|
+
response = client.messages.post_message(domain:@domainName, inbox: @inboxAll, messageToPost: messageToPost)
|
119
|
+
assert response != nil, "Expected post message response to not be nil"
|
120
|
+
assert response["status"] == "ok", "Expected post message response to be ok"
|
121
|
+
|
81
122
|
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, skip: 0, limit: 50, sort: "ascending", decodeSubject: false)
|
82
123
|
assert response != nil, "Expected fetch inbox response to not be nil"
|
83
124
|
assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
|
84
125
|
@message = response["msgs"][0]
|
85
126
|
@messageId = @message["id"]
|
86
127
|
|
87
|
-
response = client.messages.
|
128
|
+
response = client.messages.fetch_inbox_message(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
129
|
+
assert response != nil, "Expected fetch inbox message response to not be nil"
|
130
|
+
|
131
|
+
response = client.messages.fetch_message(domain:@domainName, messageId: @messageId)
|
88
132
|
assert response != nil, "Expected fetch message response to not be nil"
|
89
133
|
|
90
|
-
response = client.messages.fetch_sms_message(domain:@domainName,
|
134
|
+
response = client.messages.fetch_sms_message(domain:@domainName, teamSmsNumber: @teamSMSNumber)
|
91
135
|
assert response != nil, "Expected fetch sms message response to not be nil"
|
92
136
|
|
93
|
-
response = client.messages.
|
94
|
-
assert response != nil, "Expected fetch attachments response to not be nil"
|
137
|
+
response = client.messages.fetch_inbox_message_attachments(domain:@domainName, inbox: @inbox, messageId: @messageIdWithAttachment)
|
138
|
+
assert response != nil, "Expected fetch inbox message attachments response to not be nil"
|
139
|
+
|
140
|
+
response = client.messages.fetch_message_attachments(domain:@domainName, messageId: @messageIdWithAttachment)
|
141
|
+
assert response != nil, "Expected fetch message attachments response to not be nil"
|
95
142
|
|
96
|
-
response = client.messages.
|
97
|
-
assert response != nil, "Expected fetch attachment response to not be nil"
|
143
|
+
response = client.messages.fetch_inbox_message_attachment(domain:@domainName, inbox: @inbox, messageId: @messageIdWithAttachment, attachmentId: @attachmentId)
|
144
|
+
assert response != nil, "Expected fetch inbox message attachment response to not be nil"
|
98
145
|
|
99
|
-
response = client.messages.
|
146
|
+
response = client.messages.fetch_message_attachment(domain:@domainName, messageId: @messageIdWithAttachment, attachmentId: @attachmentId)
|
147
|
+
assert response != nil, "Expected fetch message attachment response to not be nil"
|
148
|
+
|
149
|
+
response = client.messages.fetch_message_links(domain:@domainName, messageId: @messageId)
|
100
150
|
assert response != nil, "Expected fetch message links response to not be nil"
|
101
151
|
assert response["links"] != nil, "Expected fetch message links links response to not be nil"
|
152
|
+
|
153
|
+
response = client.messages.fetch_inbox_message_links(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
154
|
+
assert response != nil, "Expected fetch inbox message links response to not be nil"
|
155
|
+
assert response["links"] != nil, "Expected fetch inbox message links links response to not be nil"
|
102
156
|
|
157
|
+
response = client.messages.fetch_message_smtp_log(domain:@domainName, messageId: @messageId)
|
158
|
+
assert response != nil, "Expected fetch message smtp log response to not be nil"
|
159
|
+
|
160
|
+
response = client.messages.fetch_inbox_message_smtp_log(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
161
|
+
assert response != nil, "Expected fetch inbox message smtp log response to not be nil"
|
162
|
+
|
163
|
+
response = client.messages.fetch_message_raw(domain:@domainName, messageId: @messageId)
|
164
|
+
assert response != nil, "Expected fetch message raw response to not be nil"
|
165
|
+
|
166
|
+
response = client.messages.fetch_inbox_message_raw(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
167
|
+
assert response != nil, "Expected fetch inbox message raw response to not be nil"
|
168
|
+
|
169
|
+
response = client.messages.fetch_latest_messages(domain:@domainName)
|
170
|
+
assert response != nil, "Expected fetch latest messages response to not be nil"
|
171
|
+
|
172
|
+
response = client.messages.fetch_latest_inbox_messages(domain:@domainName, inbox: @inboxAll)
|
173
|
+
assert response != nil, "Expected fetch latest inbox message response to not be nil"
|
174
|
+
|
103
175
|
response = client.messages.delete_message(domain:@deleteDomain, inbox: @inbox, messageId: @messageId)
|
104
176
|
assert response != nil, "Expected delete message response to not be nil"
|
105
177
|
assert response["status"] == "ok", "Expected delete message response to be ok"
|
@@ -112,21 +184,49 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
112
184
|
assert response != nil, "Expected delete all domain messages response to not be nil"
|
113
185
|
assert response["status"] == "ok", "Expected delete all domain messages response to be ok"
|
114
186
|
|
115
|
-
messageToPost = {
|
116
|
-
subject:"Testing ruby message",
|
117
|
-
from:"test_email_ruby@test.com",
|
118
|
-
text:"I love Ruby!"
|
119
|
-
}
|
120
|
-
response = client.messages.inject_message(domain:@domainName, inbox: @inboxAll, messageToPost: messageToPost)
|
121
|
-
assert response != nil, "Expected inject message response to not be nil"
|
122
|
-
assert response["status"] == "ok", "Expected inject message response to be ok"
|
123
|
-
|
124
187
|
response = client.stats.get_team_stats
|
125
188
|
assert response != nil, "Expected response to not be nil"
|
126
189
|
assert response["stats"] != nil, "Expected response stats to not be nil"
|
127
190
|
|
128
191
|
response = client.stats.get_team
|
129
192
|
assert response != nil, "Expected response to not be nil"
|
193
|
+
|
194
|
+
webhook = {
|
195
|
+
from:"MyMailinatorRubyTest",
|
196
|
+
subject:"testing message",
|
197
|
+
text:"hello world",
|
198
|
+
to:"jack"
|
199
|
+
}
|
200
|
+
|
201
|
+
clientWithoutAuthToken = MailinatorClient::Client.new()
|
202
|
+
response = clientWithoutAuthToken.webhooks.public_webhook(webhook:webhook)
|
203
|
+
assert response != nil, "Expected public webhook response to not be nil"
|
204
|
+
assert response["status"] == "ok", "Expected public webhook response to be ok"
|
205
|
+
|
206
|
+
response = clientWithoutAuthToken.webhooks.public_inbox_webhook(inbox: @webhookInbox, webhook:webhook)
|
207
|
+
assert response != nil, "Expected public inbox webhook response to not be nil"
|
208
|
+
assert response["status"] == "ok", "Expected public inbox webhook response to be ok"
|
209
|
+
|
210
|
+
response = clientWithoutAuthToken.webhooks.public_custom_service_webhook(customService: @webhookCustomService, webhook:webhook)
|
211
|
+
#assert response != nil, "Expected public custom service webhook response to not be nil"
|
212
|
+
|
213
|
+
response = clientWithoutAuthToken.webhooks.public_custom_service_inbox_webhook(customService: @webhookCustomService, inbox: @webhookInbox, webhook:webhook)
|
214
|
+
#assert response != nil, "Expected public custom service inbox webhook response to not be nil"
|
215
|
+
|
216
|
+
response = clientWithoutAuthToken.webhooks.private_webhook(whToken: @webhookTokenPrivateDomain, webhook:webhook)
|
217
|
+
assert response != nil, "Expected private webhook status response to not be nil"
|
218
|
+
assert response["status"] == "ok", "Expected private webhook response to be ok"
|
219
|
+
|
220
|
+
response = clientWithoutAuthToken.webhooks.private_inbox_webhook(whToken: @webhookTokenPrivateDomain, inbox: @webhookInbox, webhook:webhook)
|
221
|
+
assert response != nil, "Expected private inbox webhook response to not be nil"
|
222
|
+
assert response["status"] == "ok", "Expected private inbox webhook response to be ok"
|
223
|
+
|
224
|
+
response = clientWithoutAuthToken.webhooks.private_custom_service_webhook(whToken: @webhookTokenPrivateDomain, customService: @webhookCustomService, webhook:webhook)
|
225
|
+
#assert response != nil, "Expected private custom service webhook response to not be nil"
|
226
|
+
|
227
|
+
response = clientWithoutAuthToken.webhooks.private_custom_service_inbox_webhook(whToken: @webhookTokenPrivateDomain, customService: @webhookCustomService, inbox: @webhookInbox, webhook:webhook)
|
228
|
+
#assert response != nil, "Expected private custom service inbox webhook response to not be nil"
|
229
|
+
|
130
230
|
end
|
131
231
|
end
|
132
232
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailinator_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marian Melnychuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.21.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.21.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,10 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.4.19
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Provides a simple ruby wrapper around the Mailinator REST API
|
123
|
-
test_files:
|
124
|
-
- test/mailinator_client_api_test.rb
|
125
|
-
- test/test_helper.rb
|
123
|
+
test_files: []
|