mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-29 17:58:15 +08:00
* Introduce the Plugin Static Credentials object. The Plugin Static Credentials object has been introduced to support storing static credentials for plugins. The backend supporting the plugin static credentials has been introduced as well. Related RFD: https://github.com/gravitational/teleport/pull/26599 * Use MatchLabels instead of a custom rolled one, use named arguments for plugin static credentials interface, add type to error message. * Remove ok references from credentials objects. * Use protojson instead of jsonpb. * Rename header unmarshal function. * Update api/proto/teleport/legacy/types/types.proto Co-authored-by: Sakshyam Shah <sshah@goteleport.com> * Update api/types/plugin_static_credentials.go Co-authored-by: Sakshyam Shah <sshah@goteleport.com> * Use OAuth instead of Oauth, rename functions. * Correct initialism. * Use protojson instead of jsonpb, add an explanatory comment in MessageWithHeader. --------- Co-authored-by: Sakshyam Shah <sshah@goteleport.com>
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
/*
|
|
Copyright 2023 Gravitational, Inc.
|
|
|
|
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 services
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/gravitational/teleport/api/types"
|
|
)
|
|
|
|
func TestMarshalPluginStaticCredentialsRoundTrip(t *testing.T) {
|
|
spec := types.PluginStaticCredentialsSpecV1{
|
|
Credentials: &types.PluginStaticCredentialsSpecV1_APIToken{
|
|
APIToken: "some-token",
|
|
},
|
|
}
|
|
|
|
creds, err := types.NewPluginStaticCredentials(types.Metadata{
|
|
Name: "test-creds",
|
|
}, spec)
|
|
require.NoError(t, err)
|
|
|
|
payload, err := MarshalPluginStaticCredentials(creds)
|
|
require.NoError(t, err)
|
|
|
|
unmarshaled, err := UnmarshalPluginStaticCredentials(payload)
|
|
require.NoError(t, err)
|
|
require.Empty(t, cmp.Diff(creds, unmarshaled))
|
|
}
|