-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ACLs: Modify superuser command and add migrate flow (#8087)
* ACLs: Modify superuser command and add migrate flow * Fix tests * lint * more fixes * more fixes * last fix * CR Fixes
- Loading branch information
Showing
17 changed files
with
447 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
lakeFS is a data lake management platform | ||
|
||
Usage: | ||
lakefs [command] | ||
|
||
Available Commands: | ||
completion Generate completion script | ||
flare collect configuration, environment variables, and logs for debugging and troubleshooting | ||
help Help about any command | ||
migrate Manage migrations | ||
run Run lakeFS | ||
setup Setup a new lakeFS instance with initial credentials | ||
superuser Create additional user with admin credentials | ||
|
||
Flags: | ||
-c, --config string config file (default is $HOME/.lakefs.yaml) | ||
-h, --help help for lakefs | ||
--local-settings Use lakeFS local default configuration | ||
--quickstart Use lakeFS quickstart configuration | ||
-t, --toggle Help message for toggle | ||
-v, --version version for lakefs | ||
|
||
Use "lakefs [command] --help" for more information about a command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package esti | ||
|
||
import "testing" | ||
|
||
func TestLakefsHelp(t *testing.T) { | ||
RunCmdAndVerifySuccessWithFile(t, Lakefs(), false, "lakefs/help", emptyVars) | ||
RunCmdAndVerifySuccessWithFile(t, Lakefs()+" --help", false, "lakefs/help", emptyVars) | ||
RunCmdAndVerifySuccessWithFile(t, Lakefs(), true, "lakefs/help", emptyVars) | ||
RunCmdAndVerifySuccessWithFile(t, Lakefs()+" --help", true, "lakefs/help", emptyVars) | ||
} | ||
|
||
func TestLakefsSuperuser_basic(t *testing.T) { | ||
RequirePostgresDB(t) | ||
lakefsCmd := Lakefs() | ||
outputString := "credentials:\n access_key_id: <ACCESS_KEY_ID>\n secret_access_key: <SECRET_ACCESS_KEY>\n" | ||
username := t.Name() | ||
expectFailure := false | ||
if isBasicAuth() { | ||
lakefsCmd = LakefsWithBasicAuth() | ||
outputString = "already exists" | ||
expectFailure = true | ||
} | ||
runCmdAndVerifyContainsText(t, lakefsCmd+" superuser --user-name "+username, expectFailure, false, outputString, nil) | ||
} | ||
|
||
func TestLakefsSuperuser_alreadyExists(t *testing.T) { | ||
RequirePostgresDB(t) | ||
lakefsCmd := Lakefs() | ||
if isBasicAuth() { | ||
lakefsCmd = LakefsWithBasicAuth() | ||
} | ||
// On init - the AdminUsername is already created and expected error should be "already exist" (also in basic auth mode) | ||
RunCmdAndVerifyFailureContainsText(t, lakefsCmd+" superuser --user-name "+AdminUsername, false, "already exists", nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package esti | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
func LakefsWithParams(connectionString string) string { | ||
return LakefsWithParamsWithBasicAuth(connectionString, false) | ||
} | ||
|
||
func LakefsWithParamsWithBasicAuth(connectionString string, basicAuth bool) string { | ||
lakefsCmdline := "LAKEFS_DATABASE_TYPE=postgres" + | ||
" LAKEFS_DATABASE_POSTGRES_CONNECTION_STRING=" + connectionString + | ||
" LAKEFS_AUTH_INTERNAL_BASIC=" + strconv.FormatBool(basicAuth) + | ||
" LAKEFS_BLOCKSTORE_TYPE=" + viper.GetString("blockstore_type") + | ||
" LAKEFS_AUTH_ENCRYPT_SECRET_KEY='some random secret string' " + lakefsLocation() | ||
|
||
return lakefsCmdline | ||
} | ||
|
||
func lakefsLocation() string { | ||
return viper.GetString("binaries_dir") + "/lakefs" | ||
} | ||
|
||
func LakefsWithBasicAuth() string { | ||
return LakefsWithParamsWithBasicAuth(viper.GetString("database_connection_string"), true) | ||
} | ||
|
||
func Lakefs() string { | ||
return LakefsWithParams(viper.GetString("database_connection_string")) | ||
} | ||
|
||
func RequirePostgresDB(t *testing.T) { | ||
dbString := viper.GetString("database_connection_string") | ||
if dbString == "" { | ||
t.Skip("skip test - not postgres") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.