🚚 Renamed NewClientID to ParseClientID
This commit is contained in:
parent
2cc1fa02e7
commit
c31d47d5ae
|
@ -26,7 +26,7 @@ var (
|
|||
)
|
||||
|
||||
//nolint: funlen
|
||||
func NewClientID(raw string) (*ClientID, error) {
|
||||
func ParseClientID(raw string) (*ClientID, error) {
|
||||
clientID := http.AcquireURI()
|
||||
if err := clientID.Parse(nil, []byte(raw)); err != nil {
|
||||
return nil, Error{
|
||||
|
@ -113,7 +113,7 @@ func NewClientID(raw string) (*ClientID, error) {
|
|||
func TestClientID(tb testing.TB) *ClientID {
|
||||
tb.Helper()
|
||||
|
||||
clientID, err := NewClientID("https://app.example.com/")
|
||||
clientID, err := ParseClientID("https://app.example.com/")
|
||||
require.NoError(tb, err)
|
||||
|
||||
return clientID
|
||||
|
@ -121,7 +121,7 @@ func TestClientID(tb testing.TB) *ClientID {
|
|||
|
||||
// UnmarshalForm implements a custom form.Unmarshaler.
|
||||
func (cid *ClientID) UnmarshalForm(v []byte) error {
|
||||
clientID, err := NewClientID(string(v))
|
||||
clientID, err := ParseClientID(string(v))
|
||||
if err != nil {
|
||||
return fmt.Errorf("UnmarshalForm: %w", err)
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ func (cid *ClientID) UnmarshalJSON(v []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
clientID, err := NewClientID(src)
|
||||
clientID, err := ParseClientID(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("UnmarshalJSON: %w", err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
//nolint: funlen
|
||||
func TestNewClientID(t *testing.T) {
|
||||
func TestParseClientID(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, testCase := range []struct {
|
||||
|
@ -67,7 +67,7 @@ func TestNewClientID(t *testing.T) {
|
|||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
result, err := domain.NewClientID(testCase.input)
|
||||
result, err := domain.ParseClientID(testCase.input)
|
||||
if testCase.isValid {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, testCase.input, result.String())
|
||||
|
|
|
@ -126,7 +126,7 @@ func NewSession(src *domain.Session) *Session {
|
|||
}
|
||||
|
||||
func (t *Session) Populate(dst *domain.Session) {
|
||||
dst.ClientID, _ = domain.NewClientID(t.ClientID)
|
||||
dst.ClientID, _ = domain.ParseClientID(t.ClientID)
|
||||
dst.Code = t.Code
|
||||
dst.CodeChallenge = t.CodeChallenge
|
||||
dst.CodeChallengeMethod, _ = domain.ParseCodeChallengeMethod(t.CodeChallengeMethod)
|
||||
|
|
|
@ -90,7 +90,7 @@ func NewToken(src *domain.Token) *Token {
|
|||
|
||||
func (t *Token) Populate(dst *domain.Token) {
|
||||
dst.AccessToken = t.AccessToken
|
||||
dst.ClientID, _ = domain.NewClientID(t.ClientID)
|
||||
dst.ClientID, _ = domain.ParseClientID(t.ClientID)
|
||||
dst.Me, _ = domain.NewMe(t.Me)
|
||||
dst.Scope = make(domain.Scopes, 0)
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ func (useCase *tokenUseCase) Verify(ctx context.Context, accessToken string) (*d
|
|||
result := &domain.Token{
|
||||
AccessToken: accessToken,
|
||||
}
|
||||
result.ClientID, _ = domain.NewClientID(t.Issuer())
|
||||
result.ClientID, _ = domain.ParseClientID(t.Issuer())
|
||||
result.Me, _ = domain.NewMe(t.Subject())
|
||||
|
||||
if scope, ok := t.Get("scope"); ok {
|
||||
|
|
Loading…
Reference in New Issue