diff --git a/e2e/server/auth_test.go b/e2e/server/auth_test.go new file mode 100644 index 000000000..ff93a9f8b --- /dev/null +++ b/e2e/server/auth_test.go @@ -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) + }) +}