...

Source file src/github.com/ory/fosite/client_test.go

Documentation: github.com/ory/fosite

     1  /*
     2   * Copyright © 2015-2018 Aeneas Rekkas <aeneas+oss@aeneas.io>
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   *
    16   * @author		Aeneas Rekkas <aeneas+oss@aeneas.io>
    17   * @copyright 	2015-2018 Aeneas Rekkas <aeneas+oss@aeneas.io>
    18   * @license 	Apache-2.0
    19   *
    20   */
    21  
    22  package fosite
    23  
    24  import (
    25  	"testing"
    26  
    27  	"github.com/stretchr/testify/assert"
    28  )
    29  
    30  func TestDefaultClient(t *testing.T) {
    31  	sc := &DefaultClient{
    32  		ID:             "1",
    33  		Secret:         []byte("foobar-"),
    34  		RotatedSecrets: [][]byte{[]byte("foobar-1"), []byte("foobar-2")},
    35  		RedirectURIs:   []string{"foo", "bar"},
    36  		ResponseTypes:  []string{"foo", "bar"},
    37  		GrantTypes:     []string{"foo", "bar"},
    38  		Scopes:         []string{"fooscope"},
    39  	}
    40  
    41  	assert.Equal(t, sc.ID, sc.GetID())
    42  	assert.Equal(t, sc.RedirectURIs, sc.GetRedirectURIs())
    43  	assert.Equal(t, sc.Secret, sc.GetHashedSecret())
    44  	assert.Equal(t, sc.RotatedSecrets, sc.GetRotatedHashes())
    45  	assert.EqualValues(t, sc.ResponseTypes, sc.GetResponseTypes())
    46  	assert.EqualValues(t, sc.GrantTypes, sc.GetGrantTypes())
    47  	assert.EqualValues(t, sc.Scopes, sc.GetScopes())
    48  
    49  	sc.GrantTypes = []string{}
    50  	sc.ResponseTypes = []string{}
    51  	assert.Equal(t, "code", sc.GetResponseTypes()[0])
    52  	assert.Equal(t, "authorization_code", sc.GetGrantTypes()[0])
    53  
    54  	var _ ClientWithSecretRotation = sc
    55  }
    56  
    57  func TestDefaultResponseModeClient_GetResponseMode(t *testing.T) {
    58  	rc := &DefaultResponseModeClient{ResponseModes: []ResponseModeType{ResponseModeFragment}}
    59  	assert.Equal(t, []ResponseModeType{ResponseModeFragment}, rc.GetResponseModes())
    60  }
    61  

View as plain text