Repository: ory/kratos
Pull request #597 (2020-07-24 09:00:43)

refactor: rename verify to verificaiton
## Related issue

<!--
Please link the GitHub issue this pull request resolves in the format of `#1234`. If you discussed this change
with a maintainer, please mention her/him using the `@` syntax (e.g. `@aeneasr`).

If this change neither resolves an existing issue nor has sign-off from one of the maintainers, there is a
chance substantial changes will be requested or that the changes will be rejected.

You can discuss changes with maintainers either in the [ORY Community Forums](https://community.ory.sh/) or
join the [ORY Chat](https://www.ory.sh/chat).
-->

## Proposed changes

<!--
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
-->

## Checklist

<!--
Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of
them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
-->

- [ ] I have read the [contributing guidelines](../blob/master/CONTRIBUTING.md).
- [ ] I have read the [security policy](../security/policy).
- [ ] I confirm that this pull request does not address a security
      vulnerability. If this pull request addresses a security. vulnerability, I
      confirm that I got green light (please contact
      [security@ory.sh](mailto:security@ory.sh)) from the maintainers to push
      the changes.
- [ ] I have added tests that prove my fix is effective or that my feature
      works.
- [ ] I have added or changed [the documentation](docs/docs).

## Further comments

<!--
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution
you did and what alternatives you considered, etc...
-->



Patch:
diff --git a/cmd/daemon/serve.go b/cmd/daemon/serve.go
index 5a3997f23..2b493f0ca 100644
--- a/cmd/daemon/serve.go
+++ b/cmd/daemon/serve.go
@@ -24,7 +24,7 @@ import (
 	"github.com/ory/kratos/selfservice/flow/logout"
 	"github.com/ory/kratos/selfservice/flow/registration"
 	"github.com/ory/kratos/selfservice/flow/settings"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 	"github.com/ory/kratos/selfservice/strategy/oidc"
 	"github.com/ory/kratos/selfservice/strategy/password"
 	"github.com/ory/kratos/selfservice/strategy/profile"
@@ -131,10 +131,10 @@ func sqa(cmd *cobra.Command, d driver.Driver) *metricsx.Service {
 				settings.PublicPath,
 				settings.PublicRequestPath,
 				profile.PublicSettingsProfilePath,
-				verify.PublicVerificationCompletePath,
-				strings.ReplaceAll(strings.ReplaceAll(verify.PublicVerificationConfirmPath, ":via", "email"), ":code", ""),
-				strings.ReplaceAll(verify.PublicVerificationInitPath, ":via", "email"),
-				verify.PublicVerificationRequestPath,
+				verification.PublicVerificationCompletePath,
+				strings.ReplaceAll(strings.ReplaceAll(verification.PublicVerificationConfirmPath, ":via", "email"), ":code", ""),
+				strings.ReplaceAll(verification.PublicVerificationInitPath, ":via", "email"),
+				verification.PublicVerificationRequestPath,
 				errorx.ErrorsPath,
 			},
 			BuildVersion: d.Registry().BuildVersion(),
diff --git a/driver/registry.go b/driver/registry.go
index 785c21528..d132b477f 100644
--- a/driver/registry.go
+++ b/driver/registry.go
@@ -12,7 +12,7 @@ import (
 	"github.com/ory/kratos/schema"
 	"github.com/ory/kratos/selfservice/flow/recovery"
 	"github.com/ory/kratos/selfservice/flow/settings"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 
 	"github.com/ory/x/healthx"
 
@@ -108,10 +108,10 @@ type Registry interface {
 	registration.HandlerProvider
 	registration.StrategyProvider
 
-	verify.PersistenceProvider
-	verify.ErrorHandlerProvider
-	verify.SenderProvider
-	verify.HandlerProvider
+	verification.PersistenceProvider
+	verification.ErrorHandlerProvider
+	verification.SenderProvider
+	verification.HandlerProvider
 
 	recovery.RequestPersistenceProvider
 	recovery.ErrorHandlerProvider
diff --git a/driver/registry_default.go b/driver/registry_default.go
index 15c94f01f..83504e00b 100644
--- a/driver/registry_default.go
+++ b/driver/registry_default.go
@@ -13,7 +13,7 @@ import (
 	"github.com/ory/kratos/schema"
 	"github.com/ory/kratos/selfservice/flow/recovery"
 	"github.com/ory/kratos/selfservice/flow/settings"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 	"github.com/ory/kratos/selfservice/hook"
 	"github.com/ory/kratos/selfservice/strategy/profile"
 	"github.com/ory/kratos/selfservice/strategy/recoverytoken"
@@ -106,10 +106,10 @@ type RegistryDefault struct {
 	selfserviceSettingsErrorHandler *settings.ErrorHandler
 	selfserviceSettingsExecutor     *settings.HookExecutor
 
-	selfserviceVerifyErrorHandler *verify.ErrorHandler
+	selfserviceVerifyErrorHandler *verification.ErrorHandler
 	selfserviceVerifyManager      *identity.Manager
-	selfserviceVerifyHandler      *verify.Handler
-	selfserviceVerifySender       *verify.Sender
+	selfserviceVerifyHandler      *verification.Handler
+	selfserviceVerifySender       *verification.Sender
 
 	selfserviceRecoveryErrorHandler *recovery.ErrorHandler
 	selfserviceRecoveryHandler      *recovery.Handler
diff --git a/driver/registry_default_verify.go b/driver/registry_default_verify.go
index 831b81d10..3a367de94 100644
--- a/driver/registry_default_verify.go
+++ b/driver/registry_default_verify.go
@@ -2,16 +2,16 @@ package driver
 
 import (
 	"github.com/ory/kratos/identity"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 )
 
-func (m *RegistryDefault) VerificationPersister() verify.Persister {
+func (m *RegistryDefault) VerificationPersister() verification.Persister {
 	return m.persister
 }
 
-func (m *RegistryDefault) VerificationRequestErrorHandler() *verify.ErrorHandler {
+func (m *RegistryDefault) VerificationRequestErrorHandler() *verification.ErrorHandler {
 	if m.selfserviceVerifyErrorHandler == nil {
-		m.selfserviceVerifyErrorHandler = verify.NewErrorHandler(m, m.c)
+		m.selfserviceVerifyErrorHandler = verification.NewErrorHandler(m, m.c)
 	}
 
 	return m.selfserviceVerifyErrorHandler
@@ -25,17 +25,17 @@ func (m *RegistryDefault) VerificationManager() *identity.Manager {
 	return m.selfserviceVerifyManager
 }
 
-func (m *RegistryDefault) VerificationHandler() *verify.Handler {
+func (m *RegistryDefault) VerificationHandler() *verification.Handler {
 	if m.selfserviceVerifyHandler == nil {
-		m.selfserviceVerifyHandler = verify.NewHandler(m, m.c)
+		m.selfserviceVerifyHandler = verification.NewHandler(m, m.c)
 	}
 
 	return m.selfserviceVerifyHandler
 }
 
-func (m *RegistryDefault) VerificationSender() *verify.Sender {
+func (m *RegistryDefault) VerificationSender() *verification.Sender {
 	if m.selfserviceVerifySender == nil {
-		m.selfserviceVerifySender = verify.NewSender(m, m.c)
+		m.selfserviceVerifySender = verification.NewSender(m, m.c)
 	}
 
 	return m.selfserviceVerifySender
diff --git a/persistence/reference.go b/persistence/reference.go
index 10962bbd9..1c4695799 100644
--- a/persistence/reference.go
+++ b/persistence/reference.go
@@ -14,7 +14,7 @@ import (
 	"github.com/ory/kratos/selfservice/flow/recovery"
 	"github.com/ory/kratos/selfservice/flow/registration"
 	"github.com/ory/kratos/selfservice/flow/settings"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 	"github.com/ory/kratos/selfservice/strategy/recoverytoken"
 	"github.com/ory/kratos/session"
 )
@@ -32,7 +32,7 @@ type Persister interface {
 	courier.Persister
 	session.Persister
 	errorx.Persister
-	verify.Persister
+	verification.Persister
 	recovery.RequestPersister
 	recoverytoken.Persister
 
diff --git a/persistence/sql/persister_verify.go b/persistence/sql/persister_verify.go
index e294954e9..3def71b0e 100644
--- a/persistence/sql/persister_verify.go
+++ b/persistence/sql/persister_verify.go
@@ -7,25 +7,25 @@ import (
 
 	"github.com/ory/x/sqlcon"
 
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 )
 
-var _ verify.Persister = new(Persister)
+var _ verification.Persister = new(Persister)
 
-func (p Persister) CreateVerificationRequest(ctx context.Context, r *verify.Request) error {
+func (p Persister) CreateVerificationRequest(ctx context.Context, r *verification.Request) error {
 	// This should not create the request eagerly because otherwise we might accidentally create an address
 	// that isn't supposed to be in the database.
 	return p.GetConnection(ctx).Create(r)
 }
 
-func (p Persister) GetVerificationRequest(ctx context.Context, id uuid.UUID) (*verify.Request, error) {
-	var r verify.Request
+func (p Persister) GetVerificationRequest(ctx context.Context, id uuid.UUID) (*verification.Request, error) {
+	var r verification.Request
 	if err := p.GetConnection(ctx).Find(&r, id); err != nil {
 		return nil, sqlcon.HandleError(err)
 	}
 	return &r, nil
 }
 
-func (p Persister) UpdateVerificationRequest(ctx context.Context, r *verify.Request) error {
+func (p Persister) UpdateVerificationRequest(ctx context.Context, r *verification.Request) error {
 	return sqlcon.HandleError(p.GetConnection(ctx).Update(r))
 }
diff --git a/selfservice/flow/verify/error.go b/selfservice/flow/verification/error.go
similarity index 99%
rename from selfservice/flow/verify/error.go
rename to selfservice/flow/verification/error.go
index d7d35e0cc..76c516430 100644
--- a/selfservice/flow/verify/error.go
+++ b/selfservice/flow/verification/error.go
@@ -1,4 +1,4 @@
-package verify
+package verification
 
 import (
 	"net/http"
diff --git a/selfservice/flow/verify/handler.go b/selfservice/flow/verification/handler.go
similarity index 99%
rename from selfservice/flow/verify/handler.go
rename to selfservice/flow/verification/handler.go
index 1439c3104..0de202dd9 100644
--- a/selfservice/flow/verify/handler.go
+++ b/selfservice/flow/verification/handler.go
@@ -1,4 +1,4 @@
-package verify
+package verification
 
 import (
 	"net/http"
diff --git a/selfservice/flow/verify/persistence.go b/selfservice/flow/verification/persistence.go
similarity index 99%
rename from selfservice/flow/verify/persistence.go
rename to selfservice/flow/verification/persistence.go
index 3851b2de7..26dbd8d23 100644
--- a/selfservice/flow/verify/persistence.go
+++ b/selfservice/flow/verification/persistence.go
@@ -1,4 +1,4 @@
-package verify
+package verification
 
 import (
 	"context"
diff --git a/selfservice/flow/verify/request.go b/selfservice/flow/verification/request.go
similarity index 99%
rename from selfservice/flow/verify/request.go
rename to selfservice/flow/verification/request.go
index ed177b681..060c3704a 100644
--- a/selfservice/flow/verify/request.go
+++ b/selfservice/flow/verification/request.go
@@ -1,4 +1,4 @@
-package verify
+package verification
 
 import (
 	"net/http"
diff --git a/selfservice/flow/verify/sender.go b/selfservice/flow/verification/sender.go
similarity index 99%
rename from selfservice/flow/verify/sender.go
rename to selfservice/flow/verification/sender.go
index e7d2e4c67..90706cad3 100644
--- a/selfservice/flow/verify/sender.go
+++ b/selfservice/flow/verification/sender.go
@@ -1,4 +1,4 @@
-package verify
+package verification
 
 import (
 	"context"
diff --git a/selfservice/flow/verify/stub/extension/schema.json b/selfservice/flow/verification/stub/extension/schema.json
similarity index 100%
rename from selfservice/flow/verify/stub/extension/schema.json
rename to selfservice/flow/verification/stub/extension/schema.json
diff --git a/selfservice/hook/verification.go b/selfservice/hook/verification.go
index 2be6e363e..6307dec63 100644
--- a/selfservice/hook/verification.go
+++ b/selfservice/hook/verification.go
@@ -6,7 +6,7 @@ import (
 	"github.com/ory/kratos/identity"
 	"github.com/ory/kratos/selfservice/flow/registration"
 	"github.com/ory/kratos/selfservice/flow/settings"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 	"github.com/ory/kratos/session"
 )
 
@@ -15,7 +15,7 @@ var _ settings.PostHookPostPersistExecutor = new(Verifier)
 
 type (
 	verifierDependencies interface {
-		verify.SenderProvider
+		verification.SenderProvider
 	}
 	Verifier struct {
 		r verifierDependencies


Test patch:
diff --git a/internal/testhelpers/sql.go b/internal/testhelpers/sql.go
index 6e6c96781..3f9f1c46e 100644
--- a/internal/testhelpers/sql.go
+++ b/internal/testhelpers/sql.go
@@ -14,7 +14,7 @@ import (
 	"github.com/ory/kratos/selfservice/flow/recovery"
 	"github.com/ory/kratos/selfservice/flow/registration"
 	"github.com/ory/kratos/selfservice/flow/settings"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 	"github.com/ory/kratos/selfservice/strategy/recoverytoken"
 	"github.com/ory/kratos/session"
 )
@@ -32,7 +32,7 @@ func CleanSQL(t *testing.T, c *pop.Connection) {
 		new(recoverytoken.Token).TableName(),
 		new(recovery.RequestMethods).TableName(),
 		new(recovery.Request).TableName(),
-		new(verify.Request).TableName(),
+		new(verification.Request).TableName(),
 		new(session.Session).TableName(),
 		new(identity.CredentialIdentifierCollection).TableName(),
 		new(identity.CredentialsCollection).TableName(),
diff --git a/persistence/sql/persister_test.go b/persistence/sql/persister_test.go
index a75d9c766..6063bce3a 100644
--- a/persistence/sql/persister_test.go
+++ b/persistence/sql/persister_test.go
@@ -36,7 +36,7 @@ import (
 	"github.com/ory/kratos/selfservice/flow/login"
 	"github.com/ory/kratos/selfservice/flow/registration"
 	"github.com/ory/kratos/selfservice/flow/settings"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 	"github.com/ory/kratos/session"
 )
 
@@ -162,7 +162,7 @@ func TestPersister(t *testing.T) {
 			})
 			t.Run("contract=verification.TestPersister", func(t *testing.T) {
 				pop.SetLogger(pl(t))
-				verify.TestPersister(p)(t)
+				verification.TestPersister(p)(t)
 			})
 			t.Run("contract=recovery.TestRequestPersister", func(t *testing.T) {
 				pop.SetLogger(pl(t))
diff --git a/selfservice/flow/verify/handler_test.go b/selfservice/flow/verification/handler_test.go
similarity index 94%
rename from selfservice/flow/verify/handler_test.go
rename to selfservice/flow/verification/handler_test.go
index c71aacb67..9a578451a 100644
--- a/selfservice/flow/verify/handler_test.go
+++ b/selfservice/flow/verification/handler_test.go
@@ -1,4 +1,4 @@
-package verify_test
+package verification_test
 
 import (
 	"context"
@@ -27,7 +27,7 @@ import (
 	"github.com/ory/kratos/internal/httpclient/client"
 	"github.com/ory/kratos/internal/httpclient/client/common"
 	"github.com/ory/kratos/internal/testhelpers"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 	"github.com/ory/kratos/x"
 )
 
@@ -90,12 +90,12 @@ func TestHandler(t *testing.T) {
 	t.Run("case=request verification for unknown via", func(t *testing.T) {
 		res, body := x.EasyGet(t,
 			&http.Client{Jar: x.EasyCookieJar(t, nil)},
-			publicTS.URL+strings.Replace(verify.PublicVerificationInitPath, ":via", "notemail", 1))
+			publicTS.URL+strings.Replace(verification.PublicVerificationInitPath, ":via", "notemail", 1))
 		assert.Contains(t, res.Request.URL.String(), errTS.URL)
 		assert.EqualValues(t, http.StatusBadRequest, gjson.GetBytes(body, "0.code").Int())
 	})
 
-	initURL := publicTS.URL + strings.Replace(verify.PublicVerificationInitPath, ":via", "email", 1)
+	initURL := publicTS.URL + strings.Replace(verification.PublicVerificationInitPath, ":via", "email", 1)
 
 	t.Run("case=init and validate request payload", func(t *testing.T) {
 		hc := &http.Client{Jar: x.EasyCookieJar(t, nil)}
@@ -113,7 +113,7 @@ func TestHandler(t *testing.T) {
 		assert.True(t, time.Time(svr.Payload.ExpiresAt).After(time.Now()))
 		assert.Contains(t, svr.Payload.RequestURL, initURL)
 		assert.Contains(t, svr.Payload.ID, rid)
-		assert.Equal(t, publicTS.URL+strings.Replace(verify.PublicVerificationCompletePath, ":via", "email", 1)+"?request="+rid, *svr.Payload.Form.Action)
+		assert.Equal(t, publicTS.URL+strings.Replace(verification.PublicVerificationCompletePath, ":via", "email", 1)+"?request="+rid, *svr.Payload.Form.Action)
 		assert.Contains(t, "csrf_token", *svr.Payload.Form.Fields[0].Name)
 		assert.Contains(t, "to_verify", *svr.Payload.Form.Fields[1].Name)
 		assert.Contains(t, "email", *svr.Payload.Form.Fields[1].Type)
@@ -215,7 +215,7 @@ func TestHandler(t *testing.T) {
 		hc := &http.Client{Jar: x.EasyCookieJar(t, nil)}
 		res, _ := x.EasyGet(t, hc,
 			publicTS.URL+strings.ReplaceAll(
-				strings.ReplaceAll(verify.PublicVerificationConfirmPath, ":code", "unknown-code"),
+				strings.ReplaceAll(verification.PublicVerificationConfirmPath, ":code", "unknown-code"),
 				":via", "email"))
 		assert.Contains(t, res.Request.URL.String(), verifyTS.URL)
 
diff --git a/selfservice/flow/verify/request_test.go b/selfservice/flow/verification/request_test.go
similarity index 98%
rename from selfservice/flow/verify/request_test.go
rename to selfservice/flow/verification/request_test.go
index 2b62f7c41..b265bd64e 100644
--- a/selfservice/flow/verify/request_test.go
+++ b/selfservice/flow/verification/request_test.go
@@ -1,4 +1,4 @@
-package verify
+package verification
 
 import (
 	"crypto/tls"
diff --git a/selfservice/flow/verify/sender_test.go b/selfservice/flow/verification/sender_test.go
similarity index 92%
rename from selfservice/flow/verify/sender_test.go
rename to selfservice/flow/verification/sender_test.go
index dd6a94258..20c6cb4f3 100644
--- a/selfservice/flow/verify/sender_test.go
+++ b/selfservice/flow/verification/sender_test.go
@@ -1,4 +1,4 @@
-package verify_test
+package verification_test
 
 import (
 	"context"
@@ -13,7 +13,7 @@ import (
 	"github.com/ory/kratos/driver/configuration"
 	"github.com/ory/kratos/identity"
 	"github.com/ory/kratos/internal"
-	"github.com/ory/kratos/selfservice/flow/verify"
+	"github.com/ory/kratos/selfservice/flow/verification"
 )
 
 func TestManager(t *testing.T) {
@@ -36,7 +36,7 @@ func TestManager(t *testing.T) {
 		require.NoError(t, err)
 
 		_, err = reg.VerificationSender().SendCode(context.Background(), address.Via, "not-tracked@ory.sh")
-		require.EqualError(t, err, verify.ErrUnknownAddress.Error())
+		require.EqualError(t, err, verification.ErrUnknownAddress.Error())
 
 		messages, err := reg.CourierPersister().NextMessages(context.Background(), 12)
 		require.NoError(t, err)