2017-07-31 12:59:32 -04:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
2019-11-29 06:59:40 -05:00
|
|
|
// See LICENSE.txt for license information.
|
2017-07-31 12:59:32 -04:00
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
2019-10-12 05:09:27 -04:00
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2017-07-31 12:59:32 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestUserAccessTokenIsValid(t *testing.T) {
|
|
|
|
|
ad := UserAccessToken{}
|
|
|
|
|
|
2022-08-18 08:53:11 -04:00
|
|
|
appErr := ad.IsValid()
|
|
|
|
|
require.False(t, appErr == nil || appErr.Id != "model.user_access_token.is_valid.id.app_error")
|
2017-07-31 12:59:32 -04:00
|
|
|
|
|
|
|
|
ad.Id = NewRandomString(26)
|
2022-08-18 08:53:11 -04:00
|
|
|
appErr = ad.IsValid()
|
|
|
|
|
require.False(t, appErr == nil || appErr.Id != "model.user_access_token.is_valid.token.app_error")
|
2017-07-31 12:59:32 -04:00
|
|
|
|
|
|
|
|
ad.Token = NewRandomString(26)
|
2022-08-18 08:53:11 -04:00
|
|
|
appErr = ad.IsValid()
|
|
|
|
|
require.False(t, appErr == nil || appErr.Id != "model.user_access_token.is_valid.user_id.app_error")
|
2017-07-31 12:59:32 -04:00
|
|
|
|
|
|
|
|
ad.UserId = NewRandomString(26)
|
2019-10-12 05:09:27 -04:00
|
|
|
require.Nil(t, ad.IsValid())
|
2017-07-31 12:59:32 -04:00
|
|
|
|
|
|
|
|
ad.Description = NewRandomString(256)
|
2022-08-18 08:53:11 -04:00
|
|
|
appErr = ad.IsValid()
|
|
|
|
|
require.False(t, appErr == nil || appErr.Id != "model.user_access_token.is_valid.description.app_error")
|
2017-07-31 12:59:32 -04:00
|
|
|
}
|