Migrate tests from 'app/oauth_test.go' to use testify (#12155)
Этот коммит содержится в:
коммит произвёл
Ben Schumacher
родитель
69eb2faf3d
Коммит
fa6b98df3c
@@ -69,9 +69,8 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
if err := th.App.RevokeAccessToken(model.NewRandomString(16)); err == nil {
|
||||
t.Fatal("Should have failed bad token")
|
||||
}
|
||||
err := th.App.RevokeAccessToken(model.NewRandomString(16))
|
||||
require.NotNil(t, err, "Should have failed bad token")
|
||||
|
||||
session := &model.Session{}
|
||||
session.CreateAt = model.GetMillis()
|
||||
@@ -81,9 +80,8 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
session.SetExpireInDays(1)
|
||||
|
||||
session, _ = th.App.CreateSession(session)
|
||||
if err := th.App.RevokeAccessToken(session.Token); err == nil {
|
||||
t.Fatal("Should have failed does not have an access token")
|
||||
}
|
||||
err = th.App.RevokeAccessToken(session.Token)
|
||||
require.NotNil(t, err, "Should have failed does not have an access token")
|
||||
|
||||
accessData := &model.AccessData{}
|
||||
accessData.Token = session.Token
|
||||
@@ -92,12 +90,11 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
accessData.ClientId = model.NewId()
|
||||
accessData.ExpiresAt = session.ExpiresAt
|
||||
|
||||
_, err := th.App.Srv.Store.OAuth().SaveAccessData(accessData)
|
||||
_, err = th.App.Srv.Store.OAuth().SaveAccessData(accessData)
|
||||
require.Nil(t, err)
|
||||
|
||||
if err = th.App.RevokeAccessToken(accessData.Token); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = th.App.RevokeAccessToken(accessData.Token)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestOAuthDeleteApp(t *testing.T) {
|
||||
@@ -114,9 +111,7 @@ func TestOAuthDeleteApp(t *testing.T) {
|
||||
|
||||
var err *model.AppError
|
||||
a1, err = th.App.CreateOAuthApp(a1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Nil(t, err)
|
||||
|
||||
session := &model.Session{}
|
||||
session.CreateAt = model.GetMillis()
|
||||
@@ -138,13 +133,11 @@ func TestOAuthDeleteApp(t *testing.T) {
|
||||
_, err = th.App.Srv.Store.OAuth().SaveAccessData(accessData)
|
||||
require.Nil(t, err)
|
||||
|
||||
if err = th.App.DeleteOAuthApp(a1.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = th.App.DeleteOAuthApp(a1.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err = th.App.GetSession(session.Token); err == nil {
|
||||
t.Fatal("should not get session from cache or db")
|
||||
}
|
||||
_, err = th.App.GetSession(session.Token)
|
||||
require.NotNil(t, err, "should not get session from cache or db")
|
||||
}
|
||||
|
||||
func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user