-
Jordan Wright committed 6 years ago1 parent de3c3a2e
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
-
-
1 + package models 2 + 3 + import ( 4 + "fmt" 5 + 6 + check "gopkg.in/check.v1" 7 + ) 8 + 9 + type mockTemplateContext struct { 10 + URL string 11 + FromAddress string 12 + } 13 + 14 + func (m mockTemplateContext) getFromAddress() string { 15 + return m.FromAddress 16 + } 17 + 18 + func (m mockTemplateContext) getBaseURL() string { 19 + return m.URL 20 + } 21 + 22 + func (s *ModelsSuite) TestNewTemplateContext(c *check.C) { 23 + r := Result{ 24 + BaseRecipient: BaseRecipient{ 25 + FirstName: "Foo", 26 + LastName: "Bar", 27 + Email: "[email protected]", 28 + }, 29 + RId: "1234567", 30 + } 31 + ctx := mockTemplateContext{ 32 + URL: "http://example.com", 33 + FromAddress: "From Address <[email protected]>", 34 + } 35 + expected := PhishingTemplateContext{ 36 + URL: fmt.Sprintf("%s?rid=%s", ctx.URL, r.RId), 37 + BaseURL: ctx.URL, 38 + BaseRecipient: r.BaseRecipient, 39 + TrackingURL: fmt.Sprintf("%s/track?rid=%s", ctx.URL, r.RId), 40 + From: "From Address", 41 + RId: r.RId, 42 + } 43 + expected.Tracker = "<img alt='' style='display: none' src='" + expected.TrackingURL + "'/>" 44 + got, err := NewPhishingTemplateContext(ctx, r.BaseRecipient, r.RId) 45 + c.Assert(err, check.Equals, nil) 46 + c.Assert(got, check.DeepEquals, expected) 47 + } 48 +