@@ -11,6 +11,7 @@ func AssertRemoteUrlEquals(t *testing.T, expected *Remote, remotUrl string) {
11
11
actual , err := ParseRemote (remotUrl )
12
12
assert .Nil (t , err )
13
13
assert .NotNil (t , actual )
14
+ assert .Equal (t , expected .Scheme , actual .Scheme , "Scheme %s" , remotUrl )
14
15
assert .Equal (t , expected .Addr , actual .Addr , "Addr %s" , remotUrl )
15
16
assert .Equal (t , expected .Hostname , actual .Hostname , "Hostname %s" , remotUrl )
16
17
assert .Equal (t , expected .Port , actual .Port , "Port %s" , remotUrl )
@@ -26,6 +27,7 @@ func AssertRemoteUrlEquals(t *testing.T, expected *Remote, remotUrl string) {
26
27
27
28
func TestValidRemoteUrls (t * testing.T ) {
28
29
AssertRemoteUrlEquals (t , & Remote {
30
+ Scheme : "smtp" ,
29
31
SkipVerify : false ,
30
32
Auth : nil ,
31
33
Hostname : "email.com" ,
@@ -35,6 +37,7 @@ func TestValidRemoteUrls(t *testing.T) {
35
37
}, "smtp://email.com" )
36
38
37
39
AssertRemoteUrlEquals (t , & Remote {
40
+ Scheme : "smtp" ,
38
41
SkipVerify : true ,
39
42
Auth : nil ,
40
43
Hostname : "email.com" ,
@@ -44,6 +47,7 @@ func TestValidRemoteUrls(t *testing.T) {
44
47
}, "smtp://email.com?skipVerify" )
45
48
46
49
AssertRemoteUrlEquals (t , & Remote {
50
+ Scheme : "smtp" ,
47
51
SkipVerify : false ,
48
52
Auth : smtp .PlainAuth ("" , "user" , "pass" , "" ),
49
53
Hostname : "email.com" ,
@@ -53,6 +57,7 @@ func TestValidRemoteUrls(t *testing.T) {
53
57
},
"smtp://user:[email protected] " )
54
58
55
59
AssertRemoteUrlEquals (t , & Remote {
60
+ Scheme : "smtp" ,
56
61
SkipVerify : false ,
57
62
Auth : LoginAuth ("user" , "pass" ),
58
63
Hostname : "email.com" ,
@@ -62,6 +67,7 @@ func TestValidRemoteUrls(t *testing.T) {
62
67
},
"smtp://user:[email protected] ?auth=login" )
63
68
64
69
AssertRemoteUrlEquals (t , & Remote {
70
+ Scheme : "smtp" ,
65
71
SkipVerify : false ,
66
72
Auth : LoginAuth ("user" , "pass" ),
67
73
Hostname : "email.com" ,
@@ -71,6 +77,7 @@ func TestValidRemoteUrls(t *testing.T) {
71
77
72
78
73
79
AssertRemoteUrlEquals (t , & Remote {
80
+ Scheme : "smtps" ,
74
81
SkipVerify : false ,
75
82
Auth : LoginAuth ("user" , "pass" ),
76
83
Hostname : "email.com" ,
@@ -80,11 +87,28 @@ func TestValidRemoteUrls(t *testing.T) {
80
87
81
88
82
89
AssertRemoteUrlEquals (t , & Remote {
90
+ Scheme : "smtps" ,
83
91
SkipVerify : true ,
84
92
Auth : LoginAuth ("user" , "pass" ),
85
93
Hostname : "email.com" ,
86
94
Port : "8425" ,
87
95
Addr : "email.com:8425" ,
88
96
89
- },
"smtp://user:[email protected] :8425/[email protected] ?auth=login&skipVerify" )
97
+ },
"smtps://user:[email protected] :8425/[email protected] ?auth=login&skipVerify" )
98
+
99
+ AssertRemoteUrlEquals (t , & Remote {
100
+ Scheme : "starttls" ,
101
+ SkipVerify : true ,
102
+ Auth : LoginAuth ("user" , "pass" ),
103
+ Hostname : "email.com" ,
104
+ Port : "8425" ,
105
+ Addr : "email.com:8425" ,
106
+
107
+ },
"starttls://user:[email protected] :8425/[email protected] ?auth=login&skipVerify" )
108
+ }
109
+
110
+ func TestMissingScheme (t * testing.T ) {
111
+ _ ,
err := ParseRemote (
"http://user:[email protected] :8425/[email protected] " )
112
+ assert .NotNil (t , err , "Err must be present" )
113
+ assert .Equal (t , err .Error (), "'http' is not a supported relay scheme" )
90
114
}
0 commit comments