File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
bluemix/configuration/core_config Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ type BXConfigData struct {
55
55
AlphaCommandsEnabled string
56
56
HTTPTimeout int
57
57
TypeOfSSO string
58
+ FallbackAccount models.Account
58
59
FallbackIAMTokens struct {
59
60
IAMToken string
60
61
IAMRefreshToken string
@@ -430,6 +431,13 @@ func (c *bxConfig) TypeOfSSO() (style string) {
430
431
return
431
432
}
432
433
434
+ func (c * bxConfig ) FallbackAccount () (a models.Account ) {
435
+ c .read (func () {
436
+ a = c .data .FallbackAccount
437
+ })
438
+ return
439
+ }
440
+
433
441
func (c * bxConfig ) FallbackIAMToken () (t string ) {
434
442
c .read (func () {
435
443
t = c .data .FallbackIAMTokens .IAMToken
@@ -669,6 +677,14 @@ func (c *bxConfig) SetTypeOfSSO(style string) {
669
677
})
670
678
}
671
679
680
+ func (c * bxConfig ) SetFallbackAccount (guid , name , owner string ) {
681
+ c .write (func () {
682
+ c .data .FallbackAccount .GUID = guid
683
+ c .data .FallbackAccount .Name = name
684
+ c .data .FallbackAccount .Owner = owner
685
+ })
686
+ }
687
+
672
688
func (c * bxConfig ) SetFallbackIAMTokens (token , refreshToken string ) {
673
689
c .write (func () {
674
690
c .data .FallbackIAMTokens .IAMToken = token
Original file line number Diff line number Diff line change @@ -454,6 +454,28 @@ func TestMOD(t *testing.T) {
454
454
t .Cleanup (cleanupConfigFiles )
455
455
}
456
456
457
+ func TestFallback (t * testing.T ) {
458
+
459
+ config := prepareConfigForCLI (`{}` , t )
460
+
461
+ // check initial state
462
+ assert .Empty (t , config .FallbackAccount ().GUID )
463
+ assert .Empty (t , config .FallbackIAMToken ())
464
+ assert .Empty (t , config .FallbackIAMRefreshToken ())
465
+
466
+ // update mod time and check that mod should not be checked again
467
+ config .SetFallbackAccount ("value1" , "value2" , "value3" )
468
+ assert .True (t , config .FallbackAccount ().GUID == "value1" )
469
+ assert .True (t , config .FallbackAccount ().Name == "value2" )
470
+ assert .True (t , config .FallbackAccount ().Owner == "value3" )
471
+
472
+ config .SetFallbackIAMTokens ("value1" , "value2" )
473
+ assert .True (t , config .FallbackIAMToken () == "value1" )
474
+ assert .True (t , config .FallbackIAMRefreshToken () == "value2" )
475
+
476
+ t .Cleanup (cleanupConfigFiles )
477
+ }
478
+
457
479
func TestLastUpdateSessionTime (t * testing.T ) {
458
480
459
481
config := prepareConfigForCLI (`{}` , t )
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ type Repository interface {
54
54
TypeOfSSO () string
55
55
AlphaCommandsEnabled () string
56
56
AssumedTrustedProfileId () string
57
+ FallbackAccount () models.Account
57
58
FallbackIAMToken () string
58
59
FallbackIAMRefreshToken () string
59
60
HTTPTimeout () int
@@ -95,6 +96,7 @@ type Repository interface {
95
96
SetIAMToken (string )
96
97
SetIAMRefreshToken (string )
97
98
SetFallbackIAMTokens (string , string )
99
+ SetFallbackAccount (string , string , string )
98
100
SetAssumedTrustedProfileId (string )
99
101
ClearSession ()
100
102
SetAccount (models.Account )
You can’t perform that action at this time.
0 commit comments