-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathinvite_meeting_test.go
55 lines (43 loc) · 2.31 KB
/
invite_meeting_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package gui
import (
"github.com/digitalautonomy/wahay/hosting"
. "gopkg.in/check.v1"
)
type WahayInviteMeetingSuite struct{}
var _ = Suite(&WahayInviteMeetingSuite{})
func (s *WahayInviteMeetingSuite) Test_InviteMeeting_extractMeetingIDandPort_SucceedIfValidUrl(c *C) {
h1, p1, e1 := extractMeetingIDandPort("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid.onion")
h2, p2, e2 := extractMeetingIDandPort("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid.onion:8080")
c.Assert(h1, Equals, "qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid.onion")
c.Assert(p1, Equals, hosting.DefaultPort)
c.Assert(e1, Equals, nil)
c.Assert(h2, Equals, "qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid.onion")
c.Assert(p2, Equals, 8080)
c.Assert(e2, Equals, nil)
}
func (s *WahayInviteMeetingSuite) Test_InviteMeeting_extractMeetingIDandPort_FailsIfNoValidUrl(c *C) {
_, _, e1 := extractMeetingIDandPort("aaabbbcccddd.onion")
_, _, e2 := extractMeetingIDandPort("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid:8080")
_, _, e3 := extractMeetingIDandPort("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid")
_, _, e4 := extractMeetingIDandPort("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid.onion:aaaa")
c.Assert(e1, ErrorMatches, "invalid meeting address")
c.Assert(e2, ErrorMatches, "invalid meeting address")
c.Assert(e3, ErrorMatches, "invalid meeting address")
c.Assert(e4, ErrorMatches, "invalid meeting address")
}
func (s *WahayInviteMeetingSuite) Test_InviteMeeting_isAValidMeetingID_SucceedIfValidUrl(c *C) {
v1 := isAValidMeetingID("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid.onion")
v2 := isAValidMeetingID("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid.onion:8080")
v3 := isAValidMeetingID("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid.onion:4100")
c.Assert(v1, Equals, true)
c.Assert(v2, Equals, true)
c.Assert(v3, Equals, true)
}
func (s *WahayInviteMeetingSuite) Test_InviteMeeting_isAValidMeetingID_FailsIfNoValidUrl(c *C) {
v1 := isAValidMeetingID("aaabbbcccddd.onion")
v2 := isAValidMeetingID("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid:8080")
v3 := isAValidMeetingID("qvdjpoqcg572ibylv673qr76iwashlazh6spm47ly37w65iwwmkbmtid")
c.Assert(v1, Equals, false)
c.Assert(v2, Equals, false)
c.Assert(v3, Equals, false)
}