Add generated file

This PR adds generated files under pkg/client and vendor folder.
This commit is contained in:
xing-yang
2018-07-12 10:55:15 -07:00
parent 36b1de0341
commit e213d1890d
17729 changed files with 5090889 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
/*
Copyright 2016 The Kubernetes Authors.
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 bootstrap
import (
"testing"
"github.com/stretchr/testify/assert"
)
const (
content = "Hello from the other side. I must have called a thousand times."
secret = "my voice is my passcode"
id = "joshua"
)
func TestComputeDetachedSig(t *testing.T) {
sig, err := computeDetachedSig(content, id, secret)
assert.NoError(t, err, "Error when computing signature: %v", err)
assert.Equal(
t,
"eyJhbGciOiJIUzI1NiIsImtpZCI6Impvc2h1YSJ9..VShe2taLd-YTrmWuRkcL_8QTNDHYxQIEBsAYYiIj1_8",
sig,
"Wrong signature. Got: %v", sig)
// Try with null content
sig, err = computeDetachedSig("", id, secret)
assert.NoError(t, err, "Error when computing signature: %v", err)
assert.Equal(
t,
"eyJhbGciOiJIUzI1NiIsImtpZCI6Impvc2h1YSJ9..7Ui1ALizW4jXphVUB7xUqC9vLYLL9RZeOFfVLoB7Tgk",
sig,
"Wrong signature. Got: %v", sig)
// Try with no secret
sig, err = computeDetachedSig(content, id, "")
assert.NoError(t, err, "Error when computing signature: %v", err)
assert.Equal(
t,
"eyJhbGciOiJIUzI1NiIsImtpZCI6Impvc2h1YSJ9..UfkqvDGiIFxrMnFseDj9LYJOLNrvjW8aHhF71mvvAs8",
sig,
"Wrong signature. Got: %v", sig)
}
func TestDetachedTokenIsValid(t *testing.T) {
// Valid detached JWS token and valid inputs should succeed
sig := "eyJhbGciOiJIUzI1NiIsImtpZCI6Impvc2h1YSJ9..VShe2taLd-YTrmWuRkcL_8QTNDHYxQIEBsAYYiIj1_8"
assert.True(t, DetachedTokenIsValid(sig, content, id, secret),
"Content %q and token \"%s:%s\" should equal signature: %q", content, id, secret, sig)
// Invalid detached JWS token and valid inputs should fail
sig2 := sig + "foo"
assert.False(t, DetachedTokenIsValid(sig2, content, id, secret),
"Content %q and token \"%s:%s\" should not equal signature: %q", content, id, secret, sig)
}