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

remove deprecated service #780

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
8 changes: 0 additions & 8 deletions data/service/service/client_test.go
ewollesen marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

11 changes: 0 additions & 11 deletions data/service/service/service_suite_test.go

This file was deleted.

12 changes: 6 additions & 6 deletions data/service/service/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"log"
"os"

"github.com/tidepool-org/platform/clinics"

"github.com/IBM/sarama"

eventsCommon "github.com/tidepool-org/go-common/events"

"github.com/tidepool-org/platform/application"
"github.com/tidepool-org/platform/clinics"
dataDeduplicatorDeduplicator "github.com/tidepool-org/platform/data/deduplicator/deduplicator"
dataDeduplicatorFactory "github.com/tidepool-org/platform/data/deduplicator/factory"
dataEvents "github.com/tidepool-org/platform/data/events"
Expand All @@ -34,7 +34,7 @@ import (
)

type Standard struct {
*service.DEPRECATEDService
*service.Authenticated
metricClient *metricClient.Client
permissionClient *permissionClient.Client
dataDeduplicatorFactory *dataDeduplicatorFactory.Factory
Expand All @@ -51,12 +51,12 @@ type Standard struct {

func NewStandard() *Standard {
return &Standard{
DEPRECATEDService: service.NewDEPRECATEDService(),
Authenticated: service.NewAuthenticated(),
}
}

func (s *Standard) Initialize(provider application.Provider) error {
if err := s.DEPRECATEDService.Initialize(provider); err != nil {
if err := s.Service.Initialize(provider); err != nil {
return err
}

Expand Down Expand Up @@ -128,7 +128,7 @@ func (s *Standard) Terminate() {
s.permissionClient = nil
s.metricClient = nil

s.DEPRECATEDService.Terminate()
s.Authenticated.Terminate()
}

func (s *Standard) Run() error {
Expand Down
8 changes: 0 additions & 8 deletions data/service/service/standard_test.go

This file was deleted.

93 changes: 0 additions & 93 deletions service/service/DEPRECATED_service.go

This file was deleted.

128 changes: 0 additions & 128 deletions service/service/DEPRECATED_service_test.go

This file was deleted.

80 changes: 80 additions & 0 deletions service/service/authenticated_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,88 @@
package service_test

import (
"net/http"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/ghttp"

applicationTest "github.com/tidepool-org/platform/application/test"
authTest "github.com/tidepool-org/platform/auth/test"
configTest "github.com/tidepool-org/platform/config/test"
serviceService "github.com/tidepool-org/platform/service/service"
)

var _ = Describe("Authenticated", func() {

var provider *applicationTest.Provider
var svc *serviceService.Authenticated
var serverSecret string
var sessionToken string
var authClientConfig map[string]interface{}
var serviceConfig map[string]interface{}
var serverConfig map[string]interface{}
var testServer *Server

BeforeEach(func() {
provider = applicationTest.NewProviderWithDefaults()

serverSecret = authTest.NewServiceSecret()
sessionToken = authTest.NewSessionToken()

testServer = NewServer()
testServer.AppendHandlers(
CombineHandlers(
VerifyRequest("POST", "/auth/serverlogin"),
VerifyHeaderKV("X-Tidepool-Server-Name", *provider.NameOutput),
VerifyHeaderKV("X-Tidepool-Server-Secret", serverSecret),
VerifyBody(nil),
RespondWith(http.StatusOK, nil, http.Header{"X-Tidepool-Session-Token": []string{sessionToken}})),
)

authClientConfig = map[string]interface{}{
"address": testServer.URL(),
"server_token_secret": authTest.NewServiceSecret(),
"external": map[string]interface{}{
"address": testServer.URL(),
"server_session_token_secret": serverSecret,
},
}
serverConfig = map[string]interface{}{
"address": testServer.URL(),
"tls": "false",
}
serviceConfig = map[string]interface{}{
"secret": authTest.NewServiceSecret(),
"server": serverConfig,
"auth": map[string]interface{}{
"client": authClientConfig,
},
}
(*provider.ConfigReporterOutput).(*configTest.Reporter).Config = serviceConfig

svc = serviceService.NewAuthenticated()
Expect(svc).ToNot(BeNil())

Expect(svc.Initialize(provider)).To(Succeed())
})

AfterEach(func() {
if svc != nil {
svc.Terminate()
}
provider.AssertOutputsEmpty()
})

It("returns the secret", func() {
Expect(svc.Secret()).To(Equal(serviceConfig["secret"]))
})

Context("AuthClient", func() {
It("returns successfully with server token", func() {
authClient := svc.AuthClient()
Expect(authClient).ToNot(BeNil())
Eventually(authClient.ServerSessionToken).Should(Equal(sessionToken))
})
})
})