• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang objx.MSI函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/stretchr/objx.MSI函数的典型用法代码示例。如果您正苦于以下问题:Golang MSI函数的具体用法?Golang MSI怎么用?Golang MSI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MSI函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestOAuth2HandlerBeginAuthURLWithBaseMultipleScope

func TestOAuth2HandlerBeginAuthURLWithBaseMultipleScope(t *testing.T) {

	common.SetSecurityKey("rAALj6QhRjsTo3VKzfWuK21qNZ5bFfqPJ9sYNerSYeKKoMIPAi9vaIusjmqyLE3S")

	base := "https://base.url/auth"

	config := &common.Config{Map: objx.MSI()}
	config.
		Set("client_id", "client_id").
		Set("redirect_uri", "redirect_uri").
		Set("scope", "scope1 scope2").
		Set("access_type", "access_type").
		Set("approval_prompt", "approval_prompt")

	state := &common.State{Map: objx.MSI("after", "http://www.stretchr.com/")}
	base64State, _ := state.Base64()

	url, err := GetBeginAuthURLWithBase(base, state, config)

	if assert.NoError(t, err) {
		assert.Contains(t, url, "client_id=client_id")
		assert.Contains(t, url, "redirect_uri=redirect_uri")
		assert.Contains(t, url, "scope=scope1+scope2")
		assert.Contains(t, url, "access_type=access_type")
		assert.Contains(t, url, "approval_prompt=approval_prompt")
		assert.Contains(t, url, "state="+base64State)
	}

}
开发者ID:toggl,项目名称:gomniauth,代码行数:29,代码来源:url_test.go


示例2: TestUnMarshal_ObjxMap

func TestUnMarshal_ObjxMap(t *testing.T) {

	obj1 := objx.MSI("name", "Mat", "age", 30, "language", "en")
	obj2 := objx.MSI("obj", obj1)
	obj3 := objx.MSI("another_obj", obj2)

	csvCodec := new(CsvCodec)
	bytes, _ := csvCodec.Marshal(obj3, nil)

	log.Printf("bytes = %s", string(bytes))

	// unmarshal it back
	var obj interface{}
	csvCodec.Unmarshal(bytes, &obj)

	if objmap, ok := obj.(map[string]interface{}); ok {
		if objmap2, ok := objmap["another_obj"].(map[string]interface{}); ok {
			if objmap3, ok := objmap2["obj"].(map[string]interface{}); ok {

				assert.Equal(t, "Mat", objmap3["name"])
				assert.Equal(t, 30, objmap3["age"])
				assert.Equal(t, "en", objmap3["language"])

			} else {
				assert.True(t, false, "another_obj.obj should be msi")
			}
		} else {
			assert.True(t, false, "another_obj should be msi")
		}
	} else {
		assert.True(t, false, "obj should be msi")
	}

}
开发者ID:syohex,项目名称:codecs,代码行数:34,代码来源:csv_codec_test.go


示例3: TestOAuth2Provider_Non200Response

func TestOAuth2Provider_Non200Response(t *testing.T) {

	config := &common.Config{
		Map: objx.MSI(
			OAuth2KeyRedirectUrl, OAuth2KeyRedirectUrl,
			OAuth2KeyScope, OAuth2KeyScope,
			OAuth2KeyClientID, OAuth2KeyClientID,
			OAuth2KeySecret, OAuth2KeySecret,
			OAuth2KeyAuthURL, OAuth2KeyAuthURL,
			OAuth2KeyTokenURL, OAuth2KeyTokenURL)}

	testTripperFactory := new(test.TestTripperFactory)
	testTripper := new(test.TestTripper)
	testProvider := new(test.TestProvider)

	testResponse := new(http.Response)
	testResponse.Header = make(http.Header)
	testResponse.Header.Set("Content-Type", "text/plain")
	testResponse.StatusCode = 401
	testResponse.Body = ioutil.NopCloser(strings.NewReader("No mate"))

	testTripperFactory.On("NewTripper", common.EmptyCredentials, mock.Anything).Return(testTripper, nil)
	testTripper.On("RoundTrip", mock.Anything).Return(testResponse, nil)

	data := objx.MSI(OAuth2KeyCode, []string{"123"})
	_, err := CompleteAuth(testTripperFactory, data, config, testProvider)

	if assert.Error(t, err) {
		assert.IsType(t, &common.AuthServerError{}, err)
	}

	mock.AssertExpectationsForObjects(t, testTripperFactory.Mock, testTripper.Mock, testProvider.Mock)

}
开发者ID:jmptrader,项目名称:gomniauth,代码行数:34,代码来源:complete_auth_test.go


