Skip to content

Commit

Permalink
user registration
Browse files Browse the repository at this point in the history
  • Loading branch information
khanzadimahdi committed Aug 17, 2024
1 parent a49b18c commit 3394f0d
Show file tree
Hide file tree
Showing 46 changed files with 403 additions and 110 deletions.
6 changes: 3 additions & 3 deletions backend/application/article/getArticle/usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package getarticle

import (
"fmt"
"github.com/khanzadimahdi/testproject/domain/element"
"github.com/khanzadimahdi/testproject/domain/element/component"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/elements"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain"
"github.com/khanzadimahdi/testproject/domain/article"
"github.com/khanzadimahdi/testproject/domain/element"
"github.com/khanzadimahdi/testproject/domain/element/component"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/articles"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/elements"
)

func TestUseCase_Execute(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion backend/application/article/getArticles/usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package getarticles

import (
"errors"
"github.com/khanzadimahdi/testproject/domain/article"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/article"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/articles"
)

Expand Down
6 changes: 4 additions & 2 deletions backend/application/auth/authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package auth

import (
"context"
"github.com/khanzadimahdi/testproject/domain/user"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/user"
)

func TestContext(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion backend/application/auth/register/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"bytes"
"encoding/base64"
"errors"
"time"

"github.com/khanzadimahdi/testproject/application/auth"
"github.com/khanzadimahdi/testproject/domain"
"github.com/khanzadimahdi/testproject/domain/user"
"github.com/khanzadimahdi/testproject/infrastructure/jwt"
"time"
)

type UseCase struct {
Expand Down
8 changes: 7 additions & 1 deletion backend/application/auth/verify/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package verify

import (
"crypto/rand"
"encoding/base64"
"errors"

"github.com/khanzadimahdi/testproject/application/auth"
Expand Down Expand Up @@ -32,7 +33,12 @@ func (uc *UseCase) Execute(request Request) (*Response, error) {
}, nil
}

claims, err := uc.jwt.Verify(request.Token)
registrationToken, err := base64.URLEncoding.DecodeString(request.Token)
if err != nil {
return nil, err
}

claims, err := uc.jwt.Verify(string(registrationToken))
if err != nil {
return &Response{
ValidationErrors: validationErrors{
Expand Down
7 changes: 4 additions & 3 deletions backend/application/auth/verify/usecase_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package verify

import (
"encoding/base64"
"errors"
"github.com/khanzadimahdi/testproject/domain"
"github.com/stretchr/testify/mock"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

"github.com/khanzadimahdi/testproject/application/auth"
"github.com/khanzadimahdi/testproject/domain"
"github.com/khanzadimahdi/testproject/domain/user"
"github.com/khanzadimahdi/testproject/infrastructure/crypto/ecdsa"
crypto "github.com/khanzadimahdi/testproject/infrastructure/crypto/mock"
Expand Down Expand Up @@ -246,5 +247,5 @@ func generateToken(t *testing.T, j *jwt.JWT, u user.User, expiresAt time.Time, a
token, err := j.Generate(b.Build())
assert.NoError(t, err)

return token
return base64.URLEncoding.EncodeToString([]byte(token))
}
6 changes: 4 additions & 2 deletions backend/application/comment/createComment/usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package createComment

import (
"errors"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/author"
"github.com/khanzadimahdi/testproject/domain/comment"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/comments"
"github.com/stretchr/testify/assert"
"testing"
)

func TestUseCase_Execute(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion backend/application/comment/getComments/response.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package getComments

import (
"github.com/khanzadimahdi/testproject/domain/comment"
"time"

"github.com/khanzadimahdi/testproject/domain/comment"
)

type commentResponse struct {
Expand Down
6 changes: 4 additions & 2 deletions backend/application/comment/getComments/usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package getComments

import (
"errors"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/author"
"github.com/khanzadimahdi/testproject/domain/comment"
"github.com/khanzadimahdi/testproject/domain/user"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/comments"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/users"
"github.com/stretchr/testify/assert"
"testing"
)

func TestUseCase_Execute(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package deletearticle

import (
"errors"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/articles"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package updatearticle

import (
"errors"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/article"
"github.com/khanzadimahdi/testproject/domain/author"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/articles"
"github.com/stretchr/testify/assert"
"testing"
)

func TestUseCase_Execute(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package createComment

import (
"github.com/khanzadimahdi/testproject/domain/comment"
"time"

"github.com/khanzadimahdi/testproject/domain/comment"
)

type validationErrors map[string]string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package getComments

import (
"github.com/khanzadimahdi/testproject/domain/comment"
"time"

"github.com/khanzadimahdi/testproject/domain/comment"
)

type commentResponse struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package getComments

import (
"errors"
"github.com/khanzadimahdi/testproject/domain/user"
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/author"
"github.com/khanzadimahdi/testproject/domain/comment"
"github.com/khanzadimahdi/testproject/domain/user"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/comments"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/users"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package updateComment

import (
"github.com/khanzadimahdi/testproject/domain/comment"
"time"

"github.com/khanzadimahdi/testproject/domain/comment"
)

type validationErrors map[string]string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package getelement

import (
"errors"
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/element"
"github.com/khanzadimahdi/testproject/domain/element/component"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/elements"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestUseCase_Execute(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"errors"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/file"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/files"
s "github.com/khanzadimahdi/testproject/infrastructure/storage/mock"
"github.com/stretchr/testify/assert"
)

func TestUseCase_Execute(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package updateprofile

import (
"errors"

"github.com/khanzadimahdi/testproject/domain"
"github.com/khanzadimahdi/testproject/domain/user"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package createrole

import (
"errors"
"github.com/khanzadimahdi/testproject/domain/permission"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/permission"
"github.com/khanzadimahdi/testproject/domain/role"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/permissions"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/roles"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package deleterole

import (
"errors"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/roles"
)

Expand Down
1 change: 1 addition & 0 deletions backend/application/dashboard/user/createUser/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package createuser
import (
"crypto/rand"
"errors"

"github.com/khanzadimahdi/testproject/domain"
"github.com/khanzadimahdi/testproject/domain/password"
"github.com/khanzadimahdi/testproject/domain/user"
Expand Down
6 changes: 4 additions & 2 deletions backend/application/dashboard/user/getUsers/useCase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package getusers

import (
"errors"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/password"
"github.com/khanzadimahdi/testproject/domain/user"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/users"
"github.com/stretchr/testify/assert"
"testing"
)

func TestUseCase_Execute(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions backend/application/dashboard/user/updateUser/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package updateuser

import (
"errors"

"github.com/khanzadimahdi/testproject/domain"
"github.com/khanzadimahdi/testproject/domain/user"
)
Expand Down
9 changes: 5 additions & 4 deletions backend/application/home/usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package home

import (
"errors"
"github.com/khanzadimahdi/testproject/domain/element"
"github.com/khanzadimahdi/testproject/domain/element/component"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/elements"
"testing"

"github.com/stretchr/testify/assert"

"github.com/khanzadimahdi/testproject/domain/article"
"github.com/khanzadimahdi/testproject/domain/element"
"github.com/khanzadimahdi/testproject/domain/element/component"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/articles"
"github.com/stretchr/testify/assert"
"github.com/khanzadimahdi/testproject/infrastructure/repository/mocks/elements"
)

func TestUseCase_Execute(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion backend/domain/comment/comment.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package comment

import (
"github.com/khanzadimahdi/testproject/domain/author"
"time"

"github.com/khanzadimahdi/testproject/domain/author"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion backend/infrastructure/crypto/mock/mock.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package mock

import (
"github.com/khanzadimahdi/testproject/domain/password"
"github.com/stretchr/testify/mock"

"github.com/khanzadimahdi/testproject/domain/password"
)

type MockCrypto struct {
Expand Down
3 changes: 2 additions & 1 deletion backend/infrastructure/jwt/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"time"

"github.com/golang-jwt/jwt/v5"
"github.com/khanzadimahdi/testproject/infrastructure/crypto/ecdsa"
"golang.org/x/exp/maps"

"github.com/khanzadimahdi/testproject/infrastructure/crypto/ecdsa"
)

func TestJWT(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package comments

import (
"github.com/khanzadimahdi/testproject/domain/comment"
"github.com/stretchr/testify/mock"

"github.com/khanzadimahdi/testproject/domain/comment"
)

type MockCommentsRepository struct {
Expand Down
Loading

0 comments on commit 3394f0d

Please sign in to comment.