webspicy 0.20.9 → 0.20.14
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/lib/webspicy/configuration/scope.rb +1 -1
- data/lib/webspicy/tester/fakesendgrid.rb +39 -0
- data/lib/webspicy/tester/fakesendgrid/email.rb +48 -0
- data/lib/webspicy/tester/fakeses/email.rb +22 -7
- data/lib/webspicy/tester/fakesmtp/email.rb +7 -3
- data/lib/webspicy/version.rb +1 -1
- data/spec/unit/configuration/scope/test_each_specification.rb +2 -2
- data/spec/unit/tester/fakesendgrid/test_email.rb +66 -0
- data/spec/unit/tester/fakeses/test_email.rb +28 -5
- data/spec/unit/tester/fakesmtp/test_email.rb +27 -16
- metadata +30 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a89789c42cdaf51eb907eaf6053eef356acff66102ccb1f579bbb2a85168e56
|
4
|
+
data.tar.gz: 8afcba7ec470f2689300f2f9fe4122b7e0e11981617812fc5ce031df213adeb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe767864fe5185515cfc9e20a7e5941ba1907979f86904920811c0c44821b8dcf7901f847b310db703497c83a18278b340b6ba30a018c44233660c82657625ec
|
7
|
+
data.tar.gz: 749a0253312d49f05f46e5bd3022c2b657ddccfa0046fc0bdc70a68028161fc68c6f53d0c8e1b3e1cae00e333eb8b8c6429a3034090f5a1e54ea9b8958e81f2f
|
@@ -22,7 +22,7 @@ module Webspicy
|
|
22
22
|
def _each_specification_file(config, apply_filter = true)
|
23
23
|
folder = config.folder
|
24
24
|
world = config.folder/"world"
|
25
|
-
fs = folder.glob("**/*.yml").reject{|f| f.to_s.start_with?(world.to_s) }
|
25
|
+
fs = folder.glob("**/*.{yml, yaml}").reject{|f| f.to_s.start_with?(world.to_s) }
|
26
26
|
fs = fs.sort
|
27
27
|
fs = fs.select(&to_filter_proc(config.file_filter)) if apply_filter
|
28
28
|
fs.each do |file|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Webspicy
|
2
|
+
class Tester
|
3
|
+
class Fakesendgrid
|
4
|
+
include Webspicy::Support::World::Item
|
5
|
+
|
6
|
+
DEFAULT_OPTIONS = {
|
7
|
+
endpoint: "http://fakesendgrid"
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
12
|
+
end
|
13
|
+
attr_reader :options
|
14
|
+
|
15
|
+
def endpoint
|
16
|
+
options[:endpoint]
|
17
|
+
end
|
18
|
+
|
19
|
+
def clear!
|
20
|
+
res = HTTP.delete("#{endpoint}/api/mails")
|
21
|
+
end
|
22
|
+
|
23
|
+
def emails
|
24
|
+
res = HTTP.get("#{endpoint}/api/mails")
|
25
|
+
JSON.parse(res.body).map{|data| Email.new(data) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def emails_count
|
29
|
+
emails.length
|
30
|
+
end
|
31
|
+
|
32
|
+
def last_email
|
33
|
+
emails.first
|
34
|
+
end
|
35
|
+
|
36
|
+
end # class Fakesendgrid
|
37
|
+
end # class Tester
|
38
|
+
end # module Webspicy
|
39
|
+
require_relative 'fakesendgrid/email'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Webspicy
|
2
|
+
class Tester
|
3
|
+
class Fakesendgrid
|
4
|
+
class Email
|
5
|
+
|
6
|
+
def initialize(data)
|
7
|
+
@data = data
|
8
|
+
end
|
9
|
+
attr_reader :data
|
10
|
+
|
11
|
+
def from
|
12
|
+
@from ||= data['from']['name'] ?
|
13
|
+
"#{data['from']['name']} <#{data['from']['email']}>" :
|
14
|
+
data['from']['email']
|
15
|
+
end
|
16
|
+
|
17
|
+
def to
|
18
|
+
@to ||= data["personalizations"]
|
19
|
+
.select{|h| h.key? "to" }
|
20
|
+
.map{|(h)| h["to"] }
|
21
|
+
.flatten
|
22
|
+
.map{|(h)| h["email"] }
|
23
|
+
end
|
24
|
+
|
25
|
+
def cc
|
26
|
+
@cc ||= data["personalizations"]
|
27
|
+
.select{|h| h.key? "cc" }
|
28
|
+
.map{|(h)| h["cc"] }
|
29
|
+
.flatten
|
30
|
+
.map{|(h)| h["email"] }
|
31
|
+
end
|
32
|
+
|
33
|
+
def bcc
|
34
|
+
@bcc ||= data["personalizations"]
|
35
|
+
.select{|h| h.key? "bcc" }
|
36
|
+
.map{|(h)| h["bcc"] }
|
37
|
+
.flatten
|
38
|
+
.map{|(h)| h["email"] }
|
39
|
+
end
|
40
|
+
|
41
|
+
def subject
|
42
|
+
@subject ||= data["subject"]
|
43
|
+
end
|
44
|
+
|
45
|
+
end # class Email
|
46
|
+
end # class Fakesendgrid
|
47
|
+
end # class Tester
|
48
|
+
end # module Webspicy
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'mail'
|
2
|
+
|
1
3
|
module Webspicy
|
2
4
|
class Tester
|
3
5
|
class Fakeses
|
@@ -9,23 +11,36 @@ module Webspicy
|
|
9
11
|
attr_reader :data
|
10
12
|
|
11
13
|
def from
|
12
|
-
|
14
|
+
email.from
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
17
|
+
def recipients
|
16
18
|
data["body"]
|
17
19
|
.each_pair
|
18
20
|
.select{|(k,v)|
|
19
21
|
k =~ /Destinations.member/
|
20
22
|
}
|
21
|
-
.map{|(k,v)| v }
|
23
|
+
.map{|(k,v)| v.strip }
|
24
|
+
end
|
25
|
+
|
26
|
+
def to
|
27
|
+
email.to
|
22
28
|
end
|
23
29
|
|
24
30
|
def subject
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
email.subject
|
32
|
+
end
|
33
|
+
|
34
|
+
def cc
|
35
|
+
email.cc
|
36
|
+
end
|
37
|
+
|
38
|
+
def bcc
|
39
|
+
recipients - cc - to
|
40
|
+
end
|
41
|
+
|
42
|
+
def email
|
43
|
+
@email ||= Mail.read_from_string(raw_data)
|
29
44
|
end
|
30
45
|
|
31
46
|
def raw_data
|
@@ -16,9 +16,13 @@ module Webspicy
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def to
|
19
|
-
@to ||= data["
|
20
|
-
.
|
21
|
-
|
19
|
+
@to ||= data["to"]["value"]
|
20
|
+
.map{|h| h["address"] }
|
21
|
+
end
|
22
|
+
|
23
|
+
def cc
|
24
|
+
@cc ||= data["cc"]["value"]
|
25
|
+
.map{|h| h["address"] }
|
22
26
|
end
|
23
27
|
|
24
28
|
def reply_to
|
data/lib/webspicy/version.rb
CHANGED
@@ -18,7 +18,7 @@ module Webspicy
|
|
18
18
|
}
|
19
19
|
|
20
20
|
it 'returns all files' do
|
21
|
-
expect(subject.size).to eql(restful_folder.glob('**/*.yml').size)
|
21
|
+
expect(subject.size).to eql(restful_folder.glob('**/*.{yml, yaml}').size)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -59,7 +59,7 @@ module Webspicy
|
|
59
59
|
}
|
60
60
|
|
61
61
|
it 'returns all files' do
|
62
|
-
expect(subject.size).to eql(restful_folder.glob('**/*.yml').size)
|
62
|
+
expect(subject.size).to eql(restful_folder.glob('**/*.{yml, yaml}').size)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'webspicy/tester/fakesendgrid'
|
3
|
+
module Webspicy
|
4
|
+
class Tester
|
5
|
+
class Fakesendgrid
|
6
|
+
describe Email do
|
7
|
+
|
8
|
+
DATA = JSON.parse <<~J
|
9
|
+
{
|
10
|
+
"datetime": "2021-06-02T15:29:27.161Z",
|
11
|
+
"from": {
|
12
|
+
"email": "noreply@webspicy.io",
|
13
|
+
"name": "Webspicy"
|
14
|
+
},
|
15
|
+
"subject": "Hello World",
|
16
|
+
"personalizations": [
|
17
|
+
{
|
18
|
+
"to": [
|
19
|
+
{
|
20
|
+
"email": "someone@world.com"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"email": "someoneelse@world.com"
|
24
|
+
}
|
25
|
+
],
|
26
|
+
"cc": [
|
27
|
+
{
|
28
|
+
"email": "a-cc-recipient@world.com"
|
29
|
+
}
|
30
|
+
],
|
31
|
+
"bcc": [
|
32
|
+
{
|
33
|
+
"email": "a-bcc-recipient@world.com"
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"content": [
|
39
|
+
{
|
40
|
+
"value": "test",
|
41
|
+
"type": "text/plain"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"value": "test <b>test</b> test",
|
45
|
+
"type": "text/html"
|
46
|
+
}
|
47
|
+
]
|
48
|
+
}
|
49
|
+
J
|
50
|
+
|
51
|
+
subject{
|
52
|
+
Email.new(DATA)
|
53
|
+
}
|
54
|
+
|
55
|
+
it 'works as expected' do
|
56
|
+
expect(subject.from).to eql("Webspicy <noreply@webspicy.io>")
|
57
|
+
expect(subject.to).to eql(["someone@world.com", "someoneelse@world.com"])
|
58
|
+
expect(subject.cc).to eql(["a-cc-recipient@world.com"])
|
59
|
+
expect(subject.bcc).to eql(["a-bcc-recipient@world.com"])
|
60
|
+
expect(subject.subject).to eql("Hello World")
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -6,9 +6,27 @@ module Webspicy
|
|
6
6
|
describe Email do
|
7
7
|
|
8
8
|
DATA = Base64.encode64 <<~J
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Content-Type: multipart/alternative;
|
10
|
+
boundary="--_NmP-d246fd025a6652c9-Part_1"
|
11
|
+
From: Webspicy <noreply@webspicy.io>
|
12
|
+
To: someone@world.com, someoneelse@world.com
|
13
|
+
CC: a-cc-recipient@world.com
|
14
|
+
Subject: Hey world, hello!
|
15
|
+
Message-ID: <2421bae3-9c42-7988-23b4-b1f6168130c9@webspicy.io>
|
16
|
+
Date: Thu, 24 Jun 2021 13:45:16 +0000
|
17
|
+
MIME-Version: 1.0
|
18
|
+
|
19
|
+
----_NmP-d246fd025a6652c9-Part_1
|
20
|
+
Content-Type: text/plain; charset=utf-8
|
21
|
+
Content-Transfer-Encoding: 7bit
|
22
|
+
|
23
|
+
Hello world, in a text version
|
24
|
+
----_NmP-d246fd025a6652c9-Part_1
|
25
|
+
Content-Type: text/html; charset=utf-8
|
26
|
+
Content-Transfer-Encoding: 7bit
|
27
|
+
|
28
|
+
Hello world, in an html version
|
29
|
+
----_NmP-d246fd025a6652c9-Part_1--
|
12
30
|
J
|
13
31
|
|
14
32
|
DATA = JSON.parse <<~J
|
@@ -17,6 +35,9 @@ module Webspicy
|
|
17
35
|
"body": {
|
18
36
|
"Source": "noreply@webspicy.io",
|
19
37
|
"Destinations.member.1": "someone@world.com",
|
38
|
+
"Destinations.member.2": "someoneelse@world.com",
|
39
|
+
"Destinations.member.3": "a-cc-recipient@world.com",
|
40
|
+
"Destinations.member.4": "a-bcc-recipient@world.com",
|
20
41
|
"RawMessage.Data": "#{DATA.gsub /\n/, ''}",
|
21
42
|
"Action": "SendRawEmail",
|
22
43
|
"Version": "2010-12-01"
|
@@ -29,8 +50,10 @@ module Webspicy
|
|
29
50
|
}
|
30
51
|
|
31
52
|
it 'works as expected' do
|
32
|
-
expect(subject.from).to eql("noreply@webspicy.io")
|
33
|
-
expect(subject.to).to eql(["someone@world.com"])
|
53
|
+
expect(subject.from).to eql(["noreply@webspicy.io"])
|
54
|
+
expect(subject.to).to eql(["someone@world.com", "someoneelse@world.com"])
|
55
|
+
expect(subject.cc).to eql(["a-cc-recipient@world.com"])
|
56
|
+
expect(subject.bcc).to eql(["a-bcc-recipient@world.com"])
|
34
57
|
expect(subject.subject).to eql("Hey world, hello!")
|
35
58
|
end
|
36
59
|
|
@@ -15,15 +15,19 @@ module Webspicy
|
|
15
15
|
},
|
16
16
|
{
|
17
17
|
"key": "from",
|
18
|
-
"line": "From:
|
18
|
+
"line": "From: Webspicy <noreply@webspicy.io>"
|
19
19
|
},
|
20
20
|
{
|
21
21
|
"key": "reply-to",
|
22
|
-
"line": "Reply-To:
|
22
|
+
"line": "Reply-To: noreply@webspicy.io"
|
23
23
|
},
|
24
24
|
{
|
25
25
|
"key": "to",
|
26
|
-
"line": "To:
|
26
|
+
"line": "To: someone@world.com, someoneelse@world.com"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"key": "cc",
|
30
|
+
"line": "Cc: a-cc-recipient@world.com"
|
27
31
|
},
|
28
32
|
{
|
29
33
|
"key": "message-id",
|
@@ -46,12 +50,14 @@ module Webspicy
|
|
46
50
|
"to": {
|
47
51
|
"value": [
|
48
52
|
{
|
49
|
-
"address": "
|
53
|
+
"address": "someone@world.com",
|
54
|
+
"name": ""
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"address": "someoneelse@world.com",
|
50
58
|
"name": ""
|
51
59
|
}
|
52
|
-
]
|
53
|
-
"html": "<span class=\\"mp_address_group\\"><a href=\\"mailto:support@mydomain.fr\\" class=\\"mp_address_email\\">support@mydomain.fr</a></span>",
|
54
|
-
"text": "support@mydomain.fr"
|
60
|
+
]
|
55
61
|
},
|
56
62
|
"from": {
|
57
63
|
"value": [
|
@@ -59,20 +65,24 @@ module Webspicy
|
|
59
65
|
"address": "info@mydomain.be",
|
60
66
|
"name": ""
|
61
67
|
}
|
62
|
-
]
|
63
|
-
"html": "<span class=\\"mp_address_group\\"><a href=\\"mailto:info@mydomain.be\\" class=\\"mp_address_email\\">info@mydomain.be</a></span>",
|
64
|
-
"text": "info@mydomain.be"
|
68
|
+
]
|
65
69
|
},
|
66
70
|
"messageId": "<607edfd56836e_1b0492af@1d3356d02030.mail>",
|
67
71
|
"replyTo": {
|
68
72
|
"value": [
|
69
73
|
{
|
70
|
-
"address": "
|
74
|
+
"address": "noreply@webspicy.io",
|
75
|
+
"name": ""
|
76
|
+
}
|
77
|
+
]
|
78
|
+
},
|
79
|
+
"cc": {
|
80
|
+
"value": [
|
81
|
+
{
|
82
|
+
"address": "a-cc-recipient@world.com",
|
71
83
|
"name": ""
|
72
84
|
}
|
73
|
-
]
|
74
|
-
"html": "<span class=\\"mp_address_group\\"><a href=\\"mailto:test@email.be\\" class=\\"mp_address_email\\">test@email.be</a></span>",
|
75
|
-
"text": "test@email.be"
|
85
|
+
]
|
76
86
|
}
|
77
87
|
}
|
78
88
|
J
|
@@ -82,8 +92,9 @@ module Webspicy
|
|
82
92
|
}
|
83
93
|
|
84
94
|
it 'works as expected' do
|
85
|
-
expect(subject.from).to eql("
|
86
|
-
expect(subject.to).to eql(["
|
95
|
+
expect(subject.from).to eql("Webspicy <noreply@webspicy.io>")
|
96
|
+
expect(subject.to).to eql(["someone@world.com", "someoneelse@world.com"])
|
97
|
+
expect(subject.cc).to eql(["a-cc-recipient@world.com"])
|
87
98
|
expect(subject.subject).to eql("Hello World")
|
88
99
|
end
|
89
100
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webspicy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: http
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 4.4.1
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 4.4.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: path
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,22 +126,22 @@ dependencies:
|
|
126
126
|
name: rack-robustness
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.1.0
|
132
129
|
- - "~>"
|
133
130
|
- !ruby/object:Gem::Version
|
134
131
|
version: '1.1'
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 1.1.0
|
135
135
|
type: :runtime
|
136
136
|
prerelease: false
|
137
137
|
version_requirements: !ruby/object:Gem::Requirement
|
138
138
|
requirements:
|
139
|
-
- - ">="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 1.1.0
|
142
139
|
- - "~>"
|
143
140
|
- !ruby/object:Gem::Version
|
144
141
|
version: '1.1'
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 1.1.0
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: mustermann
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,6 +212,20 @@ dependencies:
|
|
212
212
|
- - "~>"
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '1.0'
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: mail
|
217
|
+
requirement: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - "~>"
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '2.7'
|
222
|
+
type: :runtime
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - "~>"
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '2.7'
|
215
229
|
description: Webspicy helps testing web services as software operation black boxes
|
216
230
|
email: blambeau@gmail.com
|
217
231
|
executables:
|
@@ -261,6 +275,8 @@ files:
|
|
261
275
|
- lib/webspicy/tester/assertions.rb
|
262
276
|
- lib/webspicy/tester/client.rb
|
263
277
|
- lib/webspicy/tester/failure.rb
|
278
|
+
- lib/webspicy/tester/fakesendgrid.rb
|
279
|
+
- lib/webspicy/tester/fakesendgrid/email.rb
|
264
280
|
- lib/webspicy/tester/fakeses.rb
|
265
281
|
- lib/webspicy/tester/fakeses/email.rb
|
266
282
|
- lib/webspicy/tester/fakesmtp.rb
|
@@ -323,6 +339,7 @@ files:
|
|
323
339
|
- spec/unit/support/world/fixtures/yaml.yml
|
324
340
|
- spec/unit/support/world/test_world.rb
|
325
341
|
- spec/unit/test_configuration.rb
|
342
|
+
- spec/unit/tester/fakesendgrid/test_email.rb
|
326
343
|
- spec/unit/tester/fakeses/test_email.rb
|
327
344
|
- spec/unit/tester/fakesmtp/test_email.rb
|
328
345
|
- spec/unit/tester/test_asserter.rb
|
@@ -352,7 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
352
369
|
- !ruby/object:Gem::Version
|
353
370
|
version: '0'
|
354
371
|
requirements: []
|
355
|
-
rubygems_version: 3.
|
372
|
+
rubygems_version: 3.2.15
|
356
373
|
signing_key:
|
357
374
|
specification_version: 4
|
358
375
|
summary: Webspicy helps testing web services as software operation black boxes!
|