示例4: TestspotifyGetBeginAuthURL

func TestspotifyGetBeginAuthURL(t *testing.T) {

	common.SetSecurityKey("ABC123")

	state := &common.State{Map: objx.MSI("after", "http://www.chikin14niwa.com/")}

	g := New("clientID", "secret", "http://myapp.com/")

	url, err := g.GetBeginAuthURL(state, nil)

	if assert.NoError(t, err) {
		assert.Contains(t, url, "client_id=clientID")
		assert.Contains(t, url, "redirect_uri=http%3A%2F%2Fmyapp.com%2F")
		assert.Contains(t, url, "scope="+spotifyDefaultScope)
		assert.Contains(t, url, "access_type="+oauth2.OAuth2AccessTypeOnline)
		assert.Contains(t, url, "approval_prompt="+oauth2.OAuth2ApprovalPromptAuto)
	}

	state = &common.State{Map: objx.MSI("after", "http://www.chikin14niwa.com/")}

	g = New("clientID", "secret", "http://myapp.com/")

	url, err = g.GetBeginAuthURL(state, objx.MSI(oauth2.OAuth2KeyScope, "avatar"))

	if assert.NoError(t, err) {
		assert.Contains(t, url, "client_id=clientID")
		assert.Contains(t, url, "redirect_uri=http%3A%2F%2Fmyapp.com%2F")
		assert.Contains(t, url, "scope=avatar+"+spotifyDefaultScope)
		assert.Contains(t, url, "access_type="+oauth2.OAuth2AccessTypeOnline)
		assert.Contains(t, url, "approval_prompt="+oauth2.OAuth2ApprovalPromptAuto)
	}

}
开发者ID:chikin14niwa,项目名称:gomniauth,代码行数:33,代码来源:spotify_test.go


示例5: TestNewUser

func TestNewUser(t *testing.T) {
	testProvider := new(test.TestProvider)
	testProvider.On("Name").Return("providerName")

	data := objx.MSI(
		spotifyKeyID, "123435467890",
		spotifyKeyName, "Mathew",
		spotifyKeyEmail, "[email protected]",
		spotifyKeyNickname, "Mat",
	)

	creds := &common.Credentials{Map: objx.MSI(oauth2.OAuth2KeyAccessToken, "ABC123")}

	user := NewUser(data, creds, testProvider)

	if assert.NotNil(t, user) {

		assert.Equal(t, data, user.Data())

		assert.Equal(t, "Mathew", user.Name())
		assert.Equal(t, "[email protected]", user.Email())
		assert.Equal(t, "Mat", user.Nickname())

		// check provider credentials
		creds := user.ProviderCredentials()[testProvider.Name()]
		if assert.NotNil(t, creds) {
			assert.Equal(t, "ABC123", creds.Get(oauth2.OAuth2KeyAccessToken).Str())
			assert.Equal(t, "123435467890", creds.Get(common.CredentialsKeyID).Str())
		}

	}

	mock.AssertExpectationsForObjects(t, testProvider.Mock)
}
开发者ID:toggl,项目名称:gomniauth,代码行数:34,代码来源:user_test.go


示例6: TestNewUser

func TestNewUser(t *testing.T) {

	testProvider := new(test.TestProvider)
	testProvider.On("Name").Return("providerName")

	data := objx.MSI(
		instagramKeyID, "123435467890",
		instagramKeyName, "Raquel",
		instagramKeyNickname, "maggit",
		instagramKeyAvatarUrl, "http://instagram.com/")
	creds := &common.Credentials{Map: objx.MSI(oauth2.OAuth2KeyAccessToken, "ABC12345")}

	user := NewUser(data, creds, testProvider)

	if assert.NotNil(t, user) {

		assert.Equal(t, data, user.Data())

		assert.Equal(t, "Raquel", user.Name())
		assert.Equal(t, "maggit", user.Nickname())
		assert.Equal(t, "http://instagram.com/", user.AvatarURL())

		// check provider credentials
		creds := user.ProviderCredentials()[testProvider.Name()]
		if assert.NotNil(t, creds) {
			assert.Equal(t, "ABC12345", creds.Get(oauth2.OAuth2KeyAccessToken).Str())
			assert.Equal(t, "123435467890", creds.Get(common.CredentialsKeyID).Str())
		}

	}

	mock.AssertExpectationsForObjects(t, testProvider.Mock)

}
开发者ID:yamadapc,项目名称:gomniauth,代码行数:34,代码来源:user_test.go


