2022-10-26 22:28:11 +00:00
|
|
|
package reddit_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-11-03 17:43:10 +00:00
|
|
|
"go.opentelemetry.io/otel"
|
2022-10-26 22:28:11 +00:00
|
|
|
|
|
|
|
"github.com/christianselig/apollo-backend/internal/reddit"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAuthenticatedClientObfuscatedToken(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2022-11-03 17:43:10 +00:00
|
|
|
tracer := otel.Tracer("test")
|
|
|
|
rc := reddit.NewClient("<SECRET>", "<SECRET>", tracer, nil, nil, 1)
|
2022-10-26 22:28:11 +00:00
|
|
|
|
|
|
|
type test struct {
|
|
|
|
have string
|
|
|
|
want string
|
|
|
|
}
|
|
|
|
|
|
|
|
tests := []test{
|
|
|
|
{"abc", "<SHORT>"},
|
|
|
|
{"abcdefghi", "abc...ghi"},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tests {
|
|
|
|
tc := tc
|
|
|
|
rac := rc.NewAuthenticatedClient("<ID>", "<REFRESH>", tc.have)
|
|
|
|
got := rac.ObfuscatedAccessToken()
|
|
|
|
|
|
|
|
assert.Equal(t, tc.want, got)
|
|
|
|
}
|
|
|
|
}
|