Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Dec 9, 2019
1 parent cb22ae9 commit 0f73b19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
22 changes: 9 additions & 13 deletions internal/orchestra/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (

// Config contains configs for logging in with the OONI orchestra.
type Config struct {
BaseURL string
ClientID string
HTTPClient *http.Client
Logger log.Logger
Password string
UserAgent string
BaseURL string
Credentials Credentials
HTTPClient *http.Client
Logger log.Logger
UserAgent string
}

type request struct {
Username string `json:"username"`
// Credentials contains the login credentials
type Credentials struct {
ClientID string `json:"username"`
Password string `json:"password"`
}

Expand All @@ -33,17 +33,13 @@ type Auth struct {

// Do logs this probe in with OONI orchestra
func Do(ctx context.Context, config Config) (*Auth, error) {
req := &request{
Password: config.Password,
Username: config.ClientID,
}
var resp Auth
err := (&jsonapi.Client{
BaseURL: config.BaseURL,
HTTPClient: config.HTTPClient,
Logger: config.Logger,
UserAgent: config.UserAgent,
}).Create(ctx, "/api/v1/login", req, &resp)
}).Create(ctx, "/api/v1/login", config.Credentials, &resp)
if err != nil {
return nil, err
}
Expand Down
8 changes: 5 additions & 3 deletions internal/orchestra/testorchestra/testorchestra.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ func Register() (string, error) {
// information on success, and an error on failure.
func Login(clientID string) (*login.Auth, error) {
return login.Do(context.Background(), login.Config{
BaseURL: "https://ps-test.ooni.io",
ClientID: clientID,
BaseURL: "https://ps-test.ooni.io",
Credentials: login.Credentials{
ClientID: clientID,
Password: password,
},
HTTPClient: http.DefaultClient,
Logger: log.Log,
Password: password,
UserAgent: "miniooni/0.1.0-dev",
})
}
Expand Down

0 comments on commit 0f73b19

Please sign in to comment.