Пример #1
0
// Starts the server and initializes the servers IP address,
// port and usernames to be used by the test cases.
func init() {
	addr, err := vault.StartSSHHostTestServer()
	if err != nil {
		panic(fmt.Sprintf("error starting mock server:%s", err))
	}
	input := strings.Split(addr, ":")
	testIP = input[0]

	u, err := user.Current()
	if err != nil {
		panic(fmt.Sprintf("error getting current username: '******'", err))
	}
	testUserName = u.Username
	testAdminUser = u.Username

	testOTPRoleData = map[string]interface{}{
		"key_type":     testOTPKeyType,
		"default_user": testUserName,
		"cidr_list":    testCIDRList,
	}
	testDynamicRoleData = map[string]interface{}{
		"key_type":     testDynamicKeyType,
		"key":          testKeyName,
		"admin_user":   testAdminUser,
		"default_user": testAdminUser,
		"cidr_list":    testCIDRList,
	}
}
Пример #2
0
// Starts the server and initializes the servers IP address,
// port and usernames to be used by the test cases.
func initTest() {
	addr, err := vault.StartSSHHostTestServer()
	if err != nil {
		panic(fmt.Sprintf("error starting mock server:%s", err))
	}
	input := strings.Split(addr, ":")
	testIP = input[0]

	testUserName := os.Getenv("VAULT_SSHTEST_USER")
	if len(testUserName) == 0 {
		panic("VAULT_SSHTEST_USER must be set to the desired user")
	}
	testAdminUser = testUserName

	testOTPRoleData = map[string]interface{}{
		"key_type":     testOTPKeyType,
		"default_user": testUserName,
		"cidr_list":    testCIDRList,
	}
	testDynamicRoleData = map[string]interface{}{
		"key_type":     testDynamicKeyType,
		"key":          testKeyName,
		"admin_user":   testAdminUser,
		"default_user": testAdminUser,
		"cidr_list":    testCIDRList,
	}
}
Пример #3
0
// Starts the server and initializes the servers IP address,
// port and usernames to be used by the test cases.
func initTest() {
	addr, err := vault.StartSSHHostTestServer()
	if err != nil {
		panic(fmt.Sprintf("Error starting mock server:%s", err))
	}
	input := strings.Split(addr, ":")
	testIP = input[0]
	testPort = input[1]

	testUserName := os.Getenv("VAULT_SSHTEST_USER")
	if len(testUserName) == 0 {
		panic("VAULT_SSHTEST_USER must be set to the desired user")
	}
	testAdminUser = testUserName
}
Пример #4
0
func testingFactory(conf *logical.BackendConfig) (logical.Backend, error) {
	_, err := vault.StartSSHHostTestServer()
	if err != nil {
		panic(fmt.Sprintf("error starting mock server:%s", err))
	}
	defaultLeaseTTLVal := 2 * time.Minute
	maxLeaseTTLVal := 10 * time.Minute
	return Factory(&logical.BackendConfig{
		Logger:      nil,
		StorageView: &logical.InmemStorage{},
		System: &logical.StaticSystemView{
			DefaultLeaseTTLVal: defaultLeaseTTLVal,
			MaxLeaseTTLVal:     maxLeaseTTLVal,
		},
	})
}
Пример #5
0
// Starts the server and initializes the servers IP address,
// port and usernames to be used by the test cases.
func init() {
	addr, err := vault.StartSSHHostTestServer()
	if err != nil {
		panic(fmt.Sprintf("Error starting mock server:%s", err))
	}
	input := strings.Split(addr, ":")
	testIP = input[0]
	testPort = input[1]

	u, err := user.Current()
	if err != nil {
		panic(fmt.Sprintf("Error getting current username: '******'", err))
	}
	testUserName = u.Username
	testAdminUser = u.Username
}
Пример #6
0
// Starts the server and initializes the servers IP address,
// port and usernames to be used by the test cases.
func init() {
	addr, err := vault.StartSSHHostTestServer()
	if err != nil {
		panic(fmt.Sprintf("error starting mock server:%s", err))
	}
	input := strings.Split(addr, ":")
	testIP = input[0]
	testPort, err = strconv.Atoi(input[1])
	if err != nil {
		panic(fmt.Sprintf("error parsing port number:%s", err))
	}

	u, err := user.Current()
	if err != nil {
		panic(fmt.Sprintf("error getting current username: '******'", err))
	}
	testUserName = u.Username
	testAdminUser = u.Username
	testInstallScript = DefaultPublicKeyInstallScript
}