wfe: Remove SendContacts call from updateAccount (#8048)
PR #8018 integrated the email-exporter service with WFE, updating wfe.NewAccount and wfe.updateAccount to submit valid email contacts to the Salesforce Pardot API. However, our new_or_updated_contact metric shows that (account) contact updates currently exceed the highest Salesforce tier’s daily submission limit by several times. This change can be reverted if additional filtering logic reduces updated (+ new) account contacts below the daily submission limit.
This commit is contained in:
parent
98b6d3f8bf
commit
f8d1d85349
|
|
@ -165,58 +165,3 @@ func TestContactsSentForNewAccount(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestContactsSentWhenAccountUpdated tests that contacts are dispatched to
|
||||
// pardot-test-srv by the email-exporter when an account is updated.
|
||||
func TestContactsSentWhenAccountUpdated(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if os.Getenv("BOULDER_CONFIG_DIR") != "test/config-next" {
|
||||
t.Skip("Test requires WFE to be configured to use email-exporter")
|
||||
}
|
||||
|
||||
token := getOAuthToken(t)
|
||||
domain := randomDomain(t)
|
||||
|
||||
c, err := acme.NewClient("http://boulder.service.consul:4001/directory")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to connect to acme directory: %s", err)
|
||||
}
|
||||
|
||||
acctKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to generate account key: %s", err)
|
||||
}
|
||||
|
||||
acct, err := c.NewAccount(acctKey, false, true)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create initial account: %s", err)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
contacts []string
|
||||
expectContacts []string
|
||||
}{
|
||||
{
|
||||
name: "Single email",
|
||||
contacts: []string{"mailto:example@" + domain},
|
||||
expectContacts: []string{"example@" + domain},
|
||||
},
|
||||
{
|
||||
name: "Multiple emails",
|
||||
contacts: []string{"mailto:example1@" + domain, "mailto:example2@" + domain},
|
||||
expectContacts: []string{"example1@" + domain, "example2@" + domain},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := c.UpdateAccount(acct, tt.contacts...)
|
||||
test.AssertNotError(t, err, "Failed to update contacts for existing account")
|
||||
assertAllContactsReceived(t, token, tt.expectContacts)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
wfe2/wfe.go
12
wfe2/wfe.go
|
|
@ -1457,18 +1457,6 @@ func (wfe *WebFrontEndImpl) updateAccount(
|
|||
return nil, probs.ServerInternal("Error updating account")
|
||||
}
|
||||
|
||||
emails := contactsToEmails(accountUpdateRequest.Contact)
|
||||
if wfe.ee != nil && len(emails) > 0 {
|
||||
_, err := wfe.ee.SendContacts(ctx, &emailpb.SendContactsRequest{
|
||||
// Note: We are explicitly using the contacts provided by the subscriber
|
||||
// here. The RA will eventually stop accepting contacts.
|
||||
Emails: emails,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, probs.ServerInternal("Error sending contact email")
|
||||
}
|
||||
}
|
||||
|
||||
return &updatedReg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4155,79 +4155,3 @@ ALTERNATE SITE: If no reply, move to Observation Point B at Broken Cairn.`},
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateAccountCreatesContacts(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
key := loadKey(t, []byte(test1KeyPrivatePEM))
|
||||
_, ok := key.(*rsa.PrivateKey)
|
||||
test.Assert(t, ok, "Couldn't load RSA key for acct 1")
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
contacts []string
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
name: "No email",
|
||||
contacts: []string{},
|
||||
expected: []string{},
|
||||
},
|
||||
{
|
||||
name: "One email",
|
||||
contacts: []string{"mailto:person@mail.com"},
|
||||
expected: []string{"person@mail.com"},
|
||||
},
|
||||
{
|
||||
name: "Two emails",
|
||||
contacts: []string{"mailto:person1@mail.com", "mailto:person2@mail.com"},
|
||||
expected: []string{"person1@mail.com", "person2@mail.com"},
|
||||
},
|
||||
{
|
||||
name: "Invalid email",
|
||||
contacts: []string{"mailto:lol@%mail.com"},
|
||||
expected: []string{},
|
||||
},
|
||||
{
|
||||
name: "One valid email, one invalid email",
|
||||
contacts: []string{"mailto:person@mail.com", "mailto:lol@%mail.com"},
|
||||
expected: []string{"person@mail.com"},
|
||||
},
|
||||
{
|
||||
name: "Valid email with invalid prefix",
|
||||
contacts: []string{"pantelegraph:person@mail.com"},
|
||||
expected: []string{},
|
||||
},
|
||||
{
|
||||
name: "Non-email prefix with correct telegraphic notation",
|
||||
contacts: []string{`pantelegraph:RECEIVING OFFICE: Bureau Room, Third Floor, Merchant House.
|
||||
TRANSMISSION LINE: Direct relay, Exchange Circuit No. 42.`},
|
||||
expected: []string{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
wfe, _, signer := setupWFE(t)
|
||||
mockPardotClient, mockImpl := mocks.NewMockPardotClientImpl()
|
||||
wfe.ee = mocks.NewMockExporterImpl(mockPardotClient)
|
||||
|
||||
responseWriter := httptest.NewRecorder()
|
||||
contactsJSON, err := json.Marshal(tc.contacts)
|
||||
test.AssertNotError(t, err, "Failed to marshal contacts")
|
||||
|
||||
newContact := fmt.Sprintf(`{"contact":%s}`, contactsJSON)
|
||||
signedURL := "http://localhost/1"
|
||||
path := "1"
|
||||
_, _, body := signer.byKeyID(1, key, signedURL, newContact)
|
||||
request := makePostRequestWithPath(path, body)
|
||||
wfe.Account(ctx, newRequestEvent(), responseWriter, request)
|
||||
test.AssertEquals(t, responseWriter.Code, http.StatusOK)
|
||||
for _, email := range tc.expected {
|
||||
test.AssertSliceContains(t, mockImpl.GetCreatedContacts(), email)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue