<commit_before>package linkedin_test

import (
	"fmt"
	"os"
	"testing"

	"github.com/markbates/goth"
	"github.com/markbates/goth/providers/linkedin"
	"github.com/stretchr/testify/assert"
)

func Test_New(t *testing.T) {
	t.Parallel()
	a := assert.New(t)

	provider := linkedinProvider()
	a.Equal(provider.ClientKey, os.Getenv("LINKEDIN_KEY"))
	a.Equal(provider.Secret, os.Getenv("LINKEDIN_SECRET"))
	a.Equal(provider.CallbackURL, "/foo")
}

func Test_Implements_Provider(t *testing.T) {
	t.Parallel()
	a := assert.New(t)

	a.Implements((*goth.Provider)(nil), linkedinProvider())
}

func Test_BeginAuth(t *testing.T) {
	t.Parallel()
	a := assert.New(t)

	provider := linkedinProvider()
	session, err := provider.BeginAuth("test_state")
	s := session.(*linkedin.Session)
	a.NoError(err)
	a.Contains(s.AuthURL, "linkedin.com/uas/oauth2/authorization")
	a.Contains(s.AuthURL, fmt.Sprintf("client_id=%s", os.Getenv("LINKEDIN_KEY")))
	a.Contains(s.AuthURL, "state=test_state")
	a.Contains(s.AuthURL, "scope=r_basicprofile+r_emailaddress&state")
}

func Test_SessionFromJSON(t *testing.T) {
	t.Parallel()
	a := assert.New(t)

	provider := linkedinProvider()

	s, err := provider.UnmarshalSession(`{"AuthURL":"http://linkedin.com/auth_url","AccessToken":"1234567890"}`)
	a.NoError(err)
	session := s.(*linkedin.Session)
	a.Equal(session.AuthURL, "http://linkedin.com/auth_url")
	a.Equal(session.AccessToken, "<PASSWORD>")
}

func linkedinProvider() *linkedin.Provider {
	return linkedin.New(os.Getenv("LINKEDIN_KEY"), os.Getenv("LINKEDIN_SECRET"), "/foo", "r_basicprofile", "r_emailaddress")
}<commit_msg>Missed auth URL check in linkedin_test.go<commit_after>package linkedin_test

import (
	"fmt"
	"os"
	"testing"

	"github.com/markbates/goth"
	"github.com/markbates/goth/providers/linkedin"
	"github.com/stretchr/testify/assert"
)

func Test_New(t *testing.T) {
	t.Parallel()
	a := assert.New(t)

	provider := linkedinProvider()
	a.Equal(provider.ClientKey, os.Getenv("LINKEDIN_KEY"))
	a.Equal(provider.Secret, os.Getenv("LINKEDIN_SECRET"))
	a.Equal(provider.CallbackURL, "/foo")
}

func Test_Implements_Provider(t *testing.T) {
	t.Parallel()
	a := assert.New(t)

	a.Implements((*goth.Provider)(nil), linkedinProvider())
}

func Test_BeginAuth(t *testing.T) {
	t.Parallel()
	a := assert.New(t)

	provider := linkedinProvider()
	session, err := provider.BeginAuth("test_state")
	s := session.(*linkedin.Session)
	a.NoError(err)
	a.Contains(s.AuthURL, "linkedin.com/oauth/v2/authorization")
	a.Contains(s.AuthURL, fmt.Sprintf("client_id=%s", os.Getenv("LINKEDIN_KEY")))
	a.Contains(s.AuthURL, "state=test_state")
	a.Contains(s.AuthURL, "scope=r_basicprofile+r_emailaddress&state")
}

func Test_SessionFromJSON(t *testing.T) {
	t.Parallel()
	a := assert.New(t)

	provider := linkedinProvider()

	s, err := provider.UnmarshalSession(`{"AuthURL":"http://linkedin.com/auth_url","AccessToken":"<PASSWORD>"}`)
	a.NoError(err)
	session := s.(*linkedin.Session)
	a.Equal(session.AuthURL, "http://linkedin.com/auth_url")
	a.Equal(session.AccessToken, "<PASSWORD>")
}

func linkedinProvider() *linkedin.Provider {
	return linkedin.New(os.Getenv("LINKEDIN_KEY"), os.Getenv("LINKEDIN_SECRET"), "/foo", "r_basicprofile", "r_emailaddress")
}
{'fraction_non_alphanumeric': 0.18043478260869567, 'fraction_numerical': 0.0037267080745341614, 'mean_word_length': 6.11037527593819, 'pattern_counts': {'":': 4, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3611379', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1250, 'n_words': 167}