From a0942422fe60d355a65e2516904eb666c6e30aa0 Mon Sep 17 00:00:00 2001 From: Gabe <7622243+decentralgabe@users.noreply.github.com> Date: Wed, 23 Aug 2023 08:35:16 -0700 Subject: [PATCH] Status 2 (#668) * tmp * fix tests * fix int test * fix config --- integration/common.go | 8 +------- pkg/server/server.go | 18 +++++++++--------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/integration/common.go b/integration/common.go index 6de315f1e..2d9b0800c 100644 --- a/integration/common.go +++ b/integration/common.go @@ -20,17 +20,15 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/tbd54566975/ssi-service/config" credmodel "github.com/tbd54566975/ssi-service/internal/credential" "github.com/tbd54566975/ssi-service/internal/keyaccess" "github.com/tbd54566975/ssi-service/internal/util" "github.com/tbd54566975/ssi-service/pkg/server/router" - "github.com/tbd54566975/ssi-service/pkg/service/framework" ) const ( // Note: for local testing change this to port 3000 - endpoint = "http://localhost:8080/" + endpoint = "http://localhost:3000/" version = "v1/" MaxElapsedTime = 120 * time.Second ) @@ -47,10 +45,6 @@ func init() { DisableQuote: true, ForceColors: true, }) - - config.SetAPIBase(endpoint) - config.SetServicePath(framework.Credential, "/credentials") - config.SetServicePath(framework.Schema, "/schemas") } type didConfigurationResourceParams struct { diff --git a/pkg/server/server.go b/pkg/server/server.go index 0749e62f3..b4d7dd9b0 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -69,13 +69,6 @@ func NewSSIServer(shutdown chan os.Signal, cfg config.SSIServiceConfig) (*SSISer // make sure to set the api base in our service info config.SetAPIBase(cfg.Services.ServiceEndpoint) - // allows for a custom URI to be used for status list credentials, if not set, we use the default path - if cfg.Services.StatusEndpoint != "" { - config.SetStatusBase(cfg.Services.StatusEndpoint) - } else { - config.SetStatusBase(fmt.Sprintf("%s/status", config.GetServicePath(svcframework.Credential))) - } - // service-level routers engine.GET(HealthPrefix, router.Health) engine.GET(ReadinessPrefix, router.Readiness(ssi.GetServices())) @@ -93,7 +86,7 @@ func NewSSIServer(shutdown chan os.Signal, cfg config.SSIServiceConfig) (*SSISer if err = SchemaAPI(v1, ssi.Schema, ssi.Webhook); err != nil { return nil, sdkutil.LoggingErrorMsg(err, "unable to instantiate Schema API") } - if err = CredentialAPI(v1, ssi.Credential, ssi.Webhook); err != nil { + if err = CredentialAPI(v1, ssi.Credential, ssi.Webhook, cfg.Services.StatusEndpoint); err != nil { return nil, sdkutil.LoggingErrorMsg(err, "unable to instantiate Credential API") } if err = OperationAPI(v1, ssi.Operation); err != nil { @@ -207,7 +200,7 @@ func SchemaAPI(rg *gin.RouterGroup, service svcframework.Service, webhookService } // CredentialAPI registers all HTTP handlers for the Credentials Service -func CredentialAPI(rg *gin.RouterGroup, service svcframework.Service, webhookService *webhook.Service) (err error) { +func CredentialAPI(rg *gin.RouterGroup, service svcframework.Service, webhookService *webhook.Service, statusEndpoint string) (err error) { credRouter, err := router.NewCredentialRouter(service) if err != nil { return sdkutil.LoggingErrorMsg(err, "creating credential router") @@ -216,6 +209,13 @@ func CredentialAPI(rg *gin.RouterGroup, service svcframework.Service, webhookSer // make sure the credential service is configured to use the correct path config.SetServicePath(svcframework.Credential, CredentialsPrefix) + // allows for a custom URI to be used for status list credentials, if not set, we use the default path + if statusEndpoint != "" { + config.SetStatusBase(statusEndpoint) + } else { + config.SetStatusBase(fmt.Sprintf("%s/status", config.GetServicePath(svcframework.Credential))) + } + // Credentials credentialAPI := rg.Group(CredentialsPrefix) credentialAPI.PUT("", middleware.Webhook(webhookService, webhook.Credential, webhook.Create), credRouter.CreateCredential)