示例7: TestIDForProvider

func TestIDForProvider(t *testing.T) {
	user := new(User)
	user.data = objx.MSI(
		common.UserKeyProviderCredentials,
		map[string]*common.Credentials{
			"github": &common.Credentials{Map: objx.MSI(common.CredentialsKeyID, "githubid")},
			"google": &common.Credentials{Map: objx.MSI(common.CredentialsKeyID, "googleid")}})

	assert.Equal(t, "githubid", user.IDForProvider("github"))
	assert.Equal(t, "googleid", user.IDForProvider("google"))
}
开发者ID:toggl,项目名称:gomniauth,代码行数:11,代码来源:user_test.go


示例8: TestGetUser

func TestGetUser(t *testing.T) {

	g := New("clientID", "secret", "http://myapp.com/")
	creds := &common.Credentials{Map: objx.MSI()}

	testTripperFactory := new(test.TestTripperFactory)
	testTripper := new(test.TestTripper)
	testTripperFactory.On("NewTripper", mock.Anything, g).Return(testTripper, nil)
	testResponse := new(http.Response)
	testResponse.Header = make(http.Header)
	testResponse.Header.Set("Content-Type", "application/json")
	testResponse.StatusCode = 200
	testResponse.Body = ioutil.NopCloser(strings.NewReader(`{"name":"their-name","id":"uniqueid","login":"loginname","email":"[email protected]","picture":"http://myface.com/","blog":"http://blog.com/"}`))
	testTripper.On("RoundTrip", mock.Anything).Return(testResponse, nil)

	g.tripperFactory = testTripperFactory

	user, err := g.GetUser(creds)

	if assert.NoError(t, err) && assert.NotNil(t, user) {

		assert.Equal(t, user.Name(), "their-name")
		assert.Equal(t, user.AuthCode(), "") // doesn't come from google
		assert.Equal(t, user.Email(), "[email protected]")
		assert.Equal(t, user.AvatarURL(), "http://myface.com/")
		assert.Equal(t, user.Data()["blog"], "http://blog.com/")

		googleCreds := user.ProviderCredentials()[googleName]
		if assert.NotNil(t, googleCreds) {
			assert.Equal(t, "uniqueid", googleCreds.Get(common.CredentialsKeyID).Str())
		}

	}

}
开发者ID:toggl,项目名称:gomniauth,代码行数:35,代码来源:google_test.go


示例9: TestMarshalWithCodec_WithError

func TestMarshalWithCodec_WithError(t *testing.T) {

	// func (s *WebCodecService) MarshalWithCodec(codec codecs.Codec, object interface{}, options ...interface{}) ([]byte, error) {

	testCodec := new(test.TestCodec)
	service := NewWebCodecService()

	// make some test stuff
	object := objx.MSI("Name", "Mat")
	var option1 string = "Option One"
	var option2 string = "Option Two"

	args := map[string]interface{}{option1: option1, option2: option2}

	// setup expectations
	testCodec.On("Marshal", object, args).Return(nil, assert.AnError)

	_, err := service.MarshalWithCodec(testCodec, object, args)

	assert.Equal(t, assert.AnError, err, "The error should get returned")

	// assert that our expectations were met
	mock.AssertExpectationsForObjects(t, testCodec.Mock)

}
开发者ID:syohex,项目名称:codecs,代码行数:25,代码来源:web_codec_service_test.go


示例10: TestMarshalWithCodec

func TestMarshalWithCodec(t *testing.T) {

	testCodec := new(test.TestCodec)
	service := NewWebCodecService()

	// make some test stuff
	var bytesToReturn []byte = []byte("Hello World")
	var object objx.Map = objx.MSI("Name", "Mat")
	var option1 string = "Option One"
	var option2 string = "Option Two"

	args := map[string]interface{}{option1: option1, option2: option2}

	// setup expectations
	testCodec.On("Marshal", object, args).Return(bytesToReturn, nil)

	bytes, err := service.MarshalWithCodec(testCodec, object, args)

	if assert.Nil(t, err) {
		assert.Equal(t, string(bytesToReturn), string(bytes))
	}

	// assert that our expectations were met
	mock.AssertExpectationsForObjects(t, testCodec.Mock)

}
开发者ID:syohex,项目名称:codecs,代码行数:26,代码来源:web_codec_service_test.go


