-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17e8a94
commit 0fb1117
Showing
2 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Teleport | ||
// Copyright (C) 2024 Gravitational, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package decisionv1_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/gravitational/trace" | ||
"github.com/stretchr/testify/assert" | ||
|
||
decisionpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/decision/v1alpha1" | ||
) | ||
|
||
func TestDecisionService_notImplemented(t *testing.T) { | ||
t.Parallel() | ||
|
||
env := NewTestenv(t) | ||
decisionClient := env.DecisionClient | ||
ctx := context.Background() | ||
|
||
t.Run("EvaluateSSHAccess", func(t *testing.T) { | ||
_, err := decisionClient.EvaluateSSHAccess(ctx, &decisionpb.EvaluateSSHAccessRequest{}) | ||
assert.ErrorAs(t, err, new(*trace.NotImplementedError), "EvaluateSSHAccess error mismatch") | ||
}) | ||
|
||
t.Run("EvaluateDatabaseAccess", func(t *testing.T) { | ||
_, err := decisionClient.EvaluateDatabaseAccess(ctx, &decisionpb.EvaluateDatabaseAccessRequest{}) | ||
assert.ErrorAs(t, err, new(*trace.NotImplementedError), "EvaluateDatabaseAccess error mismatch") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Teleport | ||
// Copyright (C) 2024 Gravitational, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package decisionv1_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/gravitational/teleport/api/constants" | ||
decisionpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/decision/v1alpha1" | ||
"github.com/gravitational/teleport/api/types" | ||
"github.com/gravitational/teleport/lib/auth" | ||
"github.com/gravitational/teleport/lib/auth/authclient" | ||
) | ||
|
||
// Testenv is a test environment for decisionv1.Service. | ||
type Testenv struct { | ||
TestServer *auth.TestServer | ||
|
||
// AuthAdminClient is an admin Auth client. | ||
AuthAdminClient *authclient.Client | ||
|
||
// DecisionClient is an admin decision client. | ||
// Created from AuthAdminClient. | ||
DecisionClient decisionpb.DecisionServiceClient | ||
} | ||
|
||
func NewTestenv(t *testing.T) *Testenv { | ||
t.Helper() | ||
|
||
testServer, err := auth.NewTestServer(auth.TestServerConfig{ | ||
Auth: auth.TestAuthServerConfig{ | ||
Dir: t.TempDir(), | ||
AuthPreferenceSpec: &types.AuthPreferenceSpecV2{ | ||
SecondFactor: constants.SecondFactorOTP, // Required. | ||
}, | ||
}, | ||
}) | ||
require.NoError(t, err, "NewTestServer failed") | ||
t.Cleanup(func() { | ||
assert.NoError(t, | ||
testServer.Shutdown(context.Background()), | ||
"testServer.Shutdown failed") | ||
}) | ||
|
||
adminClient, err := testServer.NewClient(auth.TestAdmin()) | ||
require.NoError(t, err, "NewClient failed") | ||
t.Cleanup(func() { | ||
assert.NoError(t, adminClient.Close(), "adminClient.Close() failed") | ||
}) | ||
|
||
return &Testenv{ | ||
TestServer: testServer, | ||
AuthAdminClient: adminClient, | ||
DecisionClient: adminClient.DecisionClient(), | ||
} | ||
} |