From a1fecafd4e054901f7c31275d5602b4144b6b17f Mon Sep 17 00:00:00 2001 From: Donatas Kucinskas Date: Mon, 22 Jan 2018 11:31:20 +0200 Subject: [PATCH] Change "password" term with "passphrase" to unify naming --- cmd/mysterium_client/cli/command.go | 6 +++--- identity/manager.go | 2 +- tequilapi/client/client.go | 6 +++--- tequilapi/endpoints/identities.go | 8 ++++---- tequilapi/endpoints/identities_test.go | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cmd/mysterium_client/cli/command.go b/cmd/mysterium_client/cli/command.go index a7312836b..df27ea3db 100644 --- a/cmd/mysterium_client/cli/command.go +++ b/cmd/mysterium_client/cli/command.go @@ -33,7 +33,7 @@ type Command struct { } const redColor = "\033[31m%s\033[0m" -const identityDefaultPassword = "" +const identityDefaultPassphrase = "" // Run starts CLI interface func (c *Command) Run() (err error) { @@ -126,7 +126,7 @@ func (c *Command) connect(line string) { consumerId, providerId := identities[0], identities[1] if consumerId == "new" { - id, err := c.tequilapi.NewIdentity(identityDefaultPassword) + id, err := c.tequilapi.NewIdentity(identityDefaultPassphrase) if err != nil { warn(err) return @@ -232,7 +232,7 @@ func (c *Command) identities(line string) { } if action == "new" { - id, err := c.tequilapi.NewIdentity(identityDefaultPassword) + id, err := c.tequilapi.NewIdentity(identityDefaultPassphrase) if err != nil { warn(err) return diff --git a/identity/manager.go b/identity/manager.go index 74e546237..b46c91c12 100644 --- a/identity/manager.go +++ b/identity/manager.go @@ -1,5 +1,5 @@ // Maps Ethereum account to dto.Identity. -// Currently creates a new eth account with password on CreateNewIdentity(). +// Currently creates a new eth account with passphrase on CreateNewIdentity(). package identity diff --git a/tequilapi/client/client.go b/tequilapi/client/client.go index 5b960ba5e..160af5936 100644 --- a/tequilapi/client/client.go +++ b/tequilapi/client/client.go @@ -36,11 +36,11 @@ func (client *Client) GetIdentities() (ids []IdentityDto, err error) { } // NewIdentity creates a new client identity -func (client *Client) NewIdentity(password string) (id IdentityDto, err error) { +func (client *Client) NewIdentity(passphrase string) (id IdentityDto, err error) { payload := struct { - Password string `json:"password"` + Passphrase string `json:"passphrase"` }{ - password, + passphrase, } response, err := client.http.Post("identities", payload) if err != nil { diff --git a/tequilapi/endpoints/identities.go b/tequilapi/endpoints/identities.go index 87289b7da..ed0cb149a 100644 --- a/tequilapi/endpoints/identities.go +++ b/tequilapi/endpoints/identities.go @@ -21,7 +21,7 @@ type identityList struct { } type identityCreationDto struct { - Password *string `json:"password"` + Passphrase *string `json:"passphrase"` } type identityRegistrationDto struct { @@ -73,7 +73,7 @@ func (endpoint *identitiesApi) Create(resp http.ResponseWriter, request *http.Re utils.SendValidationErrorMessage(resp, errorMap) return } - id, err := endpoint.idm.CreateNewIdentity(*createReq.Password) + id, err := endpoint.idm.CreateNewIdentity(*createReq.Passphrase) if err != nil { utils.SendError(resp, err, http.StatusInternalServerError) return @@ -151,8 +151,8 @@ func validateRegistrationRequest(regReq identityRegistrationDto) (err error) { func validateCreationRequest(createReq *identityCreationDto) (errors *validation.FieldErrorMap) { errors = validation.NewErrorMap() - if createReq.Password == nil { - errors.ForField("password").AddError("required", "Field is required") + if createReq.Passphrase == nil { + errors.ForField("passphrase").AddError("required", "Field is required") } return } diff --git a/tequilapi/endpoints/identities_test.go b/tequilapi/endpoints/identities_test.go index d83169b10..2adc558ee 100644 --- a/tequilapi/endpoints/identities_test.go +++ b/tequilapi/endpoints/identities_test.go @@ -122,12 +122,12 @@ func TestUnlockFailure(t *testing.T) { assert.Equal(t, "mypassphrase", mockIdm.LastUnlockPassphrase) } -func TestCreateNewIdentityEmptyPassword(t *testing.T) { +func TestCreateNewIdentityEmptyPassphrase(t *testing.T) { mockIdm := identity.NewIdentityManagerFake(existingIdentities, newIdentity) req, err := http.NewRequest( http.MethodPost, "/identities", - bytes.NewBufferString(`{"password": ""}`), + bytes.NewBufferString(`{"passphrase": ""}`), ) assert.Nil(t, err) @@ -139,7 +139,7 @@ func TestCreateNewIdentityEmptyPassword(t *testing.T) { assert.Equal(t, http.StatusOK, resp.Code) } -func TestCreateNewIdentityNoPassword(t *testing.T) { +func TestCreateNewIdentityNoPassphrase(t *testing.T) { mockIdm := identity.NewIdentityManagerFake(existingIdentities, newIdentity) req, err := http.NewRequest( http.MethodPost, @@ -159,7 +159,7 @@ func TestCreateNewIdentityNoPassword(t *testing.T) { `{ "message": "validation_error", "errors" : { - "password": [ {"code" : "required" , "message" : "Field is required" } ] + "passphrase": [ {"code" : "required" , "message" : "Field is required" } ] } }`, resp.Body.String(), @@ -171,7 +171,7 @@ func TestCreateNewIdentity(t *testing.T) { req, err := http.NewRequest( http.MethodPost, "/identities", - bytes.NewBufferString(`{"password": "mypass"}`), + bytes.NewBufferString(`{"passphrase": "mypass"}`), ) assert.Nil(t, err)