Created
September 8, 2025 18:38
-
-
Save ivanvc/2a0fb878bd6b79e2964b6c06357107b1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package e2e | |
| import ( | |
| "context" | |
| "errors" | |
| "testing" | |
| "time" | |
| "github.com/stretchr/testify/require" | |
| "go.etcd.io/etcd/api/v3/v3rpc/rpctypes" | |
| clientv3 "go.etcd.io/etcd/client/v3" | |
| "go.etcd.io/etcd/tests/v3/framework/e2e" | |
| ) | |
| func TestClientError(t *testing.T) { | |
| e2e.BeforeTest(t) | |
| ctx, cancel := context.WithCancel(t.Context()) | |
| defer cancel() | |
| epc, err := e2e.NewEtcdProcessCluster(ctx, t, | |
| e2e.WithClusterSize(1), | |
| ) | |
| require.NoError(t, err) | |
| defer func() { | |
| err := epc.Close() | |
| require.NoError(t, err) | |
| }() | |
| epcClient := epc.Etcdctl() | |
| createUsers(ctx, t, epcClient) | |
| cli, err := clientv3.New(clientv3.Config{ | |
| Endpoints: []string{epc.EndpointsGRPC()[0]}, | |
| DialTimeout: 3 * time.Second, | |
| Username: "nonexistentuser", | |
| Password: "password", | |
| }) | |
| require.NoError(t, err) | |
| defer cli.Close() | |
| err = epcClient.AuthEnable(ctx) | |
| require.NoError(t, err) | |
| _, err = cli.AuthStatus(ctx) | |
| require.ErrorIs(t, err, rpctypes.ErrAuthFailed) | |
| if !errors.Is(err, rpctypes.ErrAuthFailed) { | |
| t.Fail() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment