diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 5a4e3f869..3ee947942 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -50,4 +50,4 @@ dist: build env: - GO111MODULE=on - CGO_ENABLED=0 - - LS_PROTOCOL_VERSION=16 + - LS_PROTOCOL_VERSION=17 diff --git a/README.md b/README.md index 56ba0d986..fcebb3ed2 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,8 @@ Right now the language server supports the following actions: - example: ```json5 { - "token": "the snyk token" // this can be an oauth2.Token string or a legacy token + "token": "the snyk token", // this can be an oauth2.Token string or a legacy token + "apiUrl": "https://api.snyk.io" } ``` - See https://pkg.go.dev/golang.org/x/oauth2@v0.6.0#Token for more details regarding oauth tokens. @@ -197,17 +198,6 @@ Right now the language server supports the following actions: } ``` -- Diagnostics Overview (tabbed tree view) - - method: `$/snyk.diagnosticsOverview` - - params: `types.DiagnosticsOverviewParams` - - example: - ```json5 - { - "product": "oss", // or "code" or "iac" - "html": "...", // the html to display the overview tabs/tree - } - ``` - - Trusted Folder Notification - method: `$/snyk.addTrustedFolders` - params: `types.SnykTrustedFoldersParams` diff --git a/application/server/execute_command_test.go b/application/server/execute_command_test.go index e41dc04d0..fdae0c1d3 100644 --- a/application/server/execute_command_test.go +++ b/application/server/execute_command_test.go @@ -147,7 +147,12 @@ func Test_loginCommand_StartsAuthentication(t *testing.T) { assert.NotEmpty(t, tokenResponse.ResultString()) assert.True(t, fakeAuthenticationProvider.IsAuthenticated) assert.Eventually(t, func() bool { return len(jsonRPCRecorder.Notifications()) > 0 }, 5*time.Second, 50*time.Millisecond) - assert.Equal(t, 1, len(jsonRPCRecorder.FindNotificationsByMethod("$/snyk.hasAuthenticated"))) + notifications := jsonRPCRecorder.FindNotificationsByMethod("$/snyk.hasAuthenticated") + assert.Equal(t, 1, len(notifications)) + var hasAuthenticatedNotification types.AuthenticationParams + err = notifications[0].UnmarshalParams(&hasAuthenticatedNotification) + assert.NoError(t, err) + assert.NotEmpty(t, hasAuthenticatedNotification.ApiUrl) } func Test_TrustWorkspaceFolders(t *testing.T) { diff --git a/application/server/notification.go b/application/server/notification.go index 793cb329d..734bbce7f 100644 --- a/application/server/notification.go +++ b/application/server/notification.go @@ -100,21 +100,6 @@ func registerNotifier(c *config.Config, srv types.Server) { case sglsp.ShowMessageParams: notifier(c, srv, "window/showMessage", params) logger.Debug().Interface("message", params).Msg("showing message") - case types.DiagnosticsOverviewParams: - logger.Debug(). - Msgf("received diagnostics overview for %s, discarding", params.Product) - case types.PublishDiagnosticsParams: - notifier(c, srv, "textDocument/publishDiagnostics", params) - notifier(c, srv, "$/snyk.publishDiagnostics316", params) - source := "LSP" - if len(params.Diagnostics) > 0 { - source = params.Diagnostics[0].Source - } - logger.Debug(). - Interface("documentURI", params.URI). - Interface("source", source). - Interface("diagnosticCount", len(params.Diagnostics)). - Msg("publishing diagnostics") case types.SnykTrustedFoldersParams: notifier(c, srv, "$/snyk.addTrustedFolders", params) logger.Info(). @@ -130,6 +115,18 @@ func registerNotifier(c *config.Config, srv types.Server) { // Function blocks on callback, so we need to run it in a separate goroutine go handleShowMessageRequest(srv, params, &logger) logger.Debug().Msg("sending show message request to client") + case types.PublishDiagnosticsParams: + notifier(c, srv, "textDocument/publishDiagnostics", params) + notifier(c, srv, "$/snyk.publishDiagnostics316", params) + source := "LSP" + if len(params.Diagnostics) > 0 { + source = params.Diagnostics[0].Source + } + logger.Debug(). + Interface("documentURI", params.URI). + Interface("source", source). + Interface("diagnosticCount", len(params.Diagnostics)). + Msg("publishing diagnostics") case types.ApplyWorkspaceEditParams: handleApplyWorkspaceEdit(srv, params, &logger) logger.Debug(). diff --git a/application/server/notification_test.go b/application/server/notification_test.go index 6b8053f42..a7e9302d9 100644 --- a/application/server/notification_test.go +++ b/application/server/notification_test.go @@ -144,7 +144,7 @@ func Test_NotifierShouldSendNotificationToClient(t *testing.T) { if err != nil { t.Fatal(err) } - var expected = types.AuthenticationParams{Token: "test token"} + var expected = types.AuthenticationParams{Token: "test token", ApiUrl: "https://api.snyk.io"} di.Notifier().Send(expected) assert.Eventually( diff --git a/domain/ide/workspace/folder.go b/domain/ide/workspace/folder.go index e7e31c307..a9c6cdfb6 100644 --- a/domain/ide/workspace/folder.go +++ b/domain/ide/workspace/folder.go @@ -25,7 +25,6 @@ import ( "github.com/sourcegraph/go-lsp" - "github.com/snyk/snyk-ls/domain/ide/workspace/ui" "github.com/snyk/snyk-ls/domain/snyk" delta2 "github.com/snyk/snyk-ls/domain/snyk/delta" "github.com/snyk/snyk-ls/domain/snyk/persistence" @@ -614,7 +613,6 @@ func isVisibleSeverity(issue snyk.Issue) bool { func (f *Folder) publishDiagnostics(product product.Product, issuesByFile snyk.IssuesByFile) { f.sendHovers(issuesByFile) f.sendDiagnostics(issuesByFile) - ui.SendDiagnosticsOverview(f.c, product, issuesByFile, f.notifier) f.sendSuccess(product) } diff --git a/domain/ide/workspace/ui/diagnostics_overview.go b/domain/ide/workspace/ui/diagnostics_overview.go deleted file mode 100644 index b926666e0..000000000 --- a/domain/ide/workspace/ui/diagnostics_overview.go +++ /dev/null @@ -1,196 +0,0 @@ -/* - * © 2024 Snyk Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ui - -import ( - "bytes" - _ "embed" - "fmt" - "html/template" - "sync" - - "github.com/snyk/snyk-ls/application/config" - "github.com/snyk/snyk-ls/domain/snyk" - "github.com/snyk/snyk-ls/internal/html" - "github.com/snyk/snyk-ls/internal/notification" - "github.com/snyk/snyk-ls/internal/product" - "github.com/snyk/snyk-ls/internal/types" -) - -//go:embed template/diagnosticsOverview.html -var diagnosticsOverviewTemplatePath string - -//go:embed template/diagnosticsOverview.css -var diagnosticsOverviewTemplateCSS string -var diagnosticsOverviewTemplate *template.Template -var templateParsingMutex sync.RWMutex - -type TemplateData struct { - // Root nodes - RootNodes []Node - // File node with underlying slice of issue nodes - Issues map[Node][]Node - Styles template.CSS - Nonce template.HTML - DeltaFindingsEnabled bool -} - -// Node represents a tree node -type Node struct { - Icon template.HTML - Text template.HTML - ProductEnabled bool -} - -func SendDiagnosticsOverview(c *config.Config, p product.Product, issuesByFile snyk.IssuesByFile, notifier notification.Notifier) { - logger := c.Logger().With().Str("method", "ui.SendDiagnosticsOverview").Logger() - err := initializeTemplate() - if err != nil { - logger.Err(err).Msg("failed to initialize diagnostics overview template. Not sending overview") - return - } - - if p == "" { - logger.Warn().Str("method", "ui.sendDiagnosticsOverview").Msg("no product specified, this is unexpected") - return - } - - rootNodes := getRootNodes(c, p, issuesByFile) - nonce, err := html.GenerateSecurityNonce() - if err != nil { - logger.Err(err).Msgf("Failed to generate nonce") - return - } - - fileNodes := getFileNodes(issuesByFile) - - data := TemplateData{ - RootNodes: rootNodes, - Issues: fileNodes, - Styles: template.CSS(diagnosticsOverviewTemplateCSS), - Nonce: template.HTML(nonce), - DeltaFindingsEnabled: c.IsDeltaFindingsEnabled(), - } - - var htmlBuffer bytes.Buffer - if err = diagnosticsOverviewTemplate.Execute(&htmlBuffer, data); err != nil { - logger.Error().Msgf("Failed to generate tree htmlBuffer with tree template: %v", err) - return - } - - diagnosticsOverviewParams := types.DiagnosticsOverviewParams{Product: p.ToProductCodename(), Html: htmlBuffer.String()} - notifier.Send(diagnosticsOverviewParams) - logger.Debug().Msgf("sent diagnostics overview htmlBuffer for product %s", p) - logger.Trace(). - Int("issueCount", len(issuesByFile)). - Any("diagnosticsOverviewParams", diagnosticsOverviewParams). - Msg("detailed tree data") -} - -func initializeTemplate() error { - templateParsingMutex.RLock() - if diagnosticsOverviewTemplate == nil { - templateParsingMutex.RUnlock() - templateParsingMutex.Lock() - defer templateParsingMutex.Unlock() - - funcMap := map[string]any{} - var err error - - diagnosticsOverviewTemplate, err = template.New("diagnosticsOverviewTemplate").Funcs(funcMap).Parse(diagnosticsOverviewTemplatePath) - if err != nil { - return err - } - } - return nil -} - -func getFileNodes(issuesByFile snyk.IssuesByFile) map[Node][]Node { - fileNodes := make(map[Node][]Node) - for path, issues := range issuesByFile { - fileNode := Node{ - Icon: getFileTypeIcon(), - Text: template.HTML(path), - } - issueNodes := []Node{} - for _, issue := range issues { - issueNodes = append(issueNodes, Node{ - Icon: html.SeverityIcon(issue), - Text: template.HTML(issue.AdditionalData.GetTitle()), - }) - } - fileNodes[fileNode] = issueNodes - } - return fileNodes -} - -func getFileTypeIcon() template.HTML { - return "" -} - -func getRootNodes(c *config.Config, p product.Product, issuesByFile snyk.IssuesByFile) []Node { - var icon template.HTML - - productEnabled := c.IsProductEnabled(p) - if productEnabled { - icon = html.GetProductIcon(p) - } else { - icon = html.GetProductIconDisabled(p) - } - - rootNodeTitle := getRootNodeText(issuesByFile, p) - - rootNodes := append([]Node{}, Node{ - Icon: icon, - Text: template.HTML(rootNodeTitle), - ProductEnabled: productEnabled, - }) - - fixableCount := issuesByFile.FixableCount() - if fixableCount > 0 { - plural := "" - if fixableCount > 1 { - plural = "s" - } - rootNodes = append(rootNodes, Node{ - Text: template.HTML(fmt.Sprintf("⚡️ %d issue%s can be fixed automatically", fixableCount, plural)), - }) - } - - return rootNodes -} - -func getRootNodeText(issuesByFile snyk.IssuesByFile, p product.Product) string { - total, critical, high, medium, low := issuesByFile.SeverityCounts() - - pluralSuffix := "" - if total > 1 { - pluralSuffix = "s" - } - - var rootNodeTitle = fmt.Sprintf("%s - No issues found", p.ToFilterableIssueType()[0]) - if total > 0 { - rootNodeTitle = fmt.Sprintf( - "%s - %d unique issue%s: %s", - p.ToFilterableIssueType()[0], - total, - pluralSuffix, - issuesByFile.SeverityCountsAsString(critical, high, medium, low), - ) - } - return rootNodeTitle -} diff --git a/domain/ide/workspace/ui/diagnostics_overview_test.go b/domain/ide/workspace/ui/diagnostics_overview_test.go deleted file mode 100644 index b7958a039..000000000 --- a/domain/ide/workspace/ui/diagnostics_overview_test.go +++ /dev/null @@ -1,124 +0,0 @@ -/* - * © 2024 Snyk Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ui - -import ( - "encoding/json" - "testing" - "time" - - "github.com/google/uuid" - "github.com/stretchr/testify/require" - - "github.com/snyk/snyk-ls/domain/snyk" - "github.com/snyk/snyk-ls/internal/notification" - "github.com/snyk/snyk-ls/internal/product" - "github.com/snyk/snyk-ls/internal/testutil" - "github.com/snyk/snyk-ls/internal/types" -) - -func Test_DiagnosticsOverview(t *testing.T) { - t.Run("sends notification", func(t *testing.T) { - c := testutil.UnitTest(t) - issuesByFile := snyk.IssuesByFile{} - notifier := notification.NewNotifier() - notificationChannel := make(chan bool) - callback := func(params any) { - switch params.(type) { - case types.DiagnosticsOverviewParams: - notificationChannel <- true - } - } - notifier.CreateListener(callback) - - SendDiagnosticsOverview(c, product.ProductOpenSource, issuesByFile, notifier) - - require.Eventually(t, func() bool { - <-notificationChannel - return true - }, time.Second*5, time.Millisecond) - }) - - t.Run("adds unordered list for issues", func(t *testing.T) { - c := testutil.UnitTest(t) - issuesByFile := snyk.IssuesByFile{} - expectedTitle := "Fixable Great Title!" - issuesByFile["file1"] = getTestIssues(t, true, expectedTitle) - - notifier := notification.NewNotifier() - notificationChannel := make(chan bool) - callback := func(params any) { - switch p := params.(type) { - case types.DiagnosticsOverviewParams: - require.Equal(t, product.ProductOpenSource.ToProductCodename(), p.Product) - require.Contains(t, p.Html, "1 unique issue: 1 critical") - require.Contains(t, p.Html, expectedTitle) - notificationChannel <- true - } - } - notifier.CreateListener(callback) - - SendDiagnosticsOverview(c, product.ProductOpenSource, issuesByFile, notifier) - - require.Eventually(t, func() bool { - <-notificationChannel - return true - }, time.Second*5, time.Millisecond) - }) -} - -type mockAddData struct { - isFixable bool - key string - title string - filterableIssueType product.FilterableIssueType -} - -func (m mockAddData) MarshalJSON() ([]byte, error) { - return json.Marshal(m) -} - -func (m mockAddData) GetKey() string { - return m.key -} - -func (m mockAddData) GetTitle() string { - return m.title -} - -func (m mockAddData) IsFixable() bool { - return m.isFixable -} -func (m mockAddData) GetFilterableIssueType() product.FilterableIssueType { - return m.filterableIssueType -} - -func getTestIssues(t *testing.T, isFixable bool, title string) []snyk.Issue { - t.Helper() - return []snyk.Issue{ - { - ID: "id1", - Severity: snyk.Critical, - Message: "message1", - AdditionalData: mockAddData{ - title: title, - key: uuid.NewString(), - isFixable: isFixable, - filterableIssueType: product.FilterableIssueTypeOpenSource, - }, - }} -} diff --git a/domain/ide/workspace/ui/template/diagnosticsOverview.css b/domain/ide/workspace/ui/template/diagnosticsOverview.css deleted file mode 100644 index 2b75808bc..000000000 --- a/domain/ide/workspace/ui/template/diagnosticsOverview.css +++ /dev/null @@ -1,66 +0,0 @@ -.issues-overview {} - -.main-tabs-nav, -.tabs-nav { - display: flex; - list-style-type: none; - overflow: hidden; - padding: 0; -} - -.tab-content { - display: none; - border-top-style: hidden; -} - -.tab-content.is-selected { - display: block; -} - -.tab-item-icon { - vertical-align: middle; -} - -.tab-item { - font-weight: 500; - float: left; - display: block; - text-align: center; - padding: 10px 16px 8px 16px; - text-decoration: none; - margin-right: 4px; - cursor: pointer; - transition: background-color 0.3s, border-color 0.3s; -} - -.tab-item-icon { - color: inherit; -} - -.sn-tree {} - -.sn-list {} - -.sn-list-item {} - -.is-clickable-true { - cursor: pointer; -} - -.is-clickable-false { - cursor: not-allowed; -} - -.sn-icon {} - -.sn-label {} - -.sn-list-item.is-expandable {} - -.sn-list-item.is-expanded .sn-list { - display: block; -} - -.sn-list-item .sn-list { - display: none; -} diff --git a/domain/ide/workspace/ui/template/diagnosticsOverview.html b/domain/ide/workspace/ui/template/diagnosticsOverview.html deleted file mode 100644 index ad51b7612..000000000 --- a/domain/ide/workspace/ui/template/diagnosticsOverview.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
- -
-
- - All Issues - - - Net new issues - -
- - -
- -
-
-
- -
    - {{range $index, $node := .RootNodes}} -
  • - {{$node.Icon}}{{$node.Text}} -
  • - {{ end }} -
