Skip to content

Commit

Permalink
URL3
Browse files Browse the repository at this point in the history
  • Loading branch information
vtopc committed Dec 25, 2024
1 parent 636093a commit 804e2db
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion attachments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func createAttachment(t *testing.T) string {

func TestMultipleAttachments(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

var ctx = context.Background()

Expand Down
8 changes: 4 additions & 4 deletions bounces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func TestGetBounces(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
it := mg.ListBounces(testDomain, nil)
Expand All @@ -31,7 +31,7 @@ func TestGetBounces(t *testing.T) {

func TestGetSingleBounce(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
exampleEmail := fmt.Sprintf("%s@%s", strings.ToLower(randomString(64, "")),
Expand All @@ -46,7 +46,7 @@ func TestGetSingleBounce(t *testing.T) {

func TestAddDelBounces(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

findBounce := func(address string) bool {
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestAddDelBounces(t *testing.T) {

func TestAddDelBounceList(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()

Expand Down
4 changes: 2 additions & 2 deletions credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestGetCredentials(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
it := mg.ListCredentials(testDomain, nil)
Expand All @@ -29,7 +29,7 @@ func TestGetCredentials(t *testing.T) {

func TestCreateDeleteCredentials(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

randomPassword := randomString(16, "pw")
randomID := strings.ToLower(randomString(16, "usr"))
Expand Down
20 changes: 10 additions & 10 deletions domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (

func TestListDomains(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

it := mg.ListDomains(nil)
Expand All @@ -35,7 +35,7 @@ func TestListDomains(t *testing.T) {

func TestGetSingleDomain(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

it := mg.ListDomains(nil)
Expand All @@ -59,7 +59,7 @@ func TestGetSingleDomain(t *testing.T) {

func TestGetSingleDomainNotExist(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
_, err := mg.GetDomain(ctx, "unknown.domain")
Expand All @@ -73,7 +73,7 @@ func TestGetSingleDomainNotExist(t *testing.T) {

func TestAddUpdateDeleteDomain(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

// First, we need to add the domain.
Expand All @@ -92,7 +92,7 @@ func TestAddUpdateDeleteDomain(t *testing.T) {

func TestDomainConnection(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

info, err := mg.GetDomainConnection(ctx, testDomain)
Expand All @@ -113,7 +113,7 @@ func TestDomainConnection(t *testing.T) {

func TestDomainTracking(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

info, err := mg.GetDomainTracking(ctx, testDomain)
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestDomainTracking(t *testing.T) {

func TestDomainVerify(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

_, err := mg.VerifyDomain(ctx, testDomain)
Expand All @@ -163,7 +163,7 @@ func TestDomainVerify(t *testing.T) {

func TestDomainVerifyAndReturn(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

_, err := mg.VerifyAndReturnDomain(ctx, testDomain)
Expand All @@ -172,7 +172,7 @@ func TestDomainVerifyAndReturn(t *testing.T) {

func TestDomainDkimSelector(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

// Update Domain DKIM selector
Expand All @@ -182,7 +182,7 @@ func TestDomainDkimSelector(t *testing.T) {

func TestDomainTrackingWebPrefix(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

// Update Domain Tracking Web Prefix
Expand Down
6 changes: 3 additions & 3 deletions events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func TestEventIteratorGetNext(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

it := mg.ListEvents(testDomain, &mailgun.ListEventOptions{Limit: 5})

Expand Down Expand Up @@ -63,7 +63,7 @@ func TestEventIteratorGetNext(t *testing.T) {

func TestEventPoller(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

// Very short poll interval
it := mg.PollEvents(testDomain, &mailgun.ListEventOptions{
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestEventPoller(t *testing.T) {

func ExampleMailgunImpl_ListEvents() {
mg := mailgun.NewMailgun("your-api-key")
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

it := mg.ListEvents("your-domain.com", &mailgun.ListEventOptions{Limit: 100})

Expand Down
4 changes: 2 additions & 2 deletions exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestExports(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
list, err := mg.ListExports(ctx, "")
Expand All @@ -38,7 +38,7 @@ func TestExports(t *testing.T) {

func TestExportsLink(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
url, err := mg.GetExportLink(ctx, "12")
Expand Down
4 changes: 2 additions & 2 deletions ips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestMain(m *testing.M) {

func TestListIPS(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
list, err := mg.ListIPS(ctx, false)
Expand All @@ -38,7 +38,7 @@ func TestListIPS(t *testing.T) {

func TestDomainIPS(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
err := mg.AddDomainIP(ctx, testDomain, "192.172.1.1")
Expand Down
2 changes: 1 addition & 1 deletion limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestLimits(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
limits, err := mg.GetTagLimits(ctx, testDomain)
Expand Down
6 changes: 3 additions & 3 deletions mailing_lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestMailingListMembers(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
address := randomEmail("list", testDomain)
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestMailingListMembers(t *testing.T) {

func TestMailingLists(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

address := randomEmail("list", testDomain)
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestMailingLists(t *testing.T) {

func TestListMailingListRegression(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()
address := "[email protected]"

Expand Down
12 changes: 6 additions & 6 deletions mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type MockServer interface {
Stop()
URL1() string
URL4() string
URL() string
URL3() string
DomainIPS() []string
DomainList() []DomainContainer
ExportList() []Export
Expand Down Expand Up @@ -155,13 +155,13 @@ func (ms *mockServer) URL1() string {
return ms.srv.URL + "/v1"
}

func (ms *mockServer) URL4() string {
return ms.srv.URL + "/v4"
// URL3 returns the URL used to connect to the mock server
func (ms *mockServer) URL3() string {
return ms.srv.URL + "/v3"
}

// URL returns the URL used to connect to the mock server
func (ms *mockServer) URL() string {
return ms.srv.URL + "/v3"
func (ms *mockServer) URL4() string {
return ms.srv.URL + "/v4"
}

func toJSON(w http.ResponseWriter, obj any) {
Expand Down
2 changes: 1 addition & 1 deletion mock_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (ms *mockServer) createMessages(w http.ResponseWriter, r *http.Request) {
stored.Name = events.EventStored
stored.Timestamp = TimeToFloat(time.Now().UTC())
stored.ID = id
stored.Storage.URL = ms.URL() + "/se.storage.url/messages/" + id
stored.Storage.URL = ms.URL3() + "/se.storage.url/messages/" + id
stored.Storage.Key = id
stored.Message.Headers = events.MessageHeaders{
Subject: r.FormValue("subject"),
Expand Down
4 changes: 2 additions & 2 deletions routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestRouteCRUD(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()
var countRoutes = func() int {
Expand Down Expand Up @@ -59,7 +59,7 @@ func TestRouteCRUD(t *testing.T) {

func TestRoutesIterator(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

it := mg.ListRoutes(&mailgun.ListOptions{Limit: 2})

Expand Down
8 changes: 4 additions & 4 deletions spam_complaints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestGetComplaints(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

ctx := context.Background()

Expand All @@ -25,7 +25,7 @@ func TestGetComplaints(t *testing.T) {

func TestGetComplaintFromRandomNoComplaint(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

_, err := mg.GetComplaint(ctx, testDomain, randomString(64, "")+"@example.com")
Expand All @@ -38,7 +38,7 @@ func TestGetComplaintFromRandomNoComplaint(t *testing.T) {

func TestCreateDeleteComplaint(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

var hasComplaint = func(email string) bool {
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestCreateDeleteComplaint(t *testing.T) {

func TestCreateDeleteComplaintList(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())
ctx := context.Background()

var hasComplaint = func(email string) bool {
Expand Down
2 changes: 1 addition & 1 deletion storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func TestStorage(t *testing.T) {
mg := mailgun.NewMailgun(testKey)
mg.SetAPIBase(server.URL())
mg.SetAPIBase(server.URL3())

var ctx = context.Background()

Expand Down
Loading

0 comments on commit 804e2db

Please sign in to comment.