-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces a new sub-package `kestest` that contains utilities for end-to-end KES testing. It is heavily inspired by the `net/http/httptest` package and contains a `Server` type that implements a minimal KES server. The new `kestest` package makes it possible to write unit tests covering end-to-end usage scenarios without a dedicated KES server for testing purposes. Fixes #164 Signed-off-by: Andreas Auernhammer <[email protected]>
- Loading branch information
Showing
12 changed files
with
587 additions
and
89 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,37 @@ | ||
// Copyright 2021 - MinIO, Inc. All rights reserved. | ||
// Use of this source code is governed by the AGPLv3 | ||
// license that can be found in the LICENSE file. | ||
|
||
package kes_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/minio/kes/kestest" | ||
) | ||
|
||
func TestClient_CreateKey(t *testing.T) { | ||
var server = kestest.NewServer() | ||
defer server.Close() | ||
|
||
const KeyName = "my-key" | ||
if err := server.Client().CreateKey(context.Background(), KeyName); err != nil { | ||
t.Fatalf("Failed to create key %q: %v", KeyName, err) | ||
} | ||
} | ||
|
||
func TestClient_DeleteKey(t *testing.T) { | ||
var server = kestest.NewServer() | ||
defer server.Close() | ||
|
||
const KeyName = "my-key" | ||
if err := server.Client().CreateKey(context.Background(), KeyName); err != nil { | ||
t.Fatalf("Failed to create key %q: %v", KeyName, err) | ||
} | ||
|
||
if err := server.Client().DeleteKey(context.Background(), KeyName); err != nil { | ||
t.Fatalf("Failed to delete key %q: %v", KeyName, err) | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.