Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat add qr code #6

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix test on qr code change
  • Loading branch information
a-maccormack committed Feb 27, 2024
commit c119baeae6a9cb65727a3da8b3002670ac041561
1 change: 1 addition & 0 deletions models/qr-test-data/test-qr-code.html

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion models/template_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package models

import (
"fmt"
"os"

check "gopkg.in/check.v1"
)
Expand Down Expand Up @@ -29,16 +30,26 @@ func (s *ModelsSuite) TestNewTemplateContext(c *check.C) {
RId: "1234567",
}
ctx := mockTemplateContext{
URL: "http://example.com",
URL: "https://example.com",
FromAddress: "From Address <from@example.com>",
}

expectedHTMLFilePath := "./qr-test-data/test-qr-code.html"
expectedHTMLBytes, err := os.ReadFile(expectedHTMLFilePath)
if err != nil {
c.Fatalf("Failed to read new-html.html: %v", err)
}
// Remove extra backslashes from the read string
expectedHTMLString := string(expectedHTMLBytes)

expected := PhishingTemplateContext{
URL: fmt.Sprintf("%s?rid=%s", ctx.URL, r.RId),
BaseURL: ctx.URL,
BaseRecipient: r.BaseRecipient,
TrackingURL: fmt.Sprintf("%s/track?rid=%s", ctx.URL, r.RId),
From: "From Address",
RId: r.RId,
QrCode: expectedHTMLString,
}
expected.Tracker = "<img alt='' style='display: none' src='" + expected.TrackingURL + "'/>"
got, err := NewPhishingTemplateContext(ctx, r.BaseRecipient, r.RId)
Expand Down
Loading