diff --git a/api/client.go b/api/client.go index 46d5093..22610a1 100644 --- a/api/client.go +++ b/api/client.go @@ -21,10 +21,10 @@ func NewClient(url, nonce, session, apiKey string) *Client { return &Client{ sub: &http.Client{ Jar: jar, - // Don't follow redirections - CheckRedirect: func(_ *http.Request, _ []*http.Request) error { - return http.ErrUseLastResponse - }, + // // Don't follow redirections + // CheckRedirect: func(_ *http.Request, _ []*http.Request) error { + // return http.ErrUseLastResponse + // }, }, url: url, nonce: nonce, diff --git a/api/login.go b/api/login.go index 411e8a5..84b795c 100644 --- a/api/login.go +++ b/api/login.go @@ -5,8 +5,6 @@ import ( "fmt" "net/http" "net/url" - - "github.com/pkg/errors" ) type LoginParams struct { @@ -45,12 +43,5 @@ func (client *Client) Login(params *LoginParams, opts ...Option) error { return err } client.nonce = nonce - - for _, cookie := range res.Cookies() { - if cookie.Name == "session" { - client.session = cookie.Value - return nil - } - } - return errors.New("session cookie not found") + return nil } diff --git a/api/setup_test.go b/api/setup_test.go index 98613a7..36fbe15 100644 --- a/api/setup_test.go +++ b/api/setup_test.go @@ -75,6 +75,21 @@ func Test_F_Setup(t *testing.T) { } client.SetAPIKey(*token.Value) + // 1d. Logout because we don't know what could happen with a mouse on the UI + err = client.Logout() + if !assert.Nil(err, "got error: %s", err) { + return + } + + // 1e. Relog :) + err = client.Login(&api.LoginParams{ + Name: "ctfer", + Password: "password", + }) + if !assert.Nil(err, "got error: %s", err) { + return + } + // 2. Create a challenge chall, err := client.PostChallenges(&api.PostChallengesParams{ Name: "Stealing data",