示例11: TestRoundTrip

func TestRoundTrip(t *testing.T) {

	underlyingTripper := new(testifyhttp.TestRoundTripper)
	testProvider := new(test.TestProvider)
	creds := &common.Credentials{Map: objx.MSI()}
	creds.Set(OAuth2KeyAccessToken, "This is a real access token :)")

	tripper := new(OAuth2Tripper)
	tripper.underlyingTransport = underlyingTripper
	tripper.credentials = creds
	tripper.provider = testProvider

	request, _ := http.NewRequest("GET", "something", nil)

	underlyingTripper.On("RoundTrip", mock.Anything).Return(new(http.Response), nil)

	response, err := tripper.RoundTrip(request)

	if assert.NoError(t, err) {
		if assert.NotNil(t, response) {

			actualRequest := underlyingTripper.Calls[0].Arguments[0].(*http.Request)

			if assert.NotEqual(t, &actualRequest, &request, "Actual request should be different") {
				headerK, headerV := AuthorizationHeader(creds)
				assert.Equal(t, actualRequest.Header.Get(headerK), headerV)
			}

		}
	}

	mock.AssertExpectationsForObjects(t, testProvider.Mock, underlyingTripper.Mock)

}
开发者ID:amencarini,项目名称:gomniauth,代码行数:34,代码来源:oauth2_tripper_test.go


示例12: GetBeginAuthURLWithBase

// GetBeginAuthURLWithBase returns the OAuth2 authorization URL from the given arguments.
//
// The state object will be encoded to base64 and signed to ensure integrity.
func GetBeginAuthURLWithBase(base string, state *common.State, config *common.Config) (string, error) {

	if config == nil {
		panic("OAuth2Handler: Must have valid Config specified.")
	}

	// copy the config
	params := objx.MSI(
		OAuth2KeyClientID, config.Get(OAuth2KeyClientID).Str(),
		OAuth2KeyRedirectUrl, config.Get(OAuth2KeyRedirectUrl).Str(),
		OAuth2KeyScope, config.Get(OAuth2KeyScope).Str(),
		OAuth2KeyAccessType, config.Get(OAuth2KeyAccessType).Str(),
		OAuth2KeyApprovalPrompt, config.Get(OAuth2KeyApprovalPrompt).Str(),
		OAuth2KeyResponseType, config.Get(OAuth2KeyResponseType).Str())

	// set the state
	stateValue, stateErr := state.SignedBase64(common.GetSecurityKey())

	if stateErr != nil {
		return "", stateErr
	}

	params.Set("state", stateValue)

	// generate the query part
	query, queryErr := params.URLQuery()

	if queryErr != nil {
		return "", queryErr
	}

	// put the strings together
	return base + "?" + query, nil
}
开发者ID:jmptrader,项目名称:gomniauth,代码行数:37,代码来源:url.go


示例13: TestOAuth2HandlerBeginAuthURLWithBaseWithoutState

func TestOAuth2HandlerBeginAuthURLWithBaseWithoutState(t *testing.T) {

	common.SetSecurityKey("rAALj6QhRjsTo3VKzfWuK21qNZ5bFfqPJ9sYNerSYeKKoMIPAi9vaIusjmqyLE3S")

	base := "https://base.url/auth"

	config := &common.Config{Map: objx.MSI()}
	config.
		Set("client_id", "client_id").
		Set("redirect_uri", "redirect_uri").
		Set("scope", "scope").
		Set("access_type", "access_type").
		Set("approval_prompt", "approval_prompt")

	url, err := GetBeginAuthURLWithBase(base, nil, config)

	if assert.NoError(t, err) {
		assert.Contains(t, url, "client_id=client_id")
		assert.Contains(t, url, "redirect_uri=redirect_uri")
		assert.Contains(t, url, "scope=scope")
		assert.Contains(t, url, "access_type=access_type")
		assert.Contains(t, url, "approval_prompt=approval_prompt")
		assert.NotContains(t, url, "state=")
	}

}
开发者ID:toggl,项目名称:gomniauth,代码行数:26,代码来源:url_test.go


示例14: TestGetUser

