github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/util/configv3/config_test.go (about)

     1  package configv3_test
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  	"io/ioutil"
     7  	"os"
     8  	"path/filepath"
     9  	"time"
    10  
    11  	. "code.cloudfoundry.org/cli/util/configv3"
    12  
    13  	. "github.com/onsi/ginkgo"
    14  	. "github.com/onsi/ginkgo/extensions/table"
    15  	. "github.com/onsi/gomega"
    16  )
    17  
    18  var _ = Describe("Config", func() {
    19  	var homeDir string
    20  
    21  	BeforeEach(func() {
    22  		homeDir = setup()
    23  	})
    24  
    25  	AfterEach(func() {
    26  		teardown(homeDir)
    27  	})
    28  
    29  	Context("when there isn't a config set", func() {
    30  		var (
    31  			oldLang  string
    32  			oldLCAll string
    33  		)
    34  
    35  		BeforeEach(func() {
    36  			oldLang = os.Getenv("LANG")
    37  			oldLCAll = os.Getenv("LC_ALL")
    38  			os.Unsetenv("LANG")
    39  			os.Unsetenv("LC_ALL")
    40  		})
    41  
    42  		It("returns a default config", func() {
    43  			defer os.Setenv("LANG", oldLang)
    44  			defer os.Setenv("LC_ALL", oldLCAll)
    45  
    46  			// specifically for when we run unit tests locally
    47  			// we save and unset this variable in case it's present
    48  			// since we want to load a default config
    49  			envVal := os.Getenv("CF_CLI_EXPERIMENTAL")
    50  			os.Unsetenv("CF_CLI_EXPERIMENTAL")
    51  
    52  			config, err := LoadConfig()
    53  
    54  			// then we reset the env variable
    55  			os.Setenv("CF_CLI_EXPERIMENTAL", envVal)
    56  
    57  			Expect(err).ToNot(HaveOccurred())
    58  
    59  			Expect(config).ToNot(BeNil())
    60  			Expect(config.Target()).To(Equal(DefaultTarget))
    61  			Expect(config.SkipSSLValidation()).To(BeFalse())
    62  			Expect(config.ColorEnabled()).To(Equal(ColorEnabled))
    63  			Expect(config.PluginHome()).To(Equal(filepath.Join(homeDir, ".cf", "plugins")))
    64  			Expect(config.StagingTimeout()).To(Equal(DefaultStagingTimeout))
    65  			Expect(config.StartupTimeout()).To(Equal(DefaultStartupTimeout))
    66  			Expect(config.Locale()).To(BeEmpty())
    67  			Expect(config.UAAOAuthClient()).To(Equal(DefaultUAAOAuthClient))
    68  			Expect(config.UAAOAuthClientSecret()).To(Equal(DefaultUAAOAuthClientSecret))
    69  			Expect(config.OverallPollingTimeout()).To(Equal(DefaultOverallPollingTimeout))
    70  			Expect(config.LogLevel()).To(Equal(0))
    71  
    72  			Expect(config.PluginRepositories()).To(Equal([]PluginRepository{{
    73  				Name: "CF-Community",
    74  				URL:  "https://plugins.cloudfoundry.org",
    75  			}}))
    76  			Expect(config.Experimental()).To(BeFalse())
    77  
    78  			pluginConfig := config.Plugins()
    79  			Expect(pluginConfig).To(BeEmpty())
    80  
    81  			trace, location := config.Verbose()
    82  			Expect(trace).To(BeFalse())
    83  			Expect(location).To(BeEmpty())
    84  
    85  			// test the plugins map is initialized
    86  			config.AddPlugin(Plugin{})
    87  		})
    88  	})
    89  
    90  	Context("when there is a config set", func() {
    91  		var (
    92  			config *Config
    93  			err    error
    94  		)
    95  
    96  		Context("when UAAOAuthClient is not present", func() {
    97  			BeforeEach(func() {
    98  				rawConfig := `{}`
    99  				setConfig(homeDir, rawConfig)
   100  
   101  				config, err = LoadConfig()
   102  				Expect(err).ToNot(HaveOccurred())
   103  			})
   104  
   105  			It("sets UAAOAuthClient to the default", func() {
   106  				Expect(config.UAAOAuthClient()).To(Equal(DefaultUAAOAuthClient))
   107  			})
   108  
   109  			It("sets UAAOAuthClientSecret to the default", func() {
   110  				Expect(config.UAAOAuthClientSecret()).To(Equal(DefaultUAAOAuthClientSecret))
   111  			})
   112  		})
   113  
   114  		Context("when UAAOAuthClient is empty", func() {
   115  			BeforeEach(func() {
   116  				rawConfig := `
   117  					{
   118  						"UAAOAuthClient": ""
   119  					}`
   120  				setConfig(homeDir, rawConfig)
   121  
   122  				config, err = LoadConfig()
   123  				Expect(err).ToNot(HaveOccurred())
   124  			})
   125  
   126  			It("sets UAAOAuthClient to the default", func() {
   127  				Expect(config.UAAOAuthClient()).To(Equal(DefaultUAAOAuthClient))
   128  			})
   129  
   130  			It("sets UAAOAuthClientSecret to the default", func() {
   131  				Expect(config.UAAOAuthClientSecret()).To(Equal(DefaultUAAOAuthClientSecret))
   132  			})
   133  		})
   134  	})
   135  
   136  	Describe("check functions", func() {
   137  		Describe("HasTargetedOrganization", func() {
   138  			Context("when an organization is targeted", func() {
   139  				It("returns true", func() {
   140  					config := Config{}
   141  					config.SetOrganizationInformation("guid-value-1", "my-org-name")
   142  					Expect(config.HasTargetedOrganization()).To(BeTrue())
   143  				})
   144  			})
   145  
   146  			Context("when an organization is not targeted", func() {
   147  				It("returns false", func() {
   148  					config := Config{}
   149  					Expect(config.HasTargetedOrganization()).To(BeFalse())
   150  				})
   151  			})
   152  		})
   153  
   154  		Describe("HasTargetedSpace", func() {
   155  			Context("when an space is targeted", func() {
   156  				It("returns true", func() {
   157  					config := Config{}
   158  					config.SetSpaceInformation("guid-value-1", "my-org-name", true)
   159  					Expect(config.HasTargetedSpace()).To(BeTrue())
   160  				})
   161  			})
   162  
   163  			Context("when an space is not targeted", func() {
   164  				It("returns false", func() {
   165  					config := Config{}
   166  					Expect(config.HasTargetedSpace()).To(BeFalse())
   167  				})
   168  			})
   169  		})
   170  	})
   171  
   172  	Describe("getter functions", func() {
   173  		Describe("Target", func() {
   174  			var config *Config
   175  
   176  			BeforeEach(func() {
   177  				rawConfig := `{ "Target":"https://api.foo.com" }`
   178  				setConfig(homeDir, rawConfig)
   179  
   180  				var err error
   181  				config, err = LoadConfig()
   182  				Expect(err).ToNot(HaveOccurred())
   183  				Expect(config).ToNot(BeNil())
   184  			})
   185  
   186  			It("returns fields directly from config", func() {
   187  				Expect(config.Target()).To(Equal("https://api.foo.com"))
   188  			})
   189  		})
   190  
   191  		Describe("OverallPollingTimeout", func() {
   192  			var config *Config
   193  
   194  			Context("when AsyncTimeout is set in config", func() {
   195  				BeforeEach(func() {
   196  					rawConfig := `{ "AsyncTimeout":5 }`
   197  					setConfig(homeDir, rawConfig)
   198  
   199  					var err error
   200  					config, err = LoadConfig()
   201  					Expect(err).ToNot(HaveOccurred())
   202  					Expect(config).ToNot(BeNil())
   203  				})
   204  
   205  				It("returns the timeout in duration form", func() {
   206  					Expect(config.OverallPollingTimeout()).To(Equal(5 * time.Minute))
   207  				})
   208  			})
   209  		})
   210  
   211  		Describe("SkipSSLValidation", func() {
   212  			var config *Config
   213  
   214  			BeforeEach(func() {
   215  				rawConfig := `{ "SSLDisabled":true }`
   216  				setConfig(homeDir, rawConfig)
   217  
   218  				var err error
   219  				config, err = LoadConfig()
   220  				Expect(err).ToNot(HaveOccurred())
   221  				Expect(config).ToNot(BeNil())
   222  			})
   223  
   224  			It("returns fields directly from config", func() {
   225  				Expect(config.SkipSSLValidation()).To(BeTrue())
   226  			})
   227  		})
   228  
   229  		Describe("AccessToken", func() {
   230  			var config *Config
   231  
   232  			BeforeEach(func() {
   233  				rawConfig := `{ "AccessToken":"some-token" }`
   234  				setConfig(homeDir, rawConfig)
   235  
   236  				var err error
   237  				config, err = LoadConfig()
   238  				Expect(err).ToNot(HaveOccurred())
   239  				Expect(config).ToNot(BeNil())
   240  			})
   241  
   242  			It("returns fields directly from config", func() {
   243  				Expect(config.AccessToken()).To(Equal("some-token"))
   244  			})
   245  		})
   246  
   247  		Describe("RefreshToken", func() {
   248  			var config *Config
   249  
   250  			BeforeEach(func() {
   251  				rawConfig := `{ "RefreshToken":"some-token" }`
   252  				setConfig(homeDir, rawConfig)
   253  
   254  				var err error
   255  				config, err = LoadConfig()
   256  				Expect(err).ToNot(HaveOccurred())
   257  				Expect(config).ToNot(BeNil())
   258  			})
   259  
   260  			It("returns fields directly from config", func() {
   261  				Expect(config.RefreshToken()).To(Equal("some-token"))
   262  			})
   263  		})
   264  
   265  		Describe("UAAOAuthClient", func() {
   266  			var config *Config
   267  
   268  			BeforeEach(func() {
   269  				rawConfig := `{ "UAAOAuthClient":"some-client" }`
   270  				setConfig(homeDir, rawConfig)
   271  
   272  				var err error
   273  				config, err = LoadConfig()
   274  				Expect(err).ToNot(HaveOccurred())
   275  				Expect(config).ToNot(BeNil())
   276  			})
   277  
   278  			It("returns the client ID", func() {
   279  				Expect(config.UAAOAuthClient()).To(Equal("some-client"))
   280  			})
   281  		})
   282  
   283  		Describe("UAAOAuthClientSecret", func() {
   284  			var config *Config
   285  
   286  			BeforeEach(func() {
   287  				rawConfig := `
   288  					{
   289  						"UAAOAuthClient": "some-client-id",
   290  						"UAAOAuthClientSecret": "some-client-secret"
   291  					}`
   292  				setConfig(homeDir, rawConfig)
   293  
   294  				var err error
   295  				config, err = LoadConfig()
   296  				Expect(err).ToNot(HaveOccurred())
   297  				Expect(config).ToNot(BeNil())
   298  			})
   299  
   300  			It("returns the client secret", func() {
   301  				Expect(config.UAAOAuthClientSecret()).To(Equal("some-client-secret"))
   302  			})
   303  		})
   304  
   305  		DescribeTable("Experimental",
   306  			func(envVal string, expected bool) {
   307  				rawConfig := fmt.Sprintf(`{}`)
   308  				setConfig(homeDir, rawConfig)
   309  
   310  				defer os.Unsetenv("CF_CLI_EXPERIMENTAL")
   311  				if envVal == "" {
   312  					os.Unsetenv("CF_CLI_EXPERIMENTAL")
   313  				} else {
   314  					os.Setenv("CF_CLI_EXPERIMENTAL", envVal)
   315  				}
   316  
   317  				config, err := LoadConfig()
   318  				Expect(err).ToNot(HaveOccurred())
   319  				Expect(config).ToNot(BeNil())
   320  
   321  				Expect(config.Experimental()).To(Equal(expected))
   322  			},
   323  
   324  			Entry("uses default value of false if environment value is not set", "", false),
   325  			Entry("uses environment value if a valid environment value is set", "true", true),
   326  			Entry("uses default value of false if an invalid environment value is set", "something-invalid", false),
   327  		)
   328  
   329  		Describe("BinaryName", func() {
   330  			It("returns the name used to invoke", func() {
   331  				config, err := LoadConfig()
   332  				Expect(err).ToNot(HaveOccurred())
   333  				Expect(config).ToNot(BeNil())
   334  
   335  				// Ginkgo will uses a config file as the first test argument, so that
   336  				// will be considered the binary name
   337  				Expect(config.BinaryName()).To(Equal("configv3.test"))
   338  			})
   339  		})
   340  
   341  		Context("when there are environment variables", func() {
   342  			var (
   343  				originalCFStagingTimeout string
   344  				originalCFStartupTimeout string
   345  				originalHTTPSProxy       string
   346  				originalForceTTY         string
   347  
   348  				config *Config
   349  			)
   350  
   351  			BeforeEach(func() {
   352  				originalCFStagingTimeout = os.Getenv("CF_STAGING_TIMEOUT")
   353  				originalCFStartupTimeout = os.Getenv("CF_STARTUP_TIMEOUT")
   354  				originalHTTPSProxy = os.Getenv("https_proxy")
   355  				originalForceTTY = os.Getenv("FORCE_TTY")
   356  				os.Setenv("CF_STAGING_TIMEOUT", "8675")
   357  				os.Setenv("CF_STARTUP_TIMEOUT", "309")
   358  				os.Setenv("https_proxy", "proxy.com")
   359  				os.Setenv("FORCE_TTY", "true")
   360  
   361  				var err error
   362  				config, err = LoadConfig()
   363  				Expect(err).ToNot(HaveOccurred())
   364  				Expect(config).ToNot(BeNil())
   365  			})
   366  
   367  			AfterEach(func() {
   368  				os.Setenv("CF_STAGING_TIMEOUT", originalCFStagingTimeout)
   369  				os.Setenv("CF_STARTUP_TIMEOUT", originalCFStartupTimeout)
   370  				os.Setenv("https_proxy", originalHTTPSProxy)
   371  				os.Setenv("FORCE_TTY", originalForceTTY)
   372  			})
   373  
   374  			It("overrides specific config values", func() {
   375  				Expect(config.StagingTimeout()).To(Equal(time.Duration(8675) * time.Minute))
   376  				Expect(config.StartupTimeout()).To(Equal(time.Duration(309) * time.Minute))
   377  				Expect(config.HTTPSProxy()).To(Equal("proxy.com"))
   378  				Expect(config.IsTTY()).To(BeTrue())
   379  			})
   380  		})
   381  
   382  		Describe("APIVersion", func() {
   383  			It("returns the api version", func() {
   384  				config := Config{
   385  					ConfigFile: CFConfig{
   386  						APIVersion: "2.59.0",
   387  					},
   388  				}
   389  
   390  				Expect(config.APIVersion()).To(Equal("2.59.0"))
   391  			})
   392  		})
   393  
   394  		Describe("MinCLIVersion", func() {
   395  			It("returns the minimum CLI version the CC requires", func() {
   396  				config := Config{
   397  					ConfigFile: CFConfig{
   398  						MinCLIVersion: "1.0.0",
   399  					},
   400  				}
   401  
   402  				Expect(config.MinCLIVersion()).To(Equal("1.0.0"))
   403  			})
   404  		})
   405  
   406  		Describe("TargetedOrganization", func() {
   407  			It("returns the organization", func() {
   408  				organization := Organization{
   409  					GUID: "some-guid",
   410  					Name: "some-org",
   411  				}
   412  				config := Config{
   413  					ConfigFile: CFConfig{
   414  						TargetedOrganization: organization,
   415  					},
   416  				}
   417  
   418  				Expect(config.TargetedOrganization()).To(Equal(organization))
   419  			})
   420  		})
   421  
   422  		Describe("TargetedSpace", func() {
   423  			It("returns the space", func() {
   424  				space := Space{
   425  					GUID: "some-guid",
   426  					Name: "some-space",
   427  				}
   428  				config := Config{
   429  					ConfigFile: CFConfig{
   430  						TargetedSpace: space,
   431  					},
   432  				}
   433  
   434  				Expect(config.TargetedSpace()).To(Equal(space))
   435  			})
   436  		})
   437  
   438  		DescribeTable("Verbose",
   439  			func(env string, configTrace string, flag bool, expected bool, location []string) {
   440  				rawConfig := fmt.Sprintf(`{ "Trace":"%s" }`, configTrace)
   441  				setConfig(homeDir, rawConfig)
   442  
   443  				defer os.Unsetenv("CF_TRACE")
   444  				if env == "" {
   445  					os.Unsetenv("CF_TRACE")
   446  				} else {
   447  					os.Setenv("CF_TRACE", env)
   448  				}
   449  
   450  				config, err := LoadConfig(FlagOverride{
   451  					Verbose: flag,
   452  				})
   453  				Expect(err).ToNot(HaveOccurred())
   454  				Expect(config).ToNot(BeNil())
   455  
   456  				verbose, parsedLocation := config.Verbose()
   457  				Expect(verbose).To(Equal(expected))
   458  				Expect(parsedLocation).To(Equal(location))
   459  			},
   460  
   461  			Entry("CF_TRACE true: enables verbose", "true", "", false, true, nil),
   462  			Entry("CF_Trace true, config trace false: enables verbose", "true", "false", false, true, nil),
   463  			Entry("CF_Trace true, config trace file path: enables verbose AND logging to file", "true", "/foo/bar", false, true, []string{"/foo/bar"}),
   464  
   465  			Entry("CF_TRACE false: disables verbose", "false", "", false, false, nil),
   466  			Entry("CF_TRACE false, '-v': enables verbose", "false", "", true, true, nil),
   467  			Entry("CF_TRACE false, config trace true: disables verbose", "false", "true", false, false, nil),
   468  			Entry("CF_TRACE false, config trace file path: enables logging to file", "false", "/foo/bar", false, false, []string{"/foo/bar"}),
   469  			Entry("CF_TRACE false, config trace file path, '-v': enables verbose AND logging to file", "false", "/foo/bar", true, true, []string{"/foo/bar"}),
   470  
   471  			Entry("CF_TRACE empty: disables verbose", "", "", false, false, nil),
   472  			Entry("CF_TRACE empty:, '-v': enables verbose", "", "", true, true, nil),
   473  			Entry("CF_TRACE empty, config trace true: enables verbose", "", "true", false, true, nil),
   474  			Entry("CF_TRACE empty, config trace file path: enables logging to file", "", "/foo/bar", false, false, []string{"/foo/bar"}),
   475  			Entry("CF_TRACE empty, config trace file path, '-v': enables verbose AND logging to file", "", "/foo/bar", true, true, []string{"/foo/bar"}),
   476  
   477  			Entry("CF_TRACE filepath: enables logging to file", "/foo/bar", "", false, false, []string{"/foo/bar"}),
   478  			Entry("CF_TRACE filepath, '-v': enables logging to file", "/foo/bar", "", true, true, []string{"/foo/bar"}),
   479  			Entry("CF_TRACE filepath, config trace true: enables verbose AND logging to file", "/foo/bar", "true", false, true, []string{"/foo/bar"}),
   480  			Entry("CF_TRACE filepath, config trace filepath: enables logging to file for BOTH paths", "/foo/bar", "/baz", false, false, []string{"/foo/bar", "/baz"}),
   481  			Entry("CF_TRACE filepath, config trace filepath, '-v': enables verbose AND logging to file for BOTH paths", "/foo/bar", "/baz", true, true, []string{"/foo/bar", "/baz"}),
   482  		)
   483  
   484  		Describe("DialTimeout", func() {
   485  			var (
   486  				originalDialTimeout string
   487  
   488  				config *Config
   489  			)
   490  
   491  			BeforeEach(func() {
   492  				originalDialTimeout = os.Getenv("CF_DIAL_TIMEOUT")
   493  				os.Setenv("CF_DIAL_TIMEOUT", "1234")
   494  
   495  				var err error
   496  				config, err = LoadConfig()
   497  				Expect(err).ToNot(HaveOccurred())
   498  				Expect(config).ToNot(BeNil())
   499  			})
   500  
   501  			AfterEach(func() {
   502  				os.Setenv("CF_DIAL_TIMEOUT", originalDialTimeout)
   503  			})
   504  
   505  			It("returns the dial timeout", func() {
   506  				Expect(config.DialTimeout()).To(Equal(1234 * time.Second))
   507  			})
   508  		})
   509  
   510  		Describe("BinaryVersion", func() {
   511  			It("returns back version.BinaryVersion", func() {
   512  				conf := Config{}
   513  				Expect(conf.BinaryVersion()).To(Equal("0.0.0-unknown-version"))
   514  			})
   515  		})
   516  
   517  		DescribeTable("LogLevel",
   518  			func(envVal string, expectedLevel int) {
   519  				config := Config{ENV: EnvOverride{CFLogLevel: envVal}}
   520  				Expect(config.LogLevel()).To(Equal(expectedLevel))
   521  			},
   522  
   523  			Entry("Default to 0", "", 0),
   524  			Entry("panic returns 0", "panic", 0),
   525  			Entry("fatal returns 1", "fatal", 1),
   526  			Entry("error returns 2", "error", 2),
   527  			Entry("warn returns 3", "warn", 3),
   528  			Entry("info returns 4", "info", 4),
   529  			Entry("debug returns 5", "debug", 5),
   530  			Entry("dEbUg returns 5", "dEbUg", 5),
   531  		)
   532  	})
   533  
   534  	Describe("WriteConfig", func() {
   535  		var config *Config
   536  
   537  		BeforeEach(func() {
   538  			config = &Config{
   539  				ConfigFile: CFConfig{
   540  					ConfigVersion: 3,
   541  					Target:        "foo.com",
   542  					ColorEnabled:  "true",
   543  				},
   544  				ENV: EnvOverride{
   545  					CFColor: "false",
   546  				},
   547  			}
   548  		})
   549  
   550  		Context("when no errors are encountered", func() {
   551  			It("writes ConfigFile to homeDir/.cf/config.json", func() {
   552  				err := WriteConfig(config)
   553  				Expect(err).ToNot(HaveOccurred())
   554  
   555  				file, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json"))
   556  				Expect(err).ToNot(HaveOccurred())
   557  
   558  				var writtenCFConfig CFConfig
   559  				err = json.Unmarshal(file, &writtenCFConfig)
   560  				Expect(err).ToNot(HaveOccurred())
   561  
   562  				Expect(writtenCFConfig.ConfigVersion).To(Equal(config.ConfigFile.ConfigVersion))
   563  				Expect(writtenCFConfig.Target).To(Equal(config.ConfigFile.Target))
   564  				Expect(writtenCFConfig.ColorEnabled).To(Equal(config.ConfigFile.ColorEnabled))
   565  			})
   566  		})
   567  
   568  		Context("when an error is encountered", func() {
   569  			BeforeEach(func() {
   570  				err := WriteConfig(config)
   571  				Expect(err).ToNot(HaveOccurred())
   572  
   573  				configFilePath := filepath.Join(homeDir, ".cf", "config.json")
   574  				err = os.Remove(configFilePath)
   575  				Expect(err).ToNot(HaveOccurred())
   576  				err = os.Mkdir(configFilePath, 0700)
   577  				Expect(err).ToNot(HaveOccurred())
   578  			})
   579  
   580  			It("returns the error", func() {
   581  				err := WriteConfig(config)
   582  				_, ok := err.(*os.PathError)
   583  				Expect(ok).To(BeTrue())
   584  			})
   585  		})
   586  	})
   587  
   588  	Describe("setter functions", func() {
   589  		Describe("SetTargetInformation", func() {
   590  			It("sets the api target and other related endpoints", func() {
   591  				config := Config{
   592  					ConfigFile: CFConfig{
   593  						TargetedOrganization: Organization{
   594  							GUID: "this-is-a-guid",
   595  							Name: "jo bobo jim boo",
   596  						},
   597  						TargetedSpace: Space{
   598  							GUID:     "this-is-a-guid",
   599  							Name:     "jo bobo jim boo",
   600  							AllowSSH: true,
   601  						},
   602  					},
   603  				}
   604  				config.SetTargetInformation(
   605  					"https://api.foo.com",
   606  					"2.59.31",
   607  					"https://login.foo.com",
   608  					"2.0.0",
   609  					"wws://doppler.foo.com:443",
   610  					"https://uaa.foo.com",
   611  					"https://api.foo.com/routing",
   612  					true,
   613  				)
   614  
   615  				Expect(config.ConfigFile.Target).To(Equal("https://api.foo.com"))
   616  				Expect(config.ConfigFile.APIVersion).To(Equal("2.59.31"))
   617  				Expect(config.ConfigFile.AuthorizationEndpoint).To(Equal("https://login.foo.com"))
   618  				Expect(config.ConfigFile.MinCLIVersion).To(Equal("2.0.0"))
   619  				Expect(config.ConfigFile.DopplerEndpoint).To(Equal("wws://doppler.foo.com:443"))
   620  				Expect(config.ConfigFile.UAAEndpoint).To(Equal("https://uaa.foo.com"))
   621  				Expect(config.ConfigFile.RoutingEndpoint).To(Equal("https://api.foo.com/routing"))
   622  				Expect(config.ConfigFile.SkipSSLValidation).To(BeTrue())
   623  
   624  				Expect(config.ConfigFile.TargetedOrganization.GUID).To(BeEmpty())
   625  				Expect(config.ConfigFile.TargetedOrganization.Name).To(BeEmpty())
   626  				Expect(config.ConfigFile.TargetedSpace.GUID).To(BeEmpty())
   627  				Expect(config.ConfigFile.TargetedSpace.Name).To(BeEmpty())
   628  				Expect(config.ConfigFile.TargetedSpace.AllowSSH).To(BeFalse())
   629  			})
   630  		})
   631  
   632  		Describe("SetTokenInformation", func() {
   633  			It("sets the authentication token information", func() {
   634  				var config Config
   635  				config.SetTokenInformation("I am the access token", "I am the refresh token", "I am the SSH OAuth client")
   636  
   637  				Expect(config.ConfigFile.AccessToken).To(Equal("I am the access token"))
   638  				Expect(config.ConfigFile.RefreshToken).To(Equal("I am the refresh token"))
   639  				Expect(config.ConfigFile.SSHOAuthClient).To(Equal("I am the SSH OAuth client"))
   640  			})
   641  		})
   642  
   643  		Describe("SetAccessToken", func() {
   644  			It("sets the authentication token information", func() {
   645  				var config Config
   646  				config.SetAccessToken("I am the access token")
   647  				Expect(config.ConfigFile.AccessToken).To(Equal("I am the access token"))
   648  			})
   649  		})
   650  
   651  		Describe("SetRefreshToken", func() {
   652  			It("sets the refresh token information", func() {
   653  				var config Config
   654  				config.SetRefreshToken("I am the refresh token")
   655  				Expect(config.ConfigFile.RefreshToken).To(Equal("I am the refresh token"))
   656  			})
   657  		})
   658  
   659  		Describe("SetOrganizationInformation", func() {
   660  			It("sets the organization GUID and name", func() {
   661  				config := Config{}
   662  				config.SetOrganizationInformation("guid-value-1", "my-org-name")
   663  
   664  				Expect(config.ConfigFile.TargetedOrganization.GUID).To(Equal("guid-value-1"))
   665  				Expect(config.ConfigFile.TargetedOrganization.Name).To(Equal("my-org-name"))
   666  			})
   667  		})
   668  
   669  		Describe("SetSpaceInformation", func() {
   670  			It("sets the space GUID, name, and AllowSSH", func() {
   671  				config := Config{}
   672  				config.SetSpaceInformation("guid-value-1", "my-org-name", true)
   673  
   674  				Expect(config.ConfigFile.TargetedSpace.GUID).To(Equal("guid-value-1"))
   675  				Expect(config.ConfigFile.TargetedSpace.Name).To(Equal("my-org-name"))
   676  				Expect(config.ConfigFile.TargetedSpace.AllowSSH).To(BeTrue())
   677  			})
   678  		})
   679  
   680  		Describe("UnsetOrganizationInformation", func() {
   681  			config := Config{}
   682  			BeforeEach(func() {
   683  				config.SetOrganizationInformation("some-org-guid", "some-org")
   684  			})
   685  
   686  			It("resets the org GUID and name", func() {
   687  				config.UnsetOrganizationInformation()
   688  
   689  				Expect(config.ConfigFile.TargetedOrganization.GUID).To(Equal(""))
   690  				Expect(config.ConfigFile.TargetedOrganization.Name).To(Equal(""))
   691  			})
   692  		})
   693  
   694  		Describe("UnsetSpaceInformation", func() {
   695  			config := Config{}
   696  			BeforeEach(func() {
   697  				config.SetSpaceInformation("guid-value-1", "my-org-name", true)
   698  			})
   699  
   700  			It("resets the space GUID, name, and AllowSSH to default values", func() {
   701  				config.UnsetSpaceInformation()
   702  
   703  				Expect(config.ConfigFile.TargetedSpace.GUID).To(Equal(""))
   704  				Expect(config.ConfigFile.TargetedSpace.Name).To(Equal(""))
   705  				Expect(config.ConfigFile.TargetedSpace.AllowSSH).To(BeFalse())
   706  			})
   707  		})
   708  	})
   709  })