- - -
    - {{range $node, $issueNodes := .Issues}} - - {{ end }} -
-
-
- -
- - -
-
- -
-
-
- - - - - diff --git a/infrastructure/authentication/auth_service_impl.go b/infrastructure/authentication/auth_service_impl.go index c1f06de75..d70077277 100644 --- a/infrastructure/authentication/auth_service_impl.go +++ b/infrastructure/authentication/auth_service_impl.go @@ -26,6 +26,8 @@ import ( "sync" "time" + "github.com/snyk/go-application-framework/pkg/configuration" + "github.com/erni27/imcache" "github.com/rs/zerolog" sglsp "github.com/sourcegraph/go-lsp" @@ -68,14 +70,53 @@ func (a *AuthenticationServiceImpl) Provider() AuthenticationProvider { func (a *AuthenticationServiceImpl) Authenticate(ctx context.Context) (token string, err error) { token, err = a.provider.Authenticate(ctx) + if token == "" || err != nil { a.c.Logger().Warn().Err(err).Msgf("Failed to authenticate using auth provider %v", reflect.TypeOf(a.provider)) return token, err } + + customUrl := a.c.SnykApi() + engineUrl := a.c.Engine().GetConfiguration().GetString(configuration.API_URL) + prioritizedUrl := getPrioritizedApiUrl(customUrl, engineUrl) + + if prioritizedUrl != customUrl { + defer a.notifier.SendShowMessage(sglsp.Info, "The Snyk API Endpoint has been updated.") + } + + a.c.UpdateApiEndpoints(prioritizedUrl) a.UpdateCredentials(token, true) + a.ConfigureProviders(a.c) + return token, err } +func getPrioritizedApiUrl(customUrl string, engineUrl string) string { + defaultUrl := config.DefaultSnykApiUrl + customUrl = strings.TrimRight(customUrl, "/ ") + + // If the custom URL is not changed (equals default) and no engine URL is provided, + // use the default URL. + if customUrl == defaultUrl && engineUrl == "" { + return defaultUrl + } + + // If the custom URL equals the default but an engine URL is provided, use the engine URL. + // The authentication flow has redirected the user to the correct endpoint. + // http://api.eu.snyk.io + if customUrl == defaultUrl { + return engineUrl + } + + if customUrl == "" && engineUrl != "" { + return engineUrl + } + + // Otherwise, return the custom URL set by the user. + // Fedramp and single tenenat environments. + return customUrl +} + func (a *AuthenticationServiceImpl) UpdateCredentials(newToken string, sendNotification bool) { c := config.CurrentConfig() oldToken := c.Token() @@ -94,7 +135,11 @@ func (a *AuthenticationServiceImpl) UpdateCredentials(newToken string, sendNotif c.SetToken(newToken) if sendNotification { - a.notifier.Send(types.AuthenticationParams{Token: newToken}) + a.c.Logger().Debug().Str("method", "UpdateCredentials").Str( + "Sending Url %s", + a.c.SnykApi(), + ) + a.notifier.Send(types.AuthenticationParams{Token: newToken, ApiUrl: a.c.SnykApi()}) } } diff --git a/infrastructure/authentication/auth_service_impl_test.go b/infrastructure/authentication/auth_service_impl_test.go index c545fe07a..c31621fc9 100644 --- a/infrastructure/authentication/auth_service_impl_test.go +++ b/infrastructure/authentication/auth_service_impl_test.go @@ -23,6 +23,8 @@ import ( "testing" "time" + "github.com/snyk/go-application-framework/pkg/configuration" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/oauth2" @@ -63,6 +65,25 @@ func Test_UpdateCredentials(t *testing.T) { }) } +func Test_Authenticate(t *testing.T) { + t.Run("Get endpoint from GAF config and set in snyk-ls configuration ", func(t *testing.T) { + apiEndpoint := "https://api.eu.snyk.io" + c := testutil.UnitTest(t) + c.Engine().GetConfiguration().Set(configuration.API_URL, apiEndpoint) + + provider := FakeAuthenticationProvider{C: c} + service := NewAuthenticationService(c, &provider, error_reporting.NewTestErrorReporter(), notification.NewNotifier()) + + _, err := service.Authenticate(context.Background()) + if err != nil { + return + } + + uiEndpoint := c.SnykUI() + assert.Equal(t, "https://app.eu.snyk.io", uiEndpoint) + }) +} + func Test_IsAuthenticated(t *testing.T) { t.Run("User is authenticated", func(t *testing.T) { c := testutil.UnitTest(t) @@ -155,3 +176,85 @@ func TestHandleInvalidCredentials(t *testing.T) { }, maxWait, time.Millisecond, "didn't receive show message request to re-authenticate") }) } + +func TestGetApiUrl(t *testing.T) { + defaultUrl := config.DefaultSnykApiUrl + customUrl := "https://custom.snyk.io" + engineUrl := "https://engine.snyk.io" + + tests := []struct { + name string + customUrl string + engineUrl string + expectedResult string + }{ + { + name: "Default URL when custom and engine URLs are not set", + customUrl: defaultUrl, + engineUrl: "", + expectedResult: defaultUrl, + }, + { + name: "Engine URL when custom URL is default and engine URL is set", + customUrl: defaultUrl, + engineUrl: engineUrl, + expectedResult: engineUrl, + }, + { + name: "Custom URL when it's different from default and engine URL", + customUrl: customUrl, + engineUrl: engineUrl, + expectedResult: customUrl, + }, + { + name: "Custom URL when custom URL equals engine URL", + customUrl: customUrl, + engineUrl: customUrl, + expectedResult: customUrl, + }, + { + name: "Custom URL when engine URL is empty", + customUrl: customUrl, + engineUrl: "", + expectedResult: customUrl, + }, + { + name: "Custom URL when engine URL is empty", + customUrl: "", + engineUrl: engineUrl, + expectedResult: engineUrl, + }, + { + name: "Custom URL when it's different from default and engine URL is empty", + customUrl: customUrl, + engineUrl: "", + expectedResult: customUrl, + }, + { + name: "Custom URL with trailing slash", + customUrl: "https://custom.snyk.io/", + engineUrl: "", + expectedResult: customUrl, + }, + { + name: "Custom URL with trailing spaces", + customUrl: "https://custom.snyk.io ", + engineUrl: "", + expectedResult: customUrl, + }, + { + name: "Custom URL with trailing slashes and spaces", + customUrl: "https://custom.snyk.io/// ", + engineUrl: "", + expectedResult: customUrl, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := getPrioritizedApiUrl(tt.customUrl, tt.engineUrl) + assert.Equal(t, tt.expectedResult, result, "getApiUrl(%v, %v) = %v; want %v", + tt.customUrl, tt.engineUrl, result, tt.expectedResult) + }) + } +} diff --git a/internal/notification/notification_test.go b/internal/notification/notification_test.go index e6eb955e7..302f727d3 100644 --- a/internal/notification/notification_test.go +++ b/internal/notification/notification_test.go @@ -26,7 +26,7 @@ import ( "github.com/snyk/snyk-ls/internal/types" ) -var params = types.AuthenticationParams{Token: "test event"} +var params = types.AuthenticationParams{Token: "test event", ApiUrl: "https://api.snyk.io"} func TestSendReceive(t *testing.T) { n := NewNotifier() diff --git a/internal/types/lsp.go b/internal/types/lsp.go index f21fa154b..806b6db1b 100644 --- a/internal/types/lsp.go +++ b/internal/types/lsp.go @@ -618,7 +618,8 @@ type ConfigurationParams struct { } type AuthenticationParams struct { - Token string `json:"token"` + Token string `json:"token"` + ApiUrl string `json:"apiUrl,omitempty"` } type SnykIsAvailableCli struct { @@ -1069,11 +1070,6 @@ type SnykScanParams struct { CliError *CliError `json:"cliError,omitempty"` } -type DiagnosticsOverviewParams struct { - Product string `json:"product"` - Html string `json:"html"` -} - type ScanIssue struct { // TODO - convert this to a generic type // Unique key identifying an issue in the whole result set. Not the same as the Snyk issue ID. Id string `json:"id"`