func TestGetUser(t *testing.T) {

	g := New("clientID", "secret", "http://myapp.com/")
	creds := &common.Credentials{Map: objx.MSI()}

	testTripperFactory := new(test.TestTripperFactory)
	testTripper := new(test.TestTripper)
	testTripperFactory.On("NewTripper", mock.Anything, g).Return(testTripper, nil)
	testResponse := new(http.Response)
	testResponse.Header = make(http.Header)
	testResponse.Header.Set("Content-Type", "application/json")
	testResponse.StatusCode = 200
	testResponse.Body = ioutil.NopCloser(strings.NewReader(`{"full_name":"their-name","id":"uniqueid","username":"loginname","avatar_url":"http://myface.com/","online":true}`))
	testTripper.On("RoundTrip", mock.Anything).Return(testResponse, nil)

	g.tripperFactory = testTripperFactory

	user, err := g.GetUser(creds)

	if assert.NoError(t, err) && assert.NotNil(t, user) {
		assert.Equal(t, user.Name(), "their-name")
		assert.Equal(t, user.AuthCode(), "")
		assert.Equal(t, user.Nickname(), "loginname")
		assert.Equal(t, user.Email(), "") // doesn't come from soundcloud
		assert.Equal(t, user.AvatarURL(), "http://myface.com/")
		assert.Equal(t, user.Data()["online"], true)
	}

}
开发者ID:chikin14niwa,项目名称:gomniauth,代码行数:29,代码来源:soundcloud_test.go


示例15: TestMarshalWithCodec_WithFacade

func TestMarshalWithCodec_WithFacade(t *testing.T) {

	// func (s *WebCodecService) MarshalWithCodec(codec codecs.Codec, object interface{}, options ...interface{}) ([]byte, error) {

	testCodec := new(test.TestCodec)
	service := NewWebCodecService()

	// make some test stuff
	var bytesToReturn []byte = []byte("Hello World")
	testObjectWithFacade := new(test.TestObjectWithFacade)
	object := objx.MSI("Name", "Mat")
	var option1 string = "Option One"
	var option2 string = "Option Two"

	args := map[string]interface{}{option1: option1, option2: option2}

	// setup expectations
	testObjectWithFacade.On("PublicData", args).Return(object, nil)
	testCodec.On("Marshal", object, args).Return(bytesToReturn, nil)

	bytes, err := service.MarshalWithCodec(testCodec, testObjectWithFacade, args)

	if assert.Nil(t, err) {
		assert.Equal(t, string(bytesToReturn), string(bytes))
	}

	// assert that our expectations were met
	mock.AssertExpectationsForObjects(t, testCodec.Mock, testObjectWithFacade.Mock)

}
开发者ID:syohex,项目名称:codecs,代码行数:30,代码来源:web_codec_service_test.go


示例16: AowQuote

func AowQuote(ctx context.Context) error {
	index := randInt(len(quotes))
	quote := quotes[index]
	key := ctx.PathParams().Get("apiKey").Str()

	if valid := isKeyValid(key); valid == true {
		return goweb.API.RespondWithData(ctx, objx.MSI("quote", quote))
	}
	return goweb.API.RespondWithError(ctx, 400, "Access Denied: Invalid API Key")
}
开发者ID:darthlukan,项目名称:AOW-Server,代码行数:10,代码来源:controllers.go


示例17: TestOAuth2Provider_CompleteAuth_JSON

func TestOAuth2Provider_CompleteAuth_JSON(t *testing.T) {

	config := &common.Config{
		Map: objx.MSI(
			OAuth2KeyRedirectUrl, OAuth2KeyRedirectUrl,
			OAuth2KeyScope, OAuth2KeyScope,
			OAuth2KeyClientID, OAuth2KeyClientID,
			OAuth2KeySecret, OAuth2KeySecret,
			OAuth2KeyAuthURL, OAuth2KeyAuthURL,
			OAuth2KeyTokenURL, OAuth2KeyTokenURL)}

	testTripperFactory := new(test.TestTripperFactory)
	testTripper := new(test.TestTripper)
	testProvider := new(test.TestProvider)

	creds := new(common.Credentials)

	testResponse := new(http.Response)
	testResponse.Header = make(http.Header)
	testResponse.Header.Set("Content-Type", "application/json")
	testResponse.StatusCode = 200
	testResponse.Body = ioutil.NopCloser(strings.NewReader(`{"expires_in":20,"access_token":"ACCESSTOKEN","refresh_token":"REFRESHTOKEN"}`))

	testTripperFactory.On("NewTripper", common.EmptyCredentials, mock.Anything).Return(testTripper, nil)
	testTripper.On("RoundTrip", mock.Anything).Return(testResponse, nil)

	data := objx.MSI(OAuth2KeyCode, []string{"123"})
	creds, err := CompleteAuth(testTripperFactory, data, config, testProvider)

	if assert.NoError(t, err) {
		if assert.NotNil(t, creds, "Creds should be returned") {

			assert.Equal(t, creds.Get(OAuth2KeyAccessToken).Str(), "ACCESSTOKEN")
			assert.Equal(t, creds.Get(OAuth2KeyRefreshToken).Str(), "REFRESHTOKEN")
			assert.Equal(t, creds.Get(OAuth2KeyExpiresIn).Data().(time.Duration), 20000000000)

		}
	}

	mock.AssertExpectationsForObjects(t, testTripperFactory.Mock, testTripper.Mock, testProvider.Mock)

}
开发者ID:jmptrader,项目名称:gomniauth,代码行数:42,代码来源:complete_auth_test.go


