From 366606af07dadbed33723a9eac355c5c17b34f6d Mon Sep 17 00:00:00 2001 From: Samantha Date: Fri, 12 Dec 2025 17:50:55 -0500 Subject: [PATCH] salesforce: Rename email package and pardort-test-srv --- Containerfile | 2 +- Makefile | 9 +- cmd/boulder-wfe2/main.go | 6 +- cmd/email-exporter/main.go | 62 +++- cmd/sfe/main.go | 6 +- mocks/emailexporter.go | 30 +- {email => salesforce}/cache.go | 2 +- salesforce/email/proto/emailexporter.pb.go | 279 ++++++++++++++++++ .../email/proto/emailexporter.proto | 8 +- .../email/proto/emailexporter_grpc.pb.go | 166 +++++++++++ {email => salesforce}/exporter.go | 14 +- {email => salesforce}/exporter_test.go | 22 +- {email => salesforce}/pardot.go | 2 +- {email => salesforce}/pardot_test.go | 2 +- {email => salesforce}/proto/exporter.pb.go | 91 +++--- salesforce/proto/exporter.proto | 34 +++ .../proto/exporter_grpc.pb.go | 12 +- sfe/overrides.go | 6 +- sfe/sfe.go | 6 +- test/config-next/email-exporter.json | 6 + .../salesforce-test-srv.json} | 2 +- .../salesforce-test-srv.json} | 0 test/integration/email_exporter_test.go | 14 +- .../main.go | 8 +- test/startservers.py | 6 +- wfe2/wfe.go | 8 +- 26 files changed, 676 insertions(+), 127 deletions(-) rename {email => salesforce}/cache.go (99%) create mode 100644 salesforce/email/proto/emailexporter.pb.go rename email/proto/exporter.proto => salesforce/email/proto/emailexporter.proto (63%) create mode 100644 salesforce/email/proto/emailexporter_grpc.pb.go rename {email => salesforce}/exporter.go (94%) rename {email => salesforce}/exporter_test.go (91%) rename {email => salesforce}/pardot.go (99%) rename {email => salesforce}/pardot_test.go (99%) rename {email => salesforce}/proto/exporter.pb.go (62%) create mode 100644 salesforce/proto/exporter.proto rename {email => salesforce}/proto/exporter_grpc.pb.go (93%) rename test/{config/pardot-test-srv.json => config-next/salesforce-test-srv.json} (80%) rename test/{config-next/pardot-test-srv.json => config/salesforce-test-srv.json} (100%) rename test/{pardot-test-srv => salesforce-test-srv}/main.go (96%) diff --git a/Containerfile b/Containerfile index 92276aa6d30..1baa0ac59f3 100644 --- a/Containerfile +++ b/Containerfile @@ -46,7 +46,7 @@ COPY --from=builder \ /opt/boulder/bin/boulder \ /opt/boulder/bin/chall-test-srv \ /opt/boulder/bin/ct-test-srv \ - /opt/boulder/bin/pardot-test-srv \ + /opt/boulder/bin/salesforce-test-srv \ /opt/boulder/bin/zendesk-test-srv \ /opt/boulder/bin/ COPY --from=builder /opt/boulder/data /opt/boulder/data diff --git a/Makefile b/Makefile index 640ff12bdd9..cb38dc8a95e 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,9 @@ VERSION ?= 1.0.0 EPOCH ?= 1 MAINTAINER ?= "Community" -CMDS = admin boulder ceremony ct-test-srv pardot-test-srv chall-test-srv zendesk-test-srv +# TODO(#8410): Remove pardot-test-srv when we've fully migrated to +# salesforce-test-srv. +CMDS = admin boulder ceremony ct-test-srv salesforce-test-srv pardot-test-srv chall-test-srv zendesk-test-srv CMD_BINS = $(addprefix bin/, $(CMDS) ) OBJECTS = $(CMD_BINS) @@ -35,6 +37,11 @@ $(OBJDIR): $(CMD_BINS): build_cmds +# TODO(#8410): Remove bin/pardot-test-srv when we've fully migrated to +# salesforce-test-srv. +bin/pardot-test-srv: bin/salesforce-test-srv + cp bin/salesforce-test-srv $@ + build_cmds: | $(OBJDIR) echo $(OBJECTS) GOBIN=$(OBJDIR) go install -mod=vendor $(GO_BUILD_FLAGS) ./... diff --git a/cmd/boulder-wfe2/main.go b/cmd/boulder-wfe2/main.go index 8e681840eb6..8f2eec0ed2c 100644 --- a/cmd/boulder-wfe2/main.go +++ b/cmd/boulder-wfe2/main.go @@ -14,7 +14,6 @@ import ( "github.com/letsencrypt/boulder/cmd" "github.com/letsencrypt/boulder/config" - emailpb "github.com/letsencrypt/boulder/email/proto" "github.com/letsencrypt/boulder/features" "github.com/letsencrypt/boulder/goodkey" "github.com/letsencrypt/boulder/goodkey/sagoodkey" @@ -26,6 +25,7 @@ import ( "github.com/letsencrypt/boulder/ratelimits" bredis "github.com/letsencrypt/boulder/redis" sapb "github.com/letsencrypt/boulder/sa/proto" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" "github.com/letsencrypt/boulder/unpause" "github.com/letsencrypt/boulder/web" "github.com/letsencrypt/boulder/wfe2" @@ -286,11 +286,11 @@ func main() { cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to SA") sac := sapb.NewStorageAuthorityReadOnlyClient(saConn) - var eec emailpb.ExporterClient + var eec salesforcepb.ExporterClient if c.WFE.EmailExporter != nil { emailExporterConn, err := bgrpc.ClientSetup(c.WFE.EmailExporter, tlsConfig, stats, clk) cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to email-exporter") - eec = emailpb.NewExporterClient(emailExporterConn) + eec = salesforcepb.NewExporterClient(emailExporterConn) } if c.WFE.RedeemNonceService == nil { diff --git a/cmd/email-exporter/main.go b/cmd/email-exporter/main.go index 219f067d6ca..22ced0d0dbf 100644 --- a/cmd/email-exporter/main.go +++ b/cmd/email-exporter/main.go @@ -6,11 +6,13 @@ import ( "os" "github.com/jmhodges/clock" + "google.golang.org/protobuf/types/known/emptypb" "github.com/letsencrypt/boulder/cmd" - "github.com/letsencrypt/boulder/email" - emailpb "github.com/letsencrypt/boulder/email/proto" bgrpc "github.com/letsencrypt/boulder/grpc" + "github.com/letsencrypt/boulder/salesforce" + emailpb "github.com/letsencrypt/boulder/salesforce/email/proto" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" ) // Config holds the configuration for the email-exporter service. @@ -62,6 +64,38 @@ type Config struct { OpenTelemetry cmd.OpenTelemetryConfig } +// legacyEmailExporterServer is an adapter that implements the email.Exporter +// gRPC interface by delegating to an inner salesforce.Exporter server. +// +// TODO(#8410): Remove legacyEmailExporterServer once fully migrated to +// salesforcepb.Exporter. +type legacyEmailExporterServer struct { + emailpb.UnimplementedExporterServer + inner salesforcepb.ExporterServer +} + +// SendContacts is an interface adapter that forwards the request to the same +// method on the inner salesforce.Exporter server. +func (s legacyEmailExporterServer) SendContacts(ctx context.Context, req *emailpb.SendContactsRequest) (*emptypb.Empty, error) { + return s.inner.SendContacts(ctx, &salesforcepb.SendContactsRequest{Emails: req.GetEmails()}) +} + +// SendCase is an interface adapter that forwards the request to the same method +// on the inner salesforce.Exporter server. +func (s legacyEmailExporterServer) SendCase(ctx context.Context, req *emailpb.SendCaseRequest) (*emptypb.Empty, error) { + return s.inner.SendCase(ctx, &salesforcepb.SendCaseRequest{ + Origin: req.GetOrigin(), + Subject: req.GetSubject(), + Description: req.GetDescription(), + ContactEmail: req.GetContactEmail(), + Organization: req.GetOrganization(), + AccountId: req.GetAccountId(), + RateLimitName: req.GetRateLimitName(), + RateLimitTier: req.GetRateLimitTier(), + UseCase: req.GetUseCase(), + }) +} + func main() { configFile := flag.String("config", "", "Path to configuration file") grpcAddr := flag.String("addr", "", "gRPC listen address override") @@ -95,12 +129,12 @@ func main() { clientSecret, err := c.EmailExporter.ClientSecret.Pass() cmd.FailOnError(err, "Loading clientSecret") - var cache *email.EmailCache + var cache *salesforce.EmailCache if c.EmailExporter.EmailCacheSize > 0 { - cache = email.NewHashedEmailCache(c.EmailExporter.EmailCacheSize, scope) + cache = salesforce.NewHashedEmailCache(c.EmailExporter.EmailCacheSize, scope) } - sfClient, err := email.NewSalesforceClientImpl( + sfClient, err := salesforce.NewSalesforceClientImpl( clk, c.EmailExporter.PardotBusinessUnit, clientId, @@ -109,21 +143,25 @@ func main() { c.EmailExporter.PardotBaseURL, ) cmd.FailOnError(err, "Creating Pardot API client") - exporterServer := email.NewExporterImpl(sfClient, cache, c.EmailExporter.PerDayLimit, c.EmailExporter.MaxConcurrentRequests, scope, logger) + server := salesforce.NewExporterImpl(sfClient, cache, c.EmailExporter.PerDayLimit, c.EmailExporter.MaxConcurrentRequests, scope, logger) tlsConfig, err := c.EmailExporter.TLS.Load(scope) cmd.FailOnError(err, "Loading email-exporter TLS config") - daemonCtx, shutdownExporterServer := context.WithCancel(context.Background()) - go exporterServer.Start(daemonCtx) + daemonCtx, shutdown := context.WithCancel(context.Background()) + go server.Start(daemonCtx) - start, err := bgrpc.NewServer(c.EmailExporter.GRPC, logger).Add( - &emailpb.Exporter_ServiceDesc, exporterServer).Build(tlsConfig, scope, clk) + srv := bgrpc.NewServer(c.EmailExporter.GRPC, logger) + srv = srv.Add(&salesforcepb.Exporter_ServiceDesc, server) + // TODO(#8410): Remove emailpb.Exporter once fully migrated to + // salesforcepb.Exporter. + srv = srv.Add(&emailpb.Exporter_ServiceDesc, legacyEmailExporterServer{inner: server}) + start, err := srv.Build(tlsConfig, scope, clk) cmd.FailOnError(err, "Configuring email-exporter gRPC server") err = start() - shutdownExporterServer() - exporterServer.Drain() + shutdown() + server.Drain() cmd.FailOnError(err, "email-exporter gRPC service failed to start") } diff --git a/cmd/sfe/main.go b/cmd/sfe/main.go index d46fb9d49a3..c9ad711fc1d 100644 --- a/cmd/sfe/main.go +++ b/cmd/sfe/main.go @@ -11,13 +11,13 @@ import ( "github.com/letsencrypt/boulder/cmd" "github.com/letsencrypt/boulder/config" - emailpb "github.com/letsencrypt/boulder/email/proto" "github.com/letsencrypt/boulder/features" bgrpc "github.com/letsencrypt/boulder/grpc" rapb "github.com/letsencrypt/boulder/ra/proto" "github.com/letsencrypt/boulder/ratelimits" bredis "github.com/letsencrypt/boulder/redis" sapb "github.com/letsencrypt/boulder/sa/proto" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" "github.com/letsencrypt/boulder/sfe" "github.com/letsencrypt/boulder/sfe/zendesk" "github.com/letsencrypt/boulder/web" @@ -156,11 +156,11 @@ func main() { cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to SA") sac := sapb.NewStorageAuthorityReadOnlyClient(saConn) - var eec emailpb.ExporterClient + var eec salesforcepb.ExporterClient if c.SFE.EmailExporter != nil { emailExporterConn, err := bgrpc.ClientSetup(c.SFE.EmailExporter, tlsConfig, stats, clk) cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to email-exporter") - eec = emailpb.NewExporterClient(emailExporterConn) + eec = salesforcepb.NewExporterClient(emailExporterConn) } var zendeskClient *zendesk.Client diff --git a/mocks/emailexporter.go b/mocks/emailexporter.go index 4810887e5fb..a2891588845 100644 --- a/mocks/emailexporter.go +++ b/mocks/emailexporter.go @@ -8,17 +8,17 @@ import ( "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" - "github.com/letsencrypt/boulder/email" - emailpb "github.com/letsencrypt/boulder/email/proto" + "github.com/letsencrypt/boulder/salesforce" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" ) -var _ email.SalesforceClient = (*MockSalesforceClientImpl)(nil) +var _ salesforce.SalesforceClient = (*MockSalesforceClientImpl)(nil) -// MockSalesforceClientImpl is a mock implementation of email.SalesforceClient. +// MockSalesforceClientImpl is a mock implementation of salesforce.SalesforceClient. type MockSalesforceClientImpl struct { sync.Mutex CreatedContacts []string - CreatedCases []email.Case + CreatedCases []salesforce.Case } // NewMockSalesforceClientImpl returns a MockSalesforceClientImpl, which implements @@ -48,7 +48,7 @@ func (m *MockSalesforceClientImpl) GetCreatedContacts() []string { } // SendCase adds a case payload to CreatedCases. -func (m *MockSalesforceClientImpl) SendCase(payload email.Case) error { +func (m *MockSalesforceClientImpl) SendCase(payload salesforce.Case) error { m.Lock() defer m.Unlock() @@ -58,7 +58,7 @@ func (m *MockSalesforceClientImpl) SendCase(payload email.Case) error { // GetCreatedCases is used for testing to retrieve the list of created cases in // a thread-safe manner. -func (m *MockSalesforceClientImpl) GetCreatedCases() []email.Case { +func (m *MockSalesforceClientImpl) GetCreatedCases() []salesforce.Case { m.Lock() defer m.Unlock() @@ -66,23 +66,23 @@ func (m *MockSalesforceClientImpl) GetCreatedCases() []email.Case { return slices.Clone(m.CreatedCases) } -var _ emailpb.ExporterClient = (*MockExporterClientImpl)(nil) +var _ salesforcepb.ExporterClient = (*MockExporterClientImpl)(nil) // MockExporterClientImpl is a mock implementation of ExporterClient. type MockExporterClientImpl struct { - SalesforceClient email.SalesforceClient + SalesforceClient salesforce.SalesforceClient } // NewMockExporterImpl returns a MockExporterClientImpl as an ExporterClient. -func NewMockExporterImpl(salesforceClient email.SalesforceClient) emailpb.ExporterClient { +func NewMockExporterImpl(salesforceClient salesforce.SalesforceClient) salesforcepb.ExporterClient { return &MockExporterClientImpl{ SalesforceClient: salesforceClient, } } -// SendContacts submits emails to the inner email.SalesforceClient, returning an +// SendContacts submits emails to the inner salesforce.SalesforceClient, returning an // error if any fail. -func (m *MockExporterClientImpl) SendContacts(ctx context.Context, req *emailpb.SendContactsRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { +func (m *MockExporterClientImpl) SendContacts(ctx context.Context, req *salesforcepb.SendContactsRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { for _, e := range req.Emails { err := m.SalesforceClient.SendContact(e) if err != nil { @@ -92,9 +92,9 @@ func (m *MockExporterClientImpl) SendContacts(ctx context.Context, req *emailpb. return &emptypb.Empty{}, nil } -// SendCase submits a Case using the inner email.SalesforceClient. -func (m *MockExporterClientImpl) SendCase(ctx context.Context, req *emailpb.SendCaseRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { - return &emptypb.Empty{}, m.SalesforceClient.SendCase(email.Case{ +// SendCase submits a Case using the inner salesforce.SalesforceClient. +func (m *MockExporterClientImpl) SendCase(ctx context.Context, req *salesforcepb.SendCaseRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { + return &emptypb.Empty{}, m.SalesforceClient.SendCase(salesforce.Case{ Origin: req.Origin, Subject: req.Subject, Description: req.Description, diff --git a/email/cache.go b/salesforce/cache.go similarity index 99% rename from email/cache.go rename to salesforce/cache.go index f4117632e09..2ec666d125a 100644 --- a/email/cache.go +++ b/salesforce/cache.go @@ -1,4 +1,4 @@ -package email +package salesforce import ( "crypto/sha256" diff --git a/salesforce/email/proto/emailexporter.pb.go b/salesforce/email/proto/emailexporter.pb.go new file mode 100644 index 00000000000..75d14972499 --- /dev/null +++ b/salesforce/email/proto/emailexporter.pb.go @@ -0,0 +1,279 @@ +// NOTE: This service is deprecated in favor of salesforce.Exporter. It must be +// kept in sync with salesforce.Exporter until we have fully migrated. +// +// TODO(#8410): Remove this service once we've fully migrated to +// salesforce.Exporter + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.5 +// protoc v3.20.1 +// source: emailexporter.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SendContactsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Emails []string `protobuf:"bytes,1,rep,name=emails,proto3" json:"emails,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SendContactsRequest) Reset() { + *x = SendContactsRequest{} + mi := &file_emailexporter_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SendContactsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendContactsRequest) ProtoMessage() {} + +func (x *SendContactsRequest) ProtoReflect() protoreflect.Message { + mi := &file_emailexporter_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendContactsRequest.ProtoReflect.Descriptor instead. +func (*SendContactsRequest) Descriptor() ([]byte, []int) { + return file_emailexporter_proto_rawDescGZIP(), []int{0} +} + +func (x *SendContactsRequest) GetEmails() []string { + if x != nil { + return x.Emails + } + return nil +} + +type SendCaseRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Origin string `protobuf:"bytes,1,opt,name=origin,proto3" json:"origin,omitempty"` + Subject string `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + ContactEmail string `protobuf:"bytes,4,opt,name=contactEmail,proto3" json:"contactEmail,omitempty"` + Organization string `protobuf:"bytes,5,opt,name=organization,proto3" json:"organization,omitempty"` + AccountId string `protobuf:"bytes,6,opt,name=accountId,proto3" json:"accountId,omitempty"` + RateLimitName string `protobuf:"bytes,7,opt,name=rateLimitName,proto3" json:"rateLimitName,omitempty"` + RateLimitTier string `protobuf:"bytes,8,opt,name=rateLimitTier,proto3" json:"rateLimitTier,omitempty"` + UseCase string `protobuf:"bytes,9,opt,name=useCase,proto3" json:"useCase,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SendCaseRequest) Reset() { + *x = SendCaseRequest{} + mi := &file_emailexporter_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SendCaseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendCaseRequest) ProtoMessage() {} + +func (x *SendCaseRequest) ProtoReflect() protoreflect.Message { + mi := &file_emailexporter_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendCaseRequest.ProtoReflect.Descriptor instead. +func (*SendCaseRequest) Descriptor() ([]byte, []int) { + return file_emailexporter_proto_rawDescGZIP(), []int{1} +} + +func (x *SendCaseRequest) GetOrigin() string { + if x != nil { + return x.Origin + } + return "" +} + +func (x *SendCaseRequest) GetSubject() string { + if x != nil { + return x.Subject + } + return "" +} + +func (x *SendCaseRequest) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *SendCaseRequest) GetContactEmail() string { + if x != nil { + return x.ContactEmail + } + return "" +} + +func (x *SendCaseRequest) GetOrganization() string { + if x != nil { + return x.Organization + } + return "" +} + +func (x *SendCaseRequest) GetAccountId() string { + if x != nil { + return x.AccountId + } + return "" +} + +func (x *SendCaseRequest) GetRateLimitName() string { + if x != nil { + return x.RateLimitName + } + return "" +} + +func (x *SendCaseRequest) GetRateLimitTier() string { + if x != nil { + return x.RateLimitTier + } + return "" +} + +func (x *SendCaseRequest) GetUseCase() string { + if x != nil { + return x.UseCase + } + return "" +} + +var File_emailexporter_proto protoreflect.FileDescriptor + +var file_emailexporter_proto_rawDesc = string([]byte{ + 0x0a, 0x13, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x1a, 0x1b, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, + 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2d, 0x0a, 0x13, 0x53, 0x65, 0x6e, + 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x06, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x22, 0xb1, 0x02, 0x0a, 0x0f, 0x53, 0x65, 0x6e, + 0x64, 0x43, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x72, + 0x69, 0x67, 0x69, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x45, + 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, + 0x6d, 0x69, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, + 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, + 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x65, 0x72, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x54, 0x69, + 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x43, 0x61, 0x73, 0x65, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x43, 0x61, 0x73, 0x65, 0x32, 0x8a, 0x01, 0x0a, + 0x08, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x42, 0x0a, 0x0c, 0x53, 0x65, 0x6e, + 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x12, 0x1a, 0x2e, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3a, 0x0a, + 0x08, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x65, 0x74, 0x73, 0x65, 0x6e, 0x63, 0x72, + 0x79, 0x70, 0x74, 0x2f, 0x62, 0x6f, 0x75, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x73, 0x61, 0x6c, 0x65, + 0x73, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +}) + +var ( + file_emailexporter_proto_rawDescOnce sync.Once + file_emailexporter_proto_rawDescData []byte +) + +func file_emailexporter_proto_rawDescGZIP() []byte { + file_emailexporter_proto_rawDescOnce.Do(func() { + file_emailexporter_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_emailexporter_proto_rawDesc), len(file_emailexporter_proto_rawDesc))) + }) + return file_emailexporter_proto_rawDescData +} + +var file_emailexporter_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_emailexporter_proto_goTypes = []any{ + (*SendContactsRequest)(nil), // 0: email.SendContactsRequest + (*SendCaseRequest)(nil), // 1: email.SendCaseRequest + (*emptypb.Empty)(nil), // 2: google.protobuf.Empty +} +var file_emailexporter_proto_depIdxs = []int32{ + 0, // 0: email.Exporter.SendContacts:input_type -> email.SendContactsRequest + 1, // 1: email.Exporter.SendCase:input_type -> email.SendCaseRequest + 2, // 2: email.Exporter.SendContacts:output_type -> google.protobuf.Empty + 2, // 3: email.Exporter.SendCase:output_type -> google.protobuf.Empty + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_emailexporter_proto_init() } +func file_emailexporter_proto_init() { + if File_emailexporter_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_emailexporter_proto_rawDesc), len(file_emailexporter_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_emailexporter_proto_goTypes, + DependencyIndexes: file_emailexporter_proto_depIdxs, + MessageInfos: file_emailexporter_proto_msgTypes, + }.Build() + File_emailexporter_proto = out.File + file_emailexporter_proto_goTypes = nil + file_emailexporter_proto_depIdxs = nil +} diff --git a/email/proto/exporter.proto b/salesforce/email/proto/emailexporter.proto similarity index 63% rename from email/proto/exporter.proto rename to salesforce/email/proto/emailexporter.proto index 5fa176dc4e1..8c3733444e8 100644 --- a/email/proto/exporter.proto +++ b/salesforce/email/proto/emailexporter.proto @@ -1,7 +1,13 @@ +// NOTE: This service is deprecated in favor of salesforce.Exporter. It must be +// kept in sync with salesforce.Exporter until we have fully migrated. +// +// TODO(#8410): Remove this service once we've fully migrated to +// salesforce.Exporter + syntax = "proto3"; package email; -option go_package = "github.com/letsencrypt/boulder/email/proto"; +option go_package = "github.com/letsencrypt/boulder/salesforce/proto"; import "google/protobuf/empty.proto"; diff --git a/salesforce/email/proto/emailexporter_grpc.pb.go b/salesforce/email/proto/emailexporter_grpc.pb.go new file mode 100644 index 00000000000..72e7c1b3a93 --- /dev/null +++ b/salesforce/email/proto/emailexporter_grpc.pb.go @@ -0,0 +1,166 @@ +// NOTE: This service is deprecated in favor of salesforce.Exporter. It must be +// kept in sync with salesforce.Exporter until we have fully migrated. +// +// TODO(#8410): Remove this service once we've fully migrated to +// salesforce.Exporter + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v3.20.1 +// source: emailexporter.proto + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Exporter_SendContacts_FullMethodName = "/email.Exporter/SendContacts" + Exporter_SendCase_FullMethodName = "/email.Exporter/SendCase" +) + +// ExporterClient is the client API for Exporter service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ExporterClient interface { + SendContacts(ctx context.Context, in *SendContactsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + SendCase(ctx context.Context, in *SendCaseRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) +} + +type exporterClient struct { + cc grpc.ClientConnInterface +} + +func NewExporterClient(cc grpc.ClientConnInterface) ExporterClient { + return &exporterClient{cc} +} + +func (c *exporterClient) SendContacts(ctx context.Context, in *SendContactsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Exporter_SendContacts_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *exporterClient) SendCase(ctx context.Context, in *SendCaseRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Exporter_SendCase_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ExporterServer is the server API for Exporter service. +// All implementations must embed UnimplementedExporterServer +// for forward compatibility. +type ExporterServer interface { + SendContacts(context.Context, *SendContactsRequest) (*emptypb.Empty, error) + SendCase(context.Context, *SendCaseRequest) (*emptypb.Empty, error) + mustEmbedUnimplementedExporterServer() +} + +// UnimplementedExporterServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedExporterServer struct{} + +func (UnimplementedExporterServer) SendContacts(context.Context, *SendContactsRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendContacts not implemented") +} +func (UnimplementedExporterServer) SendCase(context.Context, *SendCaseRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendCase not implemented") +} +func (UnimplementedExporterServer) mustEmbedUnimplementedExporterServer() {} +func (UnimplementedExporterServer) testEmbeddedByValue() {} + +// UnsafeExporterServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ExporterServer will +// result in compilation errors. +type UnsafeExporterServer interface { + mustEmbedUnimplementedExporterServer() +} + +func RegisterExporterServer(s grpc.ServiceRegistrar, srv ExporterServer) { + // If the following call pancis, it indicates UnimplementedExporterServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Exporter_ServiceDesc, srv) +} + +func _Exporter_SendContacts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendContactsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExporterServer).SendContacts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Exporter_SendContacts_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExporterServer).SendContacts(ctx, req.(*SendContactsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Exporter_SendCase_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendCaseRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExporterServer).SendCase(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Exporter_SendCase_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExporterServer).SendCase(ctx, req.(*SendCaseRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Exporter_ServiceDesc is the grpc.ServiceDesc for Exporter service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Exporter_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "email.Exporter", + HandlerType: (*ExporterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SendContacts", + Handler: _Exporter_SendContacts_Handler, + }, + { + MethodName: "SendCase", + Handler: _Exporter_SendCase_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "emailexporter.proto", +} diff --git a/email/exporter.go b/salesforce/exporter.go similarity index 94% rename from email/exporter.go rename to salesforce/exporter.go index 9cb020e8a5b..9b9f923584b 100644 --- a/email/exporter.go +++ b/salesforce/exporter.go @@ -1,4 +1,4 @@ -package email +package salesforce import ( "context" @@ -11,9 +11,9 @@ import ( "google.golang.org/protobuf/types/known/emptypb" "github.com/letsencrypt/boulder/core" - emailpb "github.com/letsencrypt/boulder/email/proto" berrors "github.com/letsencrypt/boulder/errors" blog "github.com/letsencrypt/boulder/log" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" ) // contactsQueueCap limits the queue size to prevent unbounded growth. This @@ -25,7 +25,7 @@ var ErrQueueFull = errors.New("email-exporter queue is full") // ExporterImpl implements the gRPC server and processes email exports. type ExporterImpl struct { - emailpb.UnsafeExporterServer + salesforcepb.UnsafeExporterServer sync.Mutex drainWG sync.WaitGroup @@ -48,7 +48,7 @@ type ExporterImpl struct { log blog.Logger } -var _ emailpb.ExporterServer = (*ExporterImpl)(nil) +var _ salesforcepb.ExporterServer = (*ExporterImpl)(nil) // NewExporterImpl initializes an ExporterImpl with the given client and // configuration. Both perDayLimit and maxConcurrentRequests should be @@ -104,7 +104,7 @@ func NewExporterImpl(client SalesforceClient, cache *EmailCache, perDayLimit flo // SendContacts enqueues the provided email addresses. If the queue cannot // accommodate the new emails, an ErrQueueFull is returned. -func (impl *ExporterImpl) SendContacts(ctx context.Context, req *emailpb.SendContactsRequest) (*emptypb.Empty, error) { +func (impl *ExporterImpl) SendContacts(ctx context.Context, req *salesforcepb.SendContactsRequest) (*emptypb.Empty, error) { if core.IsAnyNilOrZero(req, req.Emails) { return nil, berrors.InternalServerError("Incomplete gRPC request message") } @@ -125,8 +125,8 @@ func (impl *ExporterImpl) SendContacts(ctx context.Context, req *emailpb.SendCon // SendCase immediately submits a new Case to the Salesforce REST API using the // provided details. Any retries are handled internally by the SalesforceClient. -// The following fields are required: Origin, Subject, ContactEmail. -func (impl *ExporterImpl) SendCase(ctx context.Context, req *emailpb.SendCaseRequest) (*emptypb.Empty, error) { +// The following fields are required: Origin, Subject, Contactsalesforce. +func (impl *ExporterImpl) SendCase(ctx context.Context, req *salesforcepb.SendCaseRequest) (*emptypb.Empty, error) { if core.IsAnyNilOrZero(req, req.Origin, req.Subject, req.ContactEmail) { return nil, berrors.InternalServerError("incomplete gRPC request message") } diff --git a/email/exporter_test.go b/salesforce/exporter_test.go similarity index 91% rename from email/exporter_test.go rename to salesforce/exporter_test.go index e88b9c591ac..d7d818a8191 100644 --- a/email/exporter_test.go +++ b/salesforce/exporter_test.go @@ -1,4 +1,4 @@ -package email +package salesforce import ( "context" @@ -8,9 +8,9 @@ import ( "testing" "time" - emailpb "github.com/letsencrypt/boulder/email/proto" blog "github.com/letsencrypt/boulder/log" "github.com/letsencrypt/boulder/metrics" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" "github.com/letsencrypt/boulder/test" "github.com/prometheus/client_golang/prometheus" @@ -91,7 +91,7 @@ func TestSendContacts(t *testing.T) { defer cleanup() wantContacts := []string{"test@example.com", "user@example.com"} - _, err := exporter.SendContacts(ctx, &emailpb.SendContactsRequest{ + _, err := exporter.SendContacts(ctx, &salesforcepb.SendContactsRequest{ Emails: wantContacts, }) test.AssertNotError(t, err, "Error creating contacts") @@ -120,7 +120,7 @@ func TestSendContactsQueueFull(t *testing.T) { var err error for range contactsQueueCap * 2 { - _, err = exporter.SendContacts(ctx, &emailpb.SendContactsRequest{ + _, err = exporter.SendContacts(ctx, &salesforcepb.SendContactsRequest{ Emails: []string{"test@example.com"}, }) if err != nil { @@ -141,7 +141,7 @@ func TestSendContactsQueueDrains(t *testing.T) { emails = append(emails, fmt.Sprintf("test@%d.example.com", i)) } - _, err := exporter.SendContacts(ctx, &emailpb.SendContactsRequest{ + _, err := exporter.SendContacts(ctx, &salesforcepb.SendContactsRequest{ Emails: emails, }) test.AssertNotError(t, err, "Error creating contacts") @@ -169,7 +169,7 @@ func TestSendContactsErrorMetrics(t *testing.T) { daemonCtx, cancel := context.WithCancel(context.Background()) exporter.Start(daemonCtx) - _, err := exporter.SendContacts(ctx, &emailpb.SendContactsRequest{ + _, err := exporter.SendContacts(ctx, &salesforcepb.SendContactsRequest{ Emails: []string{"test@example.com"}, }) test.AssertNotError(t, err, "Error creating contacts") @@ -192,7 +192,7 @@ func TestSendContactDeduplication(t *testing.T) { daemonCtx, cancel := context.WithCancel(context.Background()) exporter.Start(daemonCtx) - _, err := exporter.SendContacts(ctx, &emailpb.SendContactsRequest{ + _, err := exporter.SendContacts(ctx, &salesforcepb.SendContactsRequest{ Emails: []string{"duplicate@example.com", "duplicate@example.com"}, }) test.AssertNotError(t, err, "Error enqueuing contacts") @@ -224,7 +224,7 @@ func TestSendContactErrorRemovesFromCache(t *testing.T) { daemonCtx, cancel := context.WithCancel(context.Background()) exporter.Start(daemonCtx) - _, err := exporter.SendContacts(ctx, &emailpb.SendContactsRequest{ + _, err := exporter.SendContacts(ctx, &salesforcepb.SendContactsRequest{ Emails: []string{"error@example.com"}, }) test.AssertNotError(t, err, "enqueue failed") @@ -249,7 +249,7 @@ func TestSendCase(t *testing.T) { clientImpl := newMockSalesforceClientImpl() exporter := NewExporterImpl(clientImpl, nil, 1000000, 5, metrics.NoopRegisterer, blog.NewMock()) - _, err := exporter.SendCase(ctx, &emailpb.SendCaseRequest{ + _, err := exporter.SendCase(ctx, &salesforcepb.SendCaseRequest{ Origin: "Web", Subject: "Some Override", Description: "Please review", @@ -282,7 +282,7 @@ func TestSendCaseClientErrorIncrementsMetric(t *testing.T) { mockClient := &mockAlwaysFailCaseClient{} exporter := NewExporterImpl(mockClient, nil, 1000000, 5, metrics.NoopRegisterer, blog.NewMock()) - _, err := exporter.SendCase(ctx, &emailpb.SendCaseRequest{ + _, err := exporter.SendCase(ctx, &salesforcepb.SendCaseRequest{ Origin: "Web", Subject: "Some Override", Description: "Please review", @@ -298,7 +298,7 @@ func TestSendCaseMissingOriginValidation(t *testing.T) { clientImpl := newMockSalesforceClientImpl() exporter := NewExporterImpl(clientImpl, nil, 1000000, 5, metrics.NoopRegisterer, blog.NewMock()) - _, err := exporter.SendCase(ctx, &emailpb.SendCaseRequest{Subject: "No origin in this one, d00d"}) + _, err := exporter.SendCase(ctx, &salesforcepb.SendCaseRequest{Subject: "No origin in this one, d00d"}) test.AssertError(t, err, "SendCase should fail validation when Origin is missing") got := clientImpl.getCreatedCases() diff --git a/email/pardot.go b/salesforce/pardot.go similarity index 99% rename from email/pardot.go rename to salesforce/pardot.go index e97c5c4b072..06eaf4f215e 100644 --- a/email/pardot.go +++ b/salesforce/pardot.go @@ -1,4 +1,4 @@ -package email +package salesforce import ( "bytes" diff --git a/email/pardot_test.go b/salesforce/pardot_test.go similarity index 99% rename from email/pardot_test.go rename to salesforce/pardot_test.go index b25d28e3d01..11a4648a461 100644 --- a/email/pardot_test.go +++ b/salesforce/pardot_test.go @@ -1,4 +1,4 @@ -package email +package salesforce import ( "encoding/json" diff --git a/email/proto/exporter.pb.go b/salesforce/proto/exporter.pb.go similarity index 62% rename from email/proto/exporter.pb.go rename to salesforce/proto/exporter.pb.go index c3b1323ea9a..777fd754ff0 100644 --- a/email/proto/exporter.pb.go +++ b/salesforce/proto/exporter.pb.go @@ -1,3 +1,9 @@ +// NOTE: Any changes to this service MUST also be made to email.Exporter and +// kept in sync with the adapter in cmd/email-exporter/main.go. +// +// TODO(#8410): Remove this comment once we've fully migrated to +// salesforce.Exporter. + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.5 @@ -178,43 +184,44 @@ var File_exporter_proto protoreflect.FileDescriptor var file_exporter_proto_rawDesc = string([]byte{ 0x0a, 0x0e, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2d, 0x0a, 0x13, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x74, - 0x61, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x65, - 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x65, 0x6d, 0x61, - 0x69, 0x6c, 0x73, 0x22, 0xb1, 0x02, 0x0a, 0x0f, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x61, 0x73, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x12, - 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x63, - 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, - 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, - 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4e, 0x61, - 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, - 0x6d, 0x69, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x61, 0x74, 0x65, 0x4c, - 0x69, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, - 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x65, 0x72, 0x12, 0x18, 0x0a, - 0x07, 0x75, 0x73, 0x65, 0x43, 0x61, 0x73, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x75, 0x73, 0x65, 0x43, 0x61, 0x73, 0x65, 0x32, 0x8a, 0x01, 0x0a, 0x08, 0x45, 0x78, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x72, 0x12, 0x42, 0x0a, 0x0c, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x74, - 0x61, 0x63, 0x74, 0x73, 0x12, 0x1a, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x53, 0x65, 0x6e, + 0x12, 0x0a, 0x73, 0x61, 0x6c, 0x65, 0x73, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x1a, 0x1b, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, + 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2d, 0x0a, 0x13, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x65, 0x6e, 0x64, - 0x43, 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x53, 0x65, 0x6e, - 0x64, 0x43, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x42, 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6c, 0x65, 0x74, 0x73, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x2f, 0x62, - 0x6f, 0x75, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x06, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x22, 0xb1, 0x02, 0x0a, 0x0f, 0x53, 0x65, 0x6e, + 0x64, 0x43, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x72, + 0x69, 0x67, 0x69, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x45, + 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, + 0x6d, 0x69, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, + 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, + 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x65, 0x72, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x54, 0x69, + 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x43, 0x61, 0x73, 0x65, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x43, 0x61, 0x73, 0x65, 0x32, 0x94, 0x01, 0x0a, + 0x08, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x47, 0x0a, 0x0c, 0x53, 0x65, 0x6e, + 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x12, 0x1f, 0x2e, 0x73, 0x61, 0x6c, 0x65, + 0x73, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, + 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x12, 0x3f, 0x0a, 0x08, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x61, 0x73, 0x65, 0x12, 0x1b, + 0x2e, 0x73, 0x61, 0x6c, 0x65, 0x73, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x2e, 0x53, 0x65, 0x6e, 0x64, + 0x43, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x6c, 0x65, 0x74, 0x73, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x2f, 0x62, 0x6f, + 0x75, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x73, 0x61, 0x6c, 0x65, 0x73, 0x66, 0x6f, 0x72, 0x63, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, }) var ( @@ -231,15 +238,15 @@ func file_exporter_proto_rawDescGZIP() []byte { var file_exporter_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_exporter_proto_goTypes = []any{ - (*SendContactsRequest)(nil), // 0: email.SendContactsRequest - (*SendCaseRequest)(nil), // 1: email.SendCaseRequest + (*SendContactsRequest)(nil), // 0: salesforce.SendContactsRequest + (*SendCaseRequest)(nil), // 1: salesforce.SendCaseRequest (*emptypb.Empty)(nil), // 2: google.protobuf.Empty } var file_exporter_proto_depIdxs = []int32{ - 0, // 0: email.Exporter.SendContacts:input_type -> email.SendContactsRequest - 1, // 1: email.Exporter.SendCase:input_type -> email.SendCaseRequest - 2, // 2: email.Exporter.SendContacts:output_type -> google.protobuf.Empty - 2, // 3: email.Exporter.SendCase:output_type -> google.protobuf.Empty + 0, // 0: salesforce.Exporter.SendContacts:input_type -> salesforce.SendContactsRequest + 1, // 1: salesforce.Exporter.SendCase:input_type -> salesforce.SendCaseRequest + 2, // 2: salesforce.Exporter.SendContacts:output_type -> google.protobuf.Empty + 2, // 3: salesforce.Exporter.SendCase:output_type -> google.protobuf.Empty 2, // [2:4] is the sub-list for method output_type 0, // [0:2] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/salesforce/proto/exporter.proto b/salesforce/proto/exporter.proto new file mode 100644 index 00000000000..55e04dfdda2 --- /dev/null +++ b/salesforce/proto/exporter.proto @@ -0,0 +1,34 @@ +// NOTE: Any changes to this service MUST also be made to email.Exporter and +// kept in sync with the adapter in cmd/email-exporter/main.go. +// +// TODO(#8410): Remove this comment once we've fully migrated to +// salesforce.Exporter. + +syntax = "proto3"; + +package salesforce; +option go_package = "github.com/letsencrypt/boulder/salesforce/proto"; + +import "google/protobuf/empty.proto"; + +service Exporter { + rpc SendContacts (SendContactsRequest) returns (google.protobuf.Empty); + rpc SendCase (SendCaseRequest) returns (google.protobuf.Empty); +} + +message SendContactsRequest { + repeated string emails = 1; +} + +message SendCaseRequest { + string origin = 1; + string subject = 2; + string description = 3; + string contactEmail = 4; + string organization = 5; + string accountId = 6; + string rateLimitName = 7; + string rateLimitTier = 8; + string useCase = 9; +} + diff --git a/email/proto/exporter_grpc.pb.go b/salesforce/proto/exporter_grpc.pb.go similarity index 93% rename from email/proto/exporter_grpc.pb.go rename to salesforce/proto/exporter_grpc.pb.go index baad48aa054..5758e32ebf6 100644 --- a/email/proto/exporter_grpc.pb.go +++ b/salesforce/proto/exporter_grpc.pb.go @@ -1,3 +1,9 @@ +// NOTE: Any changes to this service MUST also be made to email.Exporter and +// kept in sync with the adapter in cmd/email-exporter/main.go. +// +// TODO(#8410): Remove this comment once we've fully migrated to +// salesforce.Exporter. + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 @@ -20,8 +26,8 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Exporter_SendContacts_FullMethodName = "/email.Exporter/SendContacts" - Exporter_SendCase_FullMethodName = "/email.Exporter/SendCase" + Exporter_SendContacts_FullMethodName = "/salesforce.Exporter/SendContacts" + Exporter_SendCase_FullMethodName = "/salesforce.Exporter/SendCase" ) // ExporterClient is the client API for Exporter service. @@ -143,7 +149,7 @@ func _Exporter_SendCase_Handler(srv interface{}, ctx context.Context, dec func(i // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Exporter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "email.Exporter", + ServiceName: "salesforce.Exporter", HandlerType: (*ExporterServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/sfe/overrides.go b/sfe/overrides.go index fd7589e60e1..08f60284313 100644 --- a/sfe/overrides.go +++ b/sfe/overrides.go @@ -12,11 +12,11 @@ import ( "strconv" "strings" - emailpb "github.com/letsencrypt/boulder/email/proto" berrors "github.com/letsencrypt/boulder/errors" "github.com/letsencrypt/boulder/iana" "github.com/letsencrypt/boulder/policy" rl "github.com/letsencrypt/boulder/ratelimits" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" "github.com/letsencrypt/boulder/sfe/forms" "github.com/letsencrypt/boulder/sfe/zendesk" "github.com/letsencrypt/boulder/web" @@ -723,14 +723,14 @@ func (sfe *SelfServiceFrontEndImpl) submitOverrideRequestHandler(w http.Response } if sfe.ee != nil && validFields[mailingListFieldName] == "true" { - _, err := sfe.ee.SendContacts(r.Context(), &emailpb.SendContactsRequest{Emails: []string{validFields[emailAddressFieldName]}}) + _, err := sfe.ee.SendContacts(r.Context(), &salesforcepb.SendContactsRequest{Emails: []string{validFields[emailAddressFieldName]}}) if err != nil { sfe.log.Errf("sending contact to email-exporter: %s", err) } } if sfe.ee != nil && validFields[fundraisingFieldName] == fundraisingYesOption { - _, err := sfe.ee.SendCase(r.Context(), &emailpb.SendCaseRequest{ + _, err := sfe.ee.SendCase(r.Context(), &salesforcepb.SendCaseRequest{ Origin: "Web", Subject: fmt.Sprintf("%s rate limit override request for %s", req.RateLimit, validFields[OrganizationFieldName]), ContactEmail: validFields[emailAddressFieldName], diff --git a/sfe/sfe.go b/sfe/sfe.go index 99dc11d0a94..3dee66520e4 100644 --- a/sfe/sfe.go +++ b/sfe/sfe.go @@ -18,12 +18,12 @@ import ( "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "github.com/letsencrypt/boulder/core" - emailpb "github.com/letsencrypt/boulder/email/proto" blog "github.com/letsencrypt/boulder/log" "github.com/letsencrypt/boulder/metrics/measured_http" rapb "github.com/letsencrypt/boulder/ra/proto" rl "github.com/letsencrypt/boulder/ratelimits" sapb "github.com/letsencrypt/boulder/sa/proto" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" "github.com/letsencrypt/boulder/sfe/zendesk" "github.com/letsencrypt/boulder/unpause" ) @@ -57,7 +57,7 @@ var ( type SelfServiceFrontEndImpl struct { ra rapb.RegistrationAuthorityClient sa sapb.StorageAuthorityReadOnlyClient - ee emailpb.ExporterClient + ee salesforcepb.ExporterClient log blog.Logger clk clock.Clock @@ -87,7 +87,7 @@ func NewSelfServiceFrontEndImpl( requestTimeout time.Duration, rac rapb.RegistrationAuthorityClient, sac sapb.StorageAuthorityReadOnlyClient, - eec emailpb.ExporterClient, + eec salesforcepb.ExporterClient, unpauseHMACKey []byte, zendeskClient *zendesk.Client, limiter *rl.Limiter, diff --git a/test/config-next/email-exporter.json b/test/config-next/email-exporter.json index fd6a93ca35a..552a57b6e85 100644 --- a/test/config-next/email-exporter.json +++ b/test/config-next/email-exporter.json @@ -11,6 +11,12 @@ "sfe.boulder" ] }, + "salesforce.Exporter": { + "clientNames": [ + "wfe.boulder", + "sfe.boulder" + ] + }, "grpc.health.v1.Health": { "clientNames": [ "health-checker.boulder" diff --git a/test/config/pardot-test-srv.json b/test/config-next/salesforce-test-srv.json similarity index 80% rename from test/config/pardot-test-srv.json rename to test/config-next/salesforce-test-srv.json index ee5c035fbf5..a98fe419962 100644 --- a/test/config/pardot-test-srv.json +++ b/test/config-next/salesforce-test-srv.json @@ -1,5 +1,5 @@ { - "oauthAddr": ":9601", + "salesforceAddr": ":9601", "pardotAddr": ":9602", "expectedClientId": "test-client-id", "expectedClientSecret": "you-shall-not-pass" diff --git a/test/config-next/pardot-test-srv.json b/test/config/salesforce-test-srv.json similarity index 100% rename from test/config-next/pardot-test-srv.json rename to test/config/salesforce-test-srv.json diff --git a/test/integration/email_exporter_test.go b/test/integration/email_exporter_test.go index bd358494fca..3bffaea7a10 100644 --- a/test/integration/email_exporter_test.go +++ b/test/integration/email_exporter_test.go @@ -34,7 +34,7 @@ func randomDomain(t *testing.T) string { return fmt.Sprintf("%x.mail.com", bytes[:]) } -// getOAuthToken queries the pardot-test-srv for the current OAuth token. +// getOAuthToken queries the salesforce-test-srv for the current OAuth token. func getOAuthToken(t *testing.T) string { t.Helper() @@ -65,7 +65,7 @@ func getOAuthToken(t *testing.T) string { return response.AccessToken } -// getCreatedContacts queries the pardot-test-srv for the list of created +// getCreatedContacts queries the salesforce-test-srv for the list of created // contacts. func getCreatedContacts(t *testing.T, token string) []string { t.Helper() @@ -90,7 +90,7 @@ func getCreatedContacts(t *testing.T, token string) []string { } // assertAllContactsReceived waits for the expected contacts to be received by -// pardot-test-srv. Retries every 50ms for up to 2 seconds and fails if the +// salesforce-test-srv. Retries every 50ms for up to 2 seconds and fails if the // expected contacts are not received. func assertAllContactsReceived(t *testing.T, token string, expect []string) { t.Helper() @@ -112,13 +112,13 @@ func assertAllContactsReceived(t *testing.T, token string, expect []string) { break } if attempt >= 19 { - t.Fatalf("Expected contacts=%v to be received by pardot-test-srv, got contacts=%v", expect, got) + t.Fatalf("Expected contacts=%v to be received by salesforce-test-srv, got contacts=%v", expect, got) } } } // TestContactsSentForNewAccount tests that contacts are dispatched to -// pardot-test-srv by the email-exporter when a new account is created. +// salesforce-test-srv by the email-exporter when a new account is created. func TestContactsSentForNewAccount(t *testing.T) { t.Parallel() @@ -167,7 +167,7 @@ func TestContactsSentForNewAccount(t *testing.T) { } } -// getCreatedCases queries the pardot-test-srv for the list of created cases. +// getCreatedCases queries the salesforce-test-srv for the list of created cases. // Fails the test on error. func getCreatedCases(t *testing.T, token string) []map[string]any { t.Helper() @@ -189,7 +189,7 @@ func getCreatedCases(t *testing.T, token string) []map[string]any { return got.Cases } -// createCase sends a request to create a new case via pardot-test-srv and +// createCase sends a request to create a new case via salesforce-test-srv and // returns the HTTP status code and response body. Fails the test on error. func createCase(t *testing.T, token string, payload map[string]any) (int, []byte) { t.Helper() diff --git a/test/pardot-test-srv/main.go b/test/salesforce-test-srv/main.go similarity index 96% rename from test/pardot-test-srv/main.go rename to test/salesforce-test-srv/main.go index 8206effb6e0..ac34953bf2a 100644 --- a/test/pardot-test-srv/main.go +++ b/test/salesforce-test-srv/main.go @@ -263,15 +263,15 @@ func main() { oauthMux.HandleFunc("/services/oauth2/token", ts.getTokenHandler) oauthMux.HandleFunc("/services/data/v64.0/sobjects/Case", ts.createCaseHandler) oauthMux.HandleFunc("/cases", ts.queryCasesHandler) - oauthServer := &http.Server{ + salesforceServer := &http.Server{ Addr: c.SalesforceAddr, Handler: oauthMux, ReadTimeout: 30 * time.Second, } - log.Printf("pardot-test-srv Salesforce REST API and OAuth server listening at %s", c.SalesforceAddr) + log.Printf("salesforce-test-srv Salesforce REST API and OAuth server listening at %s", c.SalesforceAddr) go func() { - err := oauthServer.ListenAndServe() + err := salesforceServer.ListenAndServe() if err != nil { log.Fatalf("Failed to start Salesforce REST API and OAuth server: %s", err) } @@ -287,7 +287,7 @@ func main() { Handler: pardotMux, ReadTimeout: 30 * time.Second, } - log.Printf("pardot-test-srv Salesforce Pardot API server listening at %s", c.PardotAddr) + log.Printf("salesforce-test-srv Salesforce Pardot API server listening at %s", c.PardotAddr) go func() { err := pardotServer.ListenAndServe() if err != nil { diff --git a/test/startservers.py b/test/startservers.py index cdfcad084b5..2c0e25510d0 100644 --- a/test/startservers.py +++ b/test/startservers.py @@ -116,16 +116,16 @@ 8112, '10.77.77.77:9401', 'nonce.boulder', ('./bin/boulder', 'nonce-service', '--config', os.path.join(config_dir, 'nonce-b.json'), '--addr', '10.77.77.77:9401', '--debug-addr', ':8112',), None), - Service('pardot-test-srv', + Service('salesforce-test-srv', # Uses port 9601 to mock Salesforce OAuth2 token API and 9602 to mock # the Pardot API. 9601, None, None, - ('./bin/pardot-test-srv', '--config', os.path.join(config_dir, 'pardot-test-srv.json'),), + ('./bin/salesforce-test-srv', '--config', os.path.join(config_dir, 'salesforce-test-srv.json'),), None), Service('email-exporter', 8114, None, None, ('./bin/boulder', 'email-exporter', '--config', os.path.join(config_dir, 'email-exporter.json'), '--addr', ':9603', '--debug-addr', ':8114'), - ('pardot-test-srv',)), + ('salesforce-test-srv',)), Service('boulder-wfe2', 4001, None, None, ('./bin/boulder', 'boulder-wfe2', '--config', os.path.join(config_dir, 'wfe2.json'), '--addr', ':4001', '--tls-addr', ':4431', '--debug-addr', ':8013'), diff --git a/wfe2/wfe.go b/wfe2/wfe.go index efe2c6d087a..80be0caad56 100644 --- a/wfe2/wfe.go +++ b/wfe2/wfe.go @@ -27,7 +27,6 @@ import ( "github.com/letsencrypt/boulder/core" corepb "github.com/letsencrypt/boulder/core/proto" - emailpb "github.com/letsencrypt/boulder/email/proto" berrors "github.com/letsencrypt/boulder/errors" "github.com/letsencrypt/boulder/features" "github.com/letsencrypt/boulder/goodkey" @@ -44,6 +43,7 @@ import ( "github.com/letsencrypt/boulder/ratelimits" "github.com/letsencrypt/boulder/revocation" sapb "github.com/letsencrypt/boulder/sa/proto" + salesforcepb "github.com/letsencrypt/boulder/salesforce/proto" "github.com/letsencrypt/boulder/unpause" "github.com/letsencrypt/boulder/web" ) @@ -91,7 +91,7 @@ var errIncompleteGRPCResponse = errors.New("incomplete gRPC response message") type WebFrontEndImpl struct { ra rapb.RegistrationAuthorityClient sa sapb.StorageAuthorityReadOnlyClient - ee emailpb.ExporterClient + ee salesforcepb.ExporterClient // gnc is a nonce-service client used exclusively for the issuance of // nonces. It's configured to route requests to backends colocated with the // WFE. @@ -182,7 +182,7 @@ func NewWebFrontEndImpl( maxContactsPerReg int, rac rapb.RegistrationAuthorityClient, sac sapb.StorageAuthorityReadOnlyClient, - eec emailpb.ExporterClient, + eec salesforcepb.ExporterClient, gnc nonce.Getter, rnc nonce.Redeemer, rncKey []byte, @@ -906,7 +906,7 @@ func (wfe *WebFrontEndImpl) NewAccount( newRegistrationSuccessful = true if wfe.ee != nil && len(emails) > 0 { - _, err := wfe.ee.SendContacts(ctx, &emailpb.SendContactsRequest{ + _, err := wfe.ee.SendContacts(ctx, &salesforcepb.SendContactsRequest{ // Note: We are explicitly using the contacts provided by the // subscriber here. The RA will eventually stop accepting contacts. Emails: emails,