Skip to content

Commit

Permalink
test(e2e): auth login
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed Dec 23, 2024
1 parent 61ba0d2 commit 96846c5
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions e2e/server/auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package e2e

import (
"bytes"
"net/http"
"testing"

"github.com/go-shiori/shiori/e2e/e2eutil"
"github.com/stretchr/testify/require"
)

func TestAuthLogin(t *testing.T) {
container := e2eutil.NewShioriContainer(t, "")

t.Run("login ok", func(t *testing.T) {
req, err := http.Post(
"http://localhost:"+container.GetPort()+"/api/v/auth/login",
"application/json",
bytes.NewReader([]byte(`{"username": "shiori", "password": "gopher"}`)),
)
require.NoError(t, err)
require.Equal(t, http.StatusOK, req.StatusCode)
})

t.Run("wrong credentials", func(t *testing.T) {
req, err := http.Post(
"http://localhost:"+container.GetPort()+"/api/v/auth/login",
"application/json",
bytes.NewReader([]byte(`{"username": "wrong", "password": "wrong"}`)),
)
require.NoError(t, err)
require.Equal(t, http.StatusUnauthorized, req.StatusCode)
})
}

0 comments on commit 96846c5

Please sign in to comment.