@@ -73,3 +73,39 @@ func TestSetConfigProperty_EnvVarConfigFilePath(t *testing.T) {
7373 err , _ = executeCommand (t , "configure" , "set" , "--prop-name" , "cx_client_id" , "--prop-value" , "example_client_id" )
7474 assert .NilError (t , err )
7575}
76+
77+ func TestLoadConfiguration_ConfigFilePathFlag (t * testing.T ) {
78+ err , _ := executeCommand (t , "configure" , "show" , "--config-file-path" , filePath )
79+ assert .NilError (t , err )
80+ }
81+
82+ func TestLoadConfiguration_ConfigFilePathFlagValidDirectory (t * testing.T ) {
83+ err , _ := executeCommand (t , "configure" , "show" , "--config-file-path" , "data" )
84+ assert .ErrorContains (t , err , "The specified path points to a directory, not a file." )
85+ }
86+
87+ func TestLoadConfiguration_ConfigFilePathFlagFileNotFound (t * testing.T ) {
88+ err , _ := executeCommand (t , "configure" , "show" , "--config-file-path" , "data/nonexistent_config.yaml" )
89+ assert .ErrorContains (t , err , "The specified file does not exist." )
90+ }
91+
92+ func TestSetConfigProperty_ConfigFilePathFlag (t * testing.T ) {
93+ err , _ := executeCommand (t , "configure" , "set" , "--prop-name" , "cx_client_id" , "--prop-value" , "dummy-client_id" , "--config-file-path" , filePath )
94+ assert .NilError (t , err )
95+
96+ content , err := os .ReadFile (filePath )
97+ assert .NilError (t , err )
98+ assert .Assert (t , strings .Contains (string (content ), "dummy-client_id" ))
99+
100+ err , _ = executeCommand (t , "configure" , "set" , "--prop-name" , "cx_client_id" , "--prop-value" , "example_client_id" , "--config-file-path" , filePath )
101+ assert .NilError (t , err )
102+ }
103+
104+ func TestLoadConfiguration_ConfigFilePathFlagFileWithoutPermission (t * testing.T ) {
105+ if err := os .Chmod (filePath , 0000 ); err != nil {
106+ t .Fatalf ("failed to set file permissions: %v" , err )
107+ }
108+ defer os .Chmod (filePath , 0644 )
109+ err , _ := executeCommand (t , "configure" , "show" , "--config-file-path" , filePath )
110+ assert .ErrorContains (t , err , "Access to the specified file is restricted" )
111+ }
0 commit comments