@@ -211,15 +211,15 @@ describe('KubeConfig', () => {
211211 rejectUnauthorized : false ,
212212 } ) ;
213213 } ) ;
214- it ( 'should apply password' , ( ) => {
214+ it ( 'should apply password' , async ( ) => {
215215 const kc = new KubeConfig ( ) ;
216216 kc . loadFromFile ( kcFileName ) ;
217217 kc . setCurrentContext ( 'passwd' ) ;
218218
219219 const opts : requestlib . Options = {
220220 url : 'https://company.com' ,
221221 } ;
222- kc . applyToRequest ( opts ) ;
222+ await kc . applyToRequest ( opts ) ;
223223 expect ( opts ) . to . deep . equal ( {
224224 ca : new Buffer ( 'CADATA2' , 'utf-8' ) ,
225225 auth : {
@@ -514,18 +514,18 @@ describe('KubeConfig', () => {
514514 } ) ;
515515
516516 describe ( 'auth options' , ( ) => {
517- it ( 'should populate basic-auth for https' , ( ) => {
517+ it ( 'should populate basic-auth for https' , async ( ) => {
518518 const config = new KubeConfig ( ) ;
519519 const user = 'user' ;
520520 const passwd = 'password' ;
521521
522522 config . loadFromClusterAndUser ( { } as Cluster , { username : user , password : passwd } as User ) ;
523523 const opts = { } as https . RequestOptions ;
524- config . applytoHTTPSOptions ( opts ) ;
524+ await config . applytoHTTPSOptions ( opts ) ;
525525
526526 expect ( opts . auth ) . to . equal ( `${ user } :${ passwd } ` ) ;
527527 } ) ;
528- it ( 'should populate options for request' , ( ) => {
528+ it ( 'should populate options for request' , async ( ) => {
529529 const config = new KubeConfig ( ) ;
530530 const user = 'user' ;
531531 const passwd = 'password' ;
@@ -541,7 +541,7 @@ describe('KubeConfig', () => {
541541 ) ;
542542 const opts = { } as requestlib . Options ;
543543
544- config . applyToRequest ( opts ) ;
544+ await config . applyToRequest ( opts ) ;
545545
546546 /* tslint:disable no-unused-expression*/
547547 expect ( opts . auth ) . to . not . be . undefined ;
@@ -551,17 +551,17 @@ describe('KubeConfig', () => {
551551 }
552552 expect ( opts . strictSSL ) . to . equal ( false ) ;
553553 } ) ;
554- it ( 'should not populate strict ssl' , ( ) => {
554+ it ( 'should not populate strict ssl' , async ( ) => {
555555 const config = new KubeConfig ( ) ;
556556
557557 config . loadFromClusterAndUser ( { skipTLSVerify : false } as Cluster , { } as User ) ;
558558 const opts = { } as requestlib . Options ;
559559
560- config . applyToRequest ( opts ) ;
560+ await config . applyToRequest ( opts ) ;
561561
562562 expect ( opts . strictSSL ) . to . equal ( undefined ) ;
563563 } ) ;
564- it ( 'should populate from token' , ( ) => {
564+ it ( 'should populate from token' , async ( ) => {
565565 const config = new KubeConfig ( ) ;
566566 const token = 'token' ;
567567 config . loadFromClusterAndUser (
@@ -572,13 +572,13 @@ describe('KubeConfig', () => {
572572 ) ;
573573 const opts = { } as requestlib . Options ;
574574
575- config . applyToRequest ( opts ) ;
575+ await config . applyToRequest ( opts ) ;
576576 expect ( opts . headers ) . to . not . be . undefined ;
577577 if ( opts . headers ) {
578578 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
579579 }
580580 } ) ;
581- it ( 'should populate from auth provider' , ( ) => {
581+ it ( 'should populate from auth provider' , async ( ) => {
582582 const config = new KubeConfig ( ) ;
583583 const token = 'token' ;
584584 config . loadFromClusterAndUser (
@@ -595,18 +595,18 @@ describe('KubeConfig', () => {
595595 ) ;
596596 const opts = { } as requestlib . Options ;
597597
598- config . applyToRequest ( opts ) ;
598+ await config . applyToRequest ( opts ) ;
599599 expect ( opts . headers ) . to . not . be . undefined ;
600600 if ( opts . headers ) {
601601 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
602602 }
603603 opts . headers = [ ] ;
604604 opts . headers . Host = 'foo.com' ;
605- config . applyToRequest ( opts ) ;
605+ await config . applyToRequest ( opts ) ;
606606 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
607607 } ) ;
608608
609- it ( 'should populate from auth provider without expirty' , ( ) => {
609+ it ( 'should populate from auth provider without expirty' , async ( ) => {
610610 const config = new KubeConfig ( ) ;
611611 const token = 'token' ;
612612 config . loadFromClusterAndUser (
@@ -622,14 +622,14 @@ describe('KubeConfig', () => {
622622 ) ;
623623 const opts = { } as requestlib . Options ;
624624
625- config . applyToRequest ( opts ) ;
625+ await config . applyToRequest ( opts ) ;
626626 expect ( opts . headers ) . to . not . be . undefined ;
627627 if ( opts . headers ) {
628628 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
629629 }
630630 } ) ;
631631
632- it ( 'should populate rejectUnauthorized=false when skipTLSVerify is set' , ( ) => {
632+ it ( 'should populate rejectUnauthorized=false when skipTLSVerify is set' , async ( ) => {
633633 const config = new KubeConfig ( ) ;
634634 const token = 'token' ;
635635 config . loadFromClusterAndUser (
@@ -645,11 +645,11 @@ describe('KubeConfig', () => {
645645 ) ;
646646 const opts = { } as requestlib . Options ;
647647
648- config . applyToRequest ( opts ) ;
648+ await config . applyToRequest ( opts ) ;
649649 expect ( opts . rejectUnauthorized ) . to . equal ( false ) ;
650650 } ) ;
651651
652- it ( 'should not set rejectUnauthorized if skipTLSVerify is not set' , ( ) => {
652+ it ( 'should not set rejectUnauthorized if skipTLSVerify is not set' , async ( ) => {
653653 // This test is just making 100% sure we validate certs unless we explictly set
654654 // skipTLSVerify = true
655655 const config = new KubeConfig ( ) ;
@@ -667,7 +667,7 @@ describe('KubeConfig', () => {
667667 ) ;
668668 const opts = { } as requestlib . Options ;
669669
670- config . applyToRequest ( opts ) ;
670+ await config . applyToRequest ( opts ) ;
671671 expect ( opts . rejectUnauthorized ) . to . equal ( undefined ) ;
672672 } ) ;
673673
@@ -686,7 +686,7 @@ describe('KubeConfig', () => {
686686 ) ;
687687 const opts = { } as requestlib . Options ;
688688
689- expect ( ( ) => config . applyToRequest ( opts ) ) . to . throw ( 'Token is expired!' ) ;
689+ return expect ( config . applyToRequest ( opts ) ) . to . eventually . be . rejectedWith ( 'Token is expired!' ) ;
690690 } ) ;
691691
692692 it ( 'should throw with bad command' , ( ) => {
@@ -705,10 +705,12 @@ describe('KubeConfig', () => {
705705 } as User ,
706706 ) ;
707707 const opts = { } as requestlib . Options ;
708- expect ( ( ) => config . applyToRequest ( opts ) ) . to . throw ( / F a i l e d t o r e f r e s h t o k e n / ) ;
708+ return expect ( config . applyToRequest ( opts ) ) . to . eventually . be . rejectedWith (
709+ / F a i l e d t o r e f r e s h t o k e n / ,
710+ ) ;
709711 } ) ;
710712
711- it ( 'should exec with expired token' , ( ) => {
713+ it ( 'should exec with expired token' , async ( ) => {
712714 const config = new KubeConfig ( ) ;
713715 const token = 'token' ;
714716 const responseStr = `{"token":{"accessToken":"${ token } "}}` ;
@@ -728,13 +730,13 @@ describe('KubeConfig', () => {
728730 } as User ,
729731 ) ;
730732 const opts = { } as requestlib . Options ;
731- config . applyToRequest ( opts ) ;
733+ await config . applyToRequest ( opts ) ;
732734 expect ( opts . headers ) . to . not . be . undefined ;
733735 if ( opts . headers ) {
734736 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
735737 }
736738 } ) ;
737- it ( 'should exec without access-token' , ( ) => {
739+ it ( 'should exec without access-token' , async ( ) => {
738740 const config = new KubeConfig ( ) ;
739741 const token = 'token' ;
740742 const responseStr = `{"token":{"accessToken":"${ token } "}}` ;
@@ -753,13 +755,13 @@ describe('KubeConfig', () => {
753755 } as User ,
754756 ) ;
755757 const opts = { } as requestlib . Options ;
756- config . applyToRequest ( opts ) ;
758+ await config . applyToRequest ( opts ) ;
757759 expect ( opts . headers ) . to . not . be . undefined ;
758760 if ( opts . headers ) {
759761 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
760762 }
761763 } ) ;
762- it ( 'should exec without access-token' , ( ) => {
764+ it ( 'should exec without access-token' , async ( ) => {
763765 const config = new KubeConfig ( ) ;
764766 const token = 'token' ;
765767 const responseStr = `{"token":{"accessToken":"${ token } "}}` ;
@@ -778,13 +780,13 @@ describe('KubeConfig', () => {
778780 } as User ,
779781 ) ;
780782 const opts = { } as requestlib . Options ;
781- config . applyToRequest ( opts ) ;
783+ await config . applyToRequest ( opts ) ;
782784 expect ( opts . headers ) . to . not . be . undefined ;
783785 if ( opts . headers ) {
784786 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
785787 }
786788 } ) ;
787- it ( 'should exec with exec auth and env vars' , ( ) => {
789+ it ( 'should exec with exec auth and env vars' , async ( ) => {
788790 const config = new KubeConfig ( ) ;
789791 const token = 'token' ;
790792 const responseStr = `{"status": { "token": "${ token } " }}` ;
@@ -810,13 +812,13 @@ describe('KubeConfig', () => {
810812 ) ;
811813 // TODO: inject the exec command here and validate env vars?
812814 const opts = { } as requestlib . Options ;
813- config . applyToRequest ( opts ) ;
815+ await config . applyToRequest ( opts ) ;
814816 expect ( opts . headers ) . to . not . be . undefined ;
815817 if ( opts . headers ) {
816818 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
817819 }
818820 } ) ;
819- it ( 'should exec with exec auth' , ( ) => {
821+ it ( 'should exec with exec auth' , async ( ) => {
820822 const config = new KubeConfig ( ) ;
821823 const token = 'token' ;
822824 const responseStr = `{
@@ -842,13 +844,13 @@ describe('KubeConfig', () => {
842844 ) ;
843845 // TODO: inject the exec command here?
844846 const opts = { } as requestlib . Options ;
845- config . applyToRequest ( opts ) ;
847+ await config . applyToRequest ( opts ) ;
846848 expect ( opts . headers ) . to . not . be . undefined ;
847849 if ( opts . headers ) {
848850 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
849851 }
850852 } ) ;
851- it ( 'should exec with exec auth (other location)' , ( ) => {
853+ it ( 'should exec with exec auth (other location)' , async ( ) => {
852854 const config = new KubeConfig ( ) ;
853855 const token = 'token' ;
854856 const responseStr = `{
@@ -869,7 +871,7 @@ describe('KubeConfig', () => {
869871 ) ;
870872 // TODO: inject the exec command here?
871873 const opts = { } as requestlib . Options ;
872- config . applyToRequest ( opts ) ;
874+ await config . applyToRequest ( opts ) ;
873875 expect ( opts . headers ) . to . not . be . undefined ;
874876 if ( opts . headers ) {
875877 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
@@ -889,7 +891,7 @@ describe('KubeConfig', () => {
889891 } as User ,
890892 ) ;
891893 const opts = { } as requestlib . Options ;
892- expect ( ( ) => config . applyToRequest ( opts ) ) . to . throw (
894+ return expect ( config . applyToRequest ( opts ) ) . to . eventually . be . rejectedWith (
893895 'No command was specified for exec authProvider!' ,
894896 ) ;
895897 } ) ;
@@ -1083,9 +1085,9 @@ describe('KubeConfig', () => {
10831085 expect ( emptyConfig . getCurrentContext ( ) ) . to . be . undefined ;
10841086 } ) ;
10851087
1086- it ( 'should apply to request' , ( ) => {
1088+ it ( 'should apply to request' , async ( ) => {
10871089 const opts = { } as requestlib . Options ;
1088- emptyConfig . applyToRequest ( opts ) ;
1090+ await emptyConfig . applyToRequest ( opts ) ;
10891091 } ) ;
10901092 } ) ;
10911093
0 commit comments