當前位置: 首頁>>代碼示例>>Golang>>正文


Golang testing.TestCheckAuth函數代碼示例

本文整理匯總了Golang中github.com/hashicorp/vault/logical/testing.TestCheckAuth函數的典型用法代碼示例。如果您正苦於以下問題:Golang TestCheckAuth函數的具體用法?Golang TestCheckAuth怎麽用?Golang TestCheckAuth使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了TestCheckAuth函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: testAccStepLogin

func testAccStepLogin(t *testing.T, username string) logicaltest.TestStep {
	return logicaltest.TestStep{
		Operation: logical.UpdateOperation,
		Path:      "login",
		Data: map[string]interface{}{
			"method":   "accept",
			"username": username,
		},
		Unauthenticated: true,
		Check:           logicaltest.TestCheckAuth([]string{"foo"}),
	}
}
開發者ID:freimer,項目名稱:vault,代碼行數:12,代碼來源:mfa_test.go

示例2: testAccLogin

func testAccLogin(t *testing.T, keys []string) logicaltest.TestStep {
	return logicaltest.TestStep{
		Operation: logical.WriteOperation,
		Path:      "login",
		Data: map[string]interface{}{
			"token": os.Getenv("GITHUB_TOKEN"),
		},
		Unauthenticated: true,

		Check: logicaltest.TestCheckAuth(keys),
	}
}
開發者ID:n1tr0g,項目名稱:vault,代碼行數:12,代碼來源:backend_test.go

示例3: testAccStepLogin

func testAccStepLogin(t *testing.T, user string, pass string) logicaltest.TestStep {
	return logicaltest.TestStep{
		Operation: logical.UpdateOperation,
		Path:      "login/" + user,
		Data: map[string]interface{}{
			"password": pass,
		},
		Unauthenticated: true,

		Check: logicaltest.TestCheckAuth([]string{"foo", "bar"}),
	}
}
開發者ID:richardzone,項目名稱:vault,代碼行數:12,代碼來源:backend_test.go

示例4: testAccStepLogin

func testAccStepLogin(t *testing.T, user string, pass string) logicaltest.TestStep {
	return logicaltest.TestStep{
		Operation: logical.UpdateOperation,
		Path:      "login/" + user,
		Data: map[string]interface{}{
			"password": pass,
		},
		Unauthenticated: true,

		// Verifies user tesla maps to groups via local group (engineers) as well as remote group (Scientiests)
		Check: logicaltest.TestCheckAuth([]string{"bar", "default", "foo"}),
	}
}
開發者ID:mhurne,項目名稱:vault,代碼行數:13,代碼來源:backend_test.go

示例5: testAccStepLogin

func testAccStepLogin(t *testing.T, connState tls.ConnectionState) logicaltest.TestStep {
	return logicaltest.TestStep{
		Operation:       logical.WriteOperation,
		Path:            "login",
		Unauthenticated: true,
		ConnState:       &connState,
		Check: func(resp *logical.Response) error {
			if resp.Auth.TTL != 1000*time.Second {
				t.Fatalf("bad lease length: %#v", resp.Auth)
			}

			fn := logicaltest.TestCheckAuth([]string{"foo"})
			return fn(resp)
		},
	}
}
開發者ID:rlhatcher,項目名稱:vault,代碼行數:16,代碼來源:backend_test.go

示例6: testAccLogin

func testAccLogin(t *testing.T, display string) logicaltest.TestStep {
	return logicaltest.TestStep{
		Operation: logical.WriteOperation,
		Path:      "login",
		Data: map[string]interface{}{
			"app_id":  "foo",
			"user_id": "42",
		},
		Unauthenticated: true,

		Check: logicaltest.TestCheckMulti(
			logicaltest.TestCheckAuth([]string{"bar", "foo"}),
			logicaltest.TestCheckAuthDisplayName(display),
		),
	}
}
開發者ID:vincentaubert,項目名稱:vault,代碼行數:16,代碼來源:backend_test.go

示例7: testAccStepLoginNoGroupDN

func testAccStepLoginNoGroupDN(t *testing.T, user string, pass string) logicaltest.TestStep {
	return logicaltest.TestStep{
		Operation: logical.UpdateOperation,
		Path:      "login/" + user,
		Data: map[string]interface{}{
			"password": pass,
		},
		Unauthenticated: true,

		Check: func(resp *logical.Response) error {
			if len(resp.Warnings()) != 1 {
				return fmt.Errorf("expected a warning due to no group dn, got: %#v", resp.Warnings())
			}

			return logicaltest.TestCheckAuth([]string{"bar", "default"})(resp)
		},
	}
}
開發者ID:citywander,項目名稱:vault,代碼行數:18,代碼來源:backend_test.go

示例8: testAccLoginCidr

func testAccLoginCidr(t *testing.T, ip string, err bool) logicaltest.TestStep {
	check := logicaltest.TestCheckError()
	if !err {
		check = logicaltest.TestCheckAuth([]string{"bar", "foo"})
	}

	return logicaltest.TestStep{
		Operation: logical.WriteOperation,
		Path:      "login",
		Data: map[string]interface{}{
			"app_id":  "foo",
			"user_id": "42",
		},
		ErrorOk:         err,
		Unauthenticated: true,
		RemoteAddr:      ip,

		Check: check,
	}
}
開發者ID:vincentaubert,項目名稱:vault,代碼行數:20,代碼來源:backend_test.go

示例9: testAccLoginAppIDInPath

func testAccLoginAppIDInPath(t *testing.T, display string) logicaltest.TestStep {
	checkTTL := func(resp *logical.Response) error {
		if resp.Auth.LeaseOptions.TTL.String() != "720h0m0s" {
			return fmt.Errorf("invalid TTL")
		}
		return nil
	}
	return logicaltest.TestStep{
		Operation: logical.UpdateOperation,
		Path:      "login/foo",
		Data: map[string]interface{}{
			"user_id": "42",
		},
		Unauthenticated: true,

		Check: logicaltest.TestCheckMulti(
			logicaltest.TestCheckAuth([]string{"bar", "default", "foo"}),
			logicaltest.TestCheckAuthDisplayName(display),
			checkTTL,
		),
	}
}
開發者ID:faradayio,項目名稱:vault-1,代碼行數:22,代碼來源:backend_test.go


注:本文中的github.com/hashicorp/vault/logical/testing.TestCheckAuth函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。