Path: blob/main/components/local-app/cmd/login_test.go
3601 views
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package cmd56import (7"context"8"fmt"9"net/http"10"testing"1112"github.com/bufbuild/connect-go"13v1 "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1"14gitpod_experimental_v1connect "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1/v1connect"15"github.com/gitpod-io/local-app/pkg/config"16)1718func TestLoginCmd(t *testing.T) {19RunCommandTests(t, []CommandTest{20{21Name: "test unauthenticated",22Commandline: []string{"login", "--token", "foo"},23Config: &config.Config{24ActiveContext: "test",25},26PrepServer: func(mux *http.ServeMux) {27mux.Handle(gitpod_experimental_v1connect.NewTeamsServiceHandler(&testLoginCmdSrv{28Err: connect.NewError(connect.CodeUnauthenticated, fmt.Errorf("cannot establish caller identity")),29}))30},31Expectation: CommandTestExpectation{32Error: "unauthenticated",33HasResolutions: true,34},35},36})37}3839type testLoginCmdSrv struct {40Err error41gitpod_experimental_v1connect.UnimplementedTeamsServiceHandler42}4344func (srv testLoginCmdSrv) ListTeams(context.Context, *connect.Request[v1.ListTeamsRequest]) (*connect.Response[v1.ListTeamsResponse], error) {45return nil, srv.Err46}474849