示例18: TestAuthorizationHeader

func TestAuthorizationHeader(t *testing.T) {

	creds := &common.Credentials{Map: objx.MSI()}
	accessTokenVal := "ACCESSTOKEN"
	creds.Set(OAuth2KeyAccessToken, accessTokenVal)
	k, v := AuthorizationHeader(creds)

	assert.Equal(t, k, "Authorization")
	assert.Equal(t, "Bearer "+accessTokenVal, v)

}
开发者ID:amencarini,项目名称:gomniauth,代码行数:11,代码来源:header_test.go


示例19: TestMarshal_mapWithTypes

func TestMarshal_mapWithTypes(t *testing.T) {

	data := map[string]interface{}{"name": "Mat", "age": 30, "yesOrNo": true}
	options := objx.MSI(OptionIncludeTypeAttributes, true)
	bytes, marshalErr := marshal(data, false, 0, options)

	if assert.NoError(t, marshalErr) {
		assert.Equal(t, "<object><name type=\"string\">Mat</name><age type=\"int\">30</age><yesOrNo type=\"bool\">true</yesOrNo></object>", string(bytes), "Output")
	}

}
开发者ID:syohex,项目名称:codecs,代码行数:11,代码来源:simple_xml_codec_test.go


示例20: TestGetUser

func TestGetUser(t *testing.T) {

	g := New("clientID", "secret", "http://myapp.com/")
	creds := &common.Credentials{Map: objx.MSI()}

	testTripperFactory := new(test.TestTripperFactory)
	testTripper := new(test.TestTripper)
	testTripperFactory.On("NewTripper", mock.Anything, g).Return(testTripper, nil)
	testResponse := new(http.Response)
	testResponse.Header = make(http.Header)
	testResponse.Header.Set("Content-Type", "application/json")
	testResponse.StatusCode = 200
	testResponse.Body = ioutil.NopCloser(strings.NewReader(`{
  "id": "631819186",
  "name": "their-name",
  "first_name": "Mat",
  "last_name": "Ryer",
  "link": "https://www.facebook.com/matryer",
  "username": "loginname",
  "bio": "http://www.stretchr.com/",
  "gender": "male",
  "email": "[email protected]",
  "timezone": -6,
  "locale": "en_GB",
  "verified": true,
  "updated_time": "2013-10-03T19:55:28+0000",
  "picture": {
    "url": "http://www.myface.com/"
  }
  }`))
	testTripper.On("RoundTrip", mock.Anything).Return(testResponse, nil)

	g.tripperFactory = testTripperFactory

	user, err := g.GetUser(creds)

	if assert.NoError(t, err) && assert.NotNil(t, user) {

		assert.Equal(t, user.Name(), "their-name")
		assert.Equal(t, user.AuthCode(), "") // doesn't come from github
		assert.Equal(t, user.Nickname(), "loginname")
		assert.Equal(t, user.Email(), "[email protected]")
		assert.Equal(t, user.AvatarURL(), "http://www.myface.com/")
		assert.Equal(t, user.Data()["link"], "https://www.facebook.com/matryer")

		facebookCreds := user.ProviderCredentials()[facebookName]
		if assert.NotNil(t, facebookCreds) {
			assert.Equal(t, "631819186", facebookCreds.Get(common.CredentialsKeyID).Str())
		}

	}

}
开发者ID:toggl,项目名称:gomniauth,代码行数:53,代码来源:facebook_test.go



注:本文中的github.com/stretchr/objx.MSI函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang objx.MustFromBase64函数代码示例发布时间:2022-05-28
下一篇:
Golang graceful.Run函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap