Adding an e2e test on GMSA support
The previously existing e2e GMSA test really only tests a small part of the whole GMSA set up process, namely that once the API has inlined the GMSA contents in the pod's spec, and sent that to a worker's kubelet, then the kubelet passes that down to the runtime. This new test, in contrast, really tests the whole thing, i.e. deploying the admission webhook, then deploying a GMSA custom resource, and using that resource within a pod. The downside of this test though, is that it does need to make a lot of assumptions about the cluster it runs against, notably that it runs on a worker node that's already been joined to a working Active Directory domain (there are other assumptions, all documented at the beginning of the test file); for that reason, it is only intended to ever be run against an AKS cluster with the custom AKS extension from https://github.com/kubernetes-sigs/windows-testing/pull/98. Note that this test doesn't aim at testing every edge-case, such as a pod trying to use a GMSA it doesn't have access to; the webhook has its own tests for these. This test's goal is to ensure the happy path doesn't break. Signed-off-by: Jean Rouge <rougej+github@gmail.com>
This commit is contained in:
44
test/e2e/windows/utils.go
Normal file
44
test/e2e/windows/utils.go
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright 2019 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 windows
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// downloadFile saves a remote URL to a local temp file, and returns its path.
|
||||
// It's the caller's responsibility to clean up the temp file when done.
|
||||
func downloadFile(url string) (string, error) {
|
||||
response, err := http.Get(url)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "unable to download from %q", url)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
tempFile, err := ioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "unable to create temp file")
|
||||
}
|
||||
defer tempFile.Close()
|
||||
|
||||
_, err = io.Copy(tempFile, response.Body)
|
||||
return tempFile.Name(), err
|
||||
}
|
Reference in New Issue
Block a user