コード例 #1
0
func TestNewOAuth2Tripper(t *testing.T) {

	testProvider := new(test.TestProvider)
	creds := &common.Credentials{Map: objx.MSI()}
	var tripper common.Tripper = NewOAuth2Tripper(creds, testProvider)

	if assert.NotNil(t, tripper) {
		assert.Equal(t, creds, tripper.Credentials())
		assert.Equal(t, http.DefaultTransport, tripper.(*OAuth2Tripper).underlyingTransport)
		assert.Equal(t, testProvider, tripper.Provider())
	}

}
コード例 #2
0
func TestOAuth2TripperFactoryNewTripper(t *testing.T) {

	testProvider := new(test.TestProvider)

	creds := new(common.Credentials)
	var tripperFactory common.TripperFactory
	tripperFactory = new(OAuth2TripperFactory)

	assert.NotNil(t, tripperFactory)

	var tripper common.Tripper
	tripper, err := tripperFactory.NewTripper(creds, testProvider)

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

		assert.Equal(t, creds, tripper.Credentials())
		assert.IsType(t, new(OAuth2Tripper), tripper, "OAuth2TripperFactory should make OAuth2Trippers")

	}

	mock.AssertExpectationsForObjects(t, testProvider.Mock)

}