-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stabilize client API and improve endpoint URL generation
This commit stabilizes the client API for a `v1.0.0`. Therefore, this commit renames the event log functions: - `TraceAuditLog()` => `AuditLog()` - `TraceErrorLog()` => `ErrorLog()` Further, this commit improves the endpoint URL generation by the client. Before, an endpoint string like `https://play.min.io:7373/` (whitespace) would have caused an endpoint URL with two `/`. Now, all whitespaces are removed from the base endpoint, parameters are URL-escaped and the endpoint URL is built properly.
- Loading branch information
1 parent
558854a
commit 945afb7
Showing
3 changed files
with
101 additions
and
30 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
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,46 @@ | ||
// Copyright 2020 - 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 | ||
|
||
import "testing" | ||
|
||
var endpointTests = []struct { | ||
Endpoint string | ||
Elements []string | ||
URL string | ||
}{ | ||
{Endpoint: "https://127.0.0.1:7373", Elements: nil, URL: "https://127.0.0.1:7373"}, | ||
{Endpoint: "https://127.0.0.1:7373/", Elements: nil, URL: "https://127.0.0.1:7373"}, | ||
{Endpoint: " https://127.0.0.1:7373/ ", Elements: nil, URL: "https://127.0.0.1:7373"}, | ||
|
||
{ | ||
Endpoint: "https://play.min.io:7373", | ||
Elements: []string{"/version"}, | ||
URL: "https://play.min.io:7373/version", | ||
}, | ||
{ | ||
Endpoint: "https://play.min.io:7373", | ||
Elements: []string{"version"}, | ||
URL: "https://play.min.io:7373/version", | ||
}, | ||
{ | ||
Endpoint: "https://127.0.0.1:7373", | ||
Elements: []string{"/key/create/my-key"}, | ||
URL: "https://127.0.0.1:7373/key/create/my-key", | ||
}, | ||
{ | ||
Endpoint: "https://127.0.0.1:7373", | ||
Elements: []string{"/key", "/create", "my-key"}, | ||
URL: "https://127.0.0.1:7373/key/create/my-key", | ||
}, | ||
} | ||
|
||
func TestEndpoint(t *testing.T) { | ||
for i, test := range endpointTests { | ||
if url := endpoint(test.Endpoint, test.Elements...); url != test.URL { | ||
t.Fatalf("Test %d: endpoint url mismatch: got '%s' - want '%s'", i, url, test.URL) | ||
} | ||
} | ||
} |
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