Example #1
0
func TestLoad(t *testing.T) {
	config := auth551.Config{
		Form: auth551.ConfigForm{
			LoginId: "",
		},
		Google: auth551.ConfigOAuth{
			Vendor:       "google",
			ClientId:     "Sample_ClientId",
			ClientSecret: "Sample_ClientSecret",
			RedirectUrl:  "https:sample.auth551.pubapp.biz",
			Scope: []string{
				"https://sample1.scope.pubapp.biz",
				"https://sample2.scope.pubapp.biz",
				"https://sample3.scope.pubapp.biz",
			},
			AuthUrl:  "https://auth.sample.auth551.pubapp.biz",
			TokenUrl: "https://token.sample.auth551.pubapp.biz",
		},
	}

	a1 := auth551.Load(&config)
	a2 := auth551.Load(&config)

	if a1 == nil {
		t.Errorf("インスタンスの生成に失敗しました。")
	}
	if a2 == nil {
		t.Errorf("インスタンスの生成に失敗しました。")
	}
	if a1 != a2 {
		t.Errorf("インスタンスの生成に失敗しました。")
	}
}
Example #2
0
File: gorai.go Project: go51/gorai
func (g *gorai) initialize() {
	g.config = loadConfig()

	// Logger
	if isConsole() {
		g.logger = log551.New(&g.config.Framework.CommandLog)
	} else {
		g.logger = log551.New(&g.config.Framework.SystemLog)
	}
	g.logger.Open()
	defer g.logger.Close()

	// Router
	g.router = router551.Load()

	// ModelManager
	g.modelManager = model551.Load()

	// Add Auth Model
	g.modelManager.Add(auth551.NewUserModel, auth551.NewUserModelPointer)
	g.modelManager.Add(auth551.NewUserTokenModel, auth551.NewUserTokenModelPointer)

	// Auth
	g.auth = auth551.Load(&g.config.Framework.Auth)
}
Example #3
0
func BenchmarkAuthCodeUrl(b *testing.B) {
	config := auth551.Config{
		Form: auth551.ConfigForm{
			LoginId: "",
		},
		Google: auth551.ConfigOAuth{
			Vendor:       "google",
			ClientId:     "Sample_ClientId",
			ClientSecret: "Sample_ClientSecret",
			RedirectUrl:  "https:sample.auth551.pubapp.biz",
			Scope: []string{
				"https://sample1.scope.pubapp.biz",
				"https://sample2.scope.pubapp.biz",
				"https://sample3.scope.pubapp.biz",
			},
			AuthUrl:  "https://auth.sample.auth551.pubapp.biz",
			TokenUrl: "https://token.sample.auth551.pubapp.biz",
		},
	}

	a := auth551.Load(&config)

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		_ = a.AuthCodeUrl(auth551.VENDOR_GOOGLE)
	}
}
Example #4
0
func TestAuthCodeUrl(t *testing.T) {
	config := auth551.Config{
		Form: auth551.ConfigForm{
			LoginId: "",
		},
		Google: auth551.ConfigOAuth{
			Vendor:       "google",
			ClientId:     "Sample_ClientId",
			ClientSecret: "Sample_ClientSecret",
			RedirectUrl:  "https:sample.auth551.pubapp.biz",
			Scope: []string{
				"https://sample1.scope.pubapp.biz",
				"https://sample2.scope.pubapp.biz",
				"https://sample3.scope.pubapp.biz",
			},
			AuthUrl:  "https://auth.sample.auth551.pubapp.biz",
			TokenUrl: "https://token.sample.auth551.pubapp.biz",
		},
	}

	a := auth551.Load(&config)

	url := a.AuthCodeUrl(auth551.VENDOR_GOOGLE)

	if url != "https://auth.sample.auth551.pubapp.biz?access_type=offline&client_id=Sample_ClientId&redirect_uri=https%3Asample.auth551.pubapp.biz&response_type=code&scope=https%3A%2F%2Fsample1.scope.pubapp.biz+https%3A%2F%2Fsample2.scope.pubapp.biz+https%3A%2F%2Fsample3.scope.pubapp.biz" {
		t.Errorf("URL の生成に失敗しました。")
	}
}