...

Source file src/github.com/okta/okta-sdk-golang/v2/tests/unit/user_agent_test.go

Documentation: github.com/okta/okta-sdk-golang/v2/tests/unit

     1  /*
     2   * Copyright 2018 - Present Okta, Inc.
     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  
    17  package unit
    18  
    19  import (
    20  	"context"
    21  	"runtime"
    22  	"testing"
    23  
    24  	"github.com/stretchr/testify/require"
    25  
    26  	"github.com/okta/okta-sdk-golang/v2/okta"
    27  	"github.com/okta/okta-sdk-golang/v2/tests"
    28  )
    29  
    30  func TestUserAgent(t *testing.T) {
    31  	_, client, _ := tests.NewClient(context.TODO(), okta.WithOrgUrl("https://example.com"))
    32  	agent := okta.NewUserAgent(client.GetConfig())
    33  	userAgent := "okta-sdk-golang/" + okta.Version + " golang/" + runtime.Version() + " " + runtime.GOOS + "/" + runtime.GOARCH
    34  	require.Equal(t, userAgent, agent.String())
    35  }
    36  
    37  func TestUserAgentWithExtra(t *testing.T) {
    38  	_, client, _ := tests.NewClient(context.TODO(),
    39  		okta.WithOrgUrl("https://example.com"),
    40  		okta.WithUserAgentExtra("extra"),
    41  	)
    42  	agent := okta.NewUserAgent(client.GetConfig())
    43  	userAgent := "okta-sdk-golang/" + okta.Version + " golang/" + runtime.Version() + " " + runtime.GOOS + "/" + runtime.GOARCH + " extra"
    44  	require.Equal(t, userAgent, agent.String())
    45  }
    46  

View as plain text