@@ -4,21 +4,19 @@ import (
4
4
"fmt"
5
5
"testing"
6
6
7
+ authorizationv1 "k8s.io/api/authorization/v1"
7
8
apierrors "k8s.io/apimachinery/pkg/api/errors"
8
9
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9
10
"k8s.io/apimachinery/pkg/runtime"
10
11
"k8s.io/apimachinery/pkg/runtime/schema"
11
12
"k8s.io/apiserver/pkg/admission"
12
13
"k8s.io/apiserver/pkg/authentication/user"
14
+ fakekubeclient "k8s.io/client-go/kubernetes/fake"
13
15
clientgotesting "k8s.io/client-go/testing"
14
- "k8s.io/kubernetes/pkg/apis/authorization"
15
- fakekubeclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
16
- kubeadmission "k8s.io/kubernetes/pkg/kubeapiserver/admission"
17
16
18
17
buildapiv1 "github.com/openshift/api/build/v1"
19
18
fakebuildclient "github.com/openshift/client-go/build/clientset/versioned/fake"
20
19
buildapi "github.com/openshift/origin/pkg/build/apis/build"
21
- oadmission "github.com/openshift/origin/pkg/cmd/server/admission"
22
20
23
21
"github.com/openshift/api/build"
24
22
_ "github.com/openshift/origin/pkg/build/apis/build/install"
@@ -33,7 +31,7 @@ func TestBuildAdmission(t *testing.T) {
33
31
object runtime.Object
34
32
oldObject runtime.Object
35
33
responseObject runtime.Object
36
- reviewResponse * authorization .SubjectAccessReview
34
+ reviewResponse * authorizationv1 .SubjectAccessReview
37
35
expectedResource string
38
36
expectedSubresource string
39
37
expectAccept bool
@@ -179,7 +177,7 @@ func TestBuildAdmission(t *testing.T) {
179
177
},
180
178
}
181
179
182
- emptyResponse := & authorization .SubjectAccessReview {}
180
+ emptyResponse := & authorizationv1 .SubjectAccessReview {}
183
181
ops := []admission.Operation {admission .Create , admission .Update }
184
182
for _ , test := range tests {
185
183
t .Run (test .name , func (t * testing.T ) {
@@ -191,7 +189,7 @@ func TestBuildAdmission(t *testing.T) {
191
189
192
190
fakeKubeClient := fakekubeclient .NewSimpleClientset ()
193
191
fakeKubeClient .PrependReactor ("create" , "subjectaccessreviews" , func (action clientgotesting.Action ) (handled bool , ret runtime.Object , err error ) {
194
- review , ok := action .(clientgotesting.CreateAction ).GetObject ().(* authorization .SubjectAccessReview )
192
+ review , ok := action .(clientgotesting.CreateAction ).GetObject ().(* authorizationv1 .SubjectAccessReview )
195
193
if ! ok {
196
194
return true , emptyResponse , fmt .Errorf ("unexpected object received: %#v" , review )
197
195
}
@@ -211,8 +209,8 @@ func TestBuildAdmission(t *testing.T) {
211
209
})
212
210
213
211
c := NewBuildByStrategy ()
214
- c .(kubeadmission. WantsInternalKubeClientSet ). SetInternalKubeClientSet ( fakeKubeClient )
215
- c .(oadmission. WantsOpenshiftInternalBuildClient ). SetOpenshiftInternalBuildClient ( fakeBuildClient )
212
+ c .(* buildByStrategy ). sarClient = fakeKubeClient . AuthorizationV1 (). SubjectAccessReviews ( )
213
+ c .(* buildByStrategy ). buildClient = fakeBuildClient
216
214
attrs := admission .NewAttributesRecord (test .object , test .oldObject , test .kind .WithVersion ("version" ), "foo" , "test-build" , test .resource .WithVersion ("version" ), test .subResource , op , fakeUser ())
217
215
err := c .(admission.MutationInterface ).Admit (attrs )
218
216
if err != nil && test .expectAccept {
@@ -298,9 +296,9 @@ func v1TestBuildConfig(strategy buildapiv1.BuildStrategy) *buildapiv1.BuildConfi
298
296
}
299
297
}
300
298
301
- func reviewResponse (allowed bool , msg string ) * authorization .SubjectAccessReview {
302
- return & authorization .SubjectAccessReview {
303
- Status : authorization .SubjectAccessReviewStatus {
299
+ func reviewResponse (allowed bool , msg string ) * authorizationv1 .SubjectAccessReview {
300
+ return & authorizationv1 .SubjectAccessReview {
301
+ Status : authorizationv1 .SubjectAccessReviewStatus {
304
302
Allowed : allowed ,
305
303
Reason : msg ,
306
304
},
0 commit comments