@@ -791,37 +791,54 @@ describe('apiProxy', () => {
791
791
792
792
describe ( 'testAuth' , ( ) => {
793
793
const apiPath = '/apis/authorization.k8s.io/v1/selfsubjectrulesreviews' ;
794
- const spec = { namespace : namespace } ;
794
+ const customNamespace = 'custom-namespace' ;
795
+ const specDefault = { namespace : namespace } ;
796
+ const specCustom = { namespace : customNamespace } ;
795
797
796
798
beforeEach ( ( ) => {
797
799
nock ( baseApiUrl )
798
- . persist ( )
799
- . post ( `/clusters/${ clusterName } ${ apiPath } ` , { spec } )
800
+ . post ( `/clusters/${ clusterName } ${ apiPath } ` , { spec : specDefault } )
801
+ . reply ( 200 , mockResponse ) ;
802
+
803
+ nock ( baseApiUrl )
804
+ . post ( `/clusters/${ clusterName } ${ apiPath } ` , { spec : specCustom } )
800
805
. reply ( 200 , mockResponse ) ;
801
806
} ) ;
802
807
803
808
afterEach ( ( ) => {
804
809
nock . cleanAll ( ) ;
805
810
} ) ;
806
811
807
- it ( 'Successfully handles authentication' , async ( ) => {
812
+ it ( 'Successfully handles authentication with default namespace ' , async ( ) => {
808
813
const response = await apiProxy . testAuth ( clusterName ) ;
809
814
expect ( response ) . toEqual ( mockResponse ) ;
810
815
} ) ;
811
816
817
+ it ( 'Successfully handles authentication with custom namespace' , async ( ) => {
818
+ const response = await apiProxy . testAuth ( clusterName , customNamespace ) ;
819
+ expect ( response ) . toEqual ( mockResponse ) ;
820
+ } ) ;
821
+
812
822
it . each ( [
813
- [ 401 , errorResponse401 ] ,
814
- [ 500 , errorResponse500 ] ,
823
+ [ 401 , errorResponse401 , namespace ] ,
824
+ [ 500 , errorResponse500 , namespace ] ,
825
+ [ 401 , errorResponse401 , customNamespace ] ,
826
+ [ 500 , errorResponse500 , customNamespace ] ,
815
827
] ) (
816
828
'Successfully handles authentication with error status %d' ,
817
- async ( statusCode , errorResponse ) => {
829
+ async ( statusCode , errorResponse , namespace ) => {
818
830
nock . cleanAll ( ) ;
819
831
nock ( baseApiUrl )
820
- . persist ( )
821
- . post ( `/clusters/${ clusterName } ${ apiPath } ` , { spec } )
832
+ . post ( `/clusters/${ clusterName } ${ apiPath } ` , { spec : specDefault } )
822
833
. reply ( statusCode , { message : errorResponse . error } ) ;
823
834
824
- await expect ( apiProxy . testAuth ( clusterName ) ) . rejects . toThrow ( errorResponse . error ) ;
835
+ nock ( baseApiUrl )
836
+ . post ( `/clusters/${ clusterName } ${ apiPath } ` , { spec : specCustom } )
837
+ . reply ( statusCode , { message : errorResponse . error } ) ;
838
+
839
+ await expect ( apiProxy . testAuth ( clusterName , namespace ) ) . rejects . toThrow (
840
+ errorResponse . error
841
+ ) ;
825
842
}
826
843
) ;
827
844
} ) ;
0 commit comments