diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c7a2fa059..f46ad399e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -7,19 +7,73 @@ on: branches: [ "**" ] jobs: - install-build-test-fmt-lint: - name: install-build-test-fmt-lint + e2e-cli: + name: e2e-cli runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: - - name: Set up Go 1.14 - uses: actions/setup-go@v1 - with: - go-version: 1.14 - id: go - - name: Check out code - uses: actions/checkout@v2 - - name: Setup External Dependences - run: make compose-e2e - - name: e2e - run: make test-e2e + - name: Set up Go 1.14 + uses: actions/setup-go@v1 + with: + go-version: 1.14 + id: go + - name: Check out code + uses: actions/checkout@v2 + - name: e2e + run: make test-e2e-cli + e2e-server-horusec: + name: e2e-server-horusec + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Set up Go 1.14 + uses: actions/setup-go@v1 + with: + go-version: 1.14 + id: go + - name: Check out code + uses: actions/checkout@v2 + - name: e2e + run: make test-e2e-server-horusec + e2e-server-keycloak: + name: e2e-server-keycloak + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Set up Go 1.14 + uses: actions/setup-go@v1 + with: + go-version: 1.14 + id: go + - name: Check out code + uses: actions/checkout@v2 + - name: e2e + run: make test-e2e-server-keycloak + e2e-application-admin-horusec: + name: e2e-application-admin-horusec + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Set up Go 1.14 + uses: actions/setup-go@v1 + with: + go-version: 1.14 + id: go + - name: Check out code + uses: actions/checkout@v2 + - name: e2e + run: make test-e2e-application-admin-horusec + e2e-messages: + name: e2e-messages + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Set up Go 1.14 + uses: actions/setup-go@v1 + with: + go-version: 1.14 + id: go + - name: Check out code + uses: actions/checkout@v2 + - name: e2e + run: make test-e2e-messages diff --git a/Makefile b/Makefile index 8b7d8795c..d568d64eb 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ GO ?= go GOFMT ?= gofmt GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor) GOCILINT ?= ./bin/golangci-lint +DOCKER_COMPOSE ?= docker-compose # Format all files founded in GO fmt: @@ -43,14 +44,31 @@ lint: # Run all tests of project but stop the execution on the first test fail test: - $(GO) clean -testcache && $(GO) test -v ./... -timeout=2m -parallel=1 -failfast -short + $(GO) clean -testcache && $(GO) test -v ./... -timeout=20m -parallel=1 -failfast -short -test-e2e: - go get -v ./e2e/... - go get -v ./horusec-cli/... +test-e2e-cli: + $(GO) get -v ./e2e/... + $(GO) get -v ./horusec-cli/... $(GO) clean -testcache $(GO) test -v ./e2e/cli/scan_languages/scan_languages_test.go -timeout=5m -parallel=1 -failfast - $(GO) test -v ./e2e/server/... -timeout=5m -parallel=1 -failfast +test-e2e-server-horusec: compose-e2e-server-horusec + $(GO) get -v ./e2e/... + $(GO) clean -testcache + $(GO) test -v ./e2e/server/horusec/... -timeout=5m -parallel=1 -failfast +test-e2e-application-admin-horusec: compose-e2e-application-admin-horusec + $(GO) get -v ./e2e/... + $(GO) clean -testcache + $(GO) test -v ./e2e/application_admin/horusec/... -timeout=5m -parallel=1 -failfast +test-e2e-messages: compose-e2e-messages + $(GO) get -v ./e2e/... + $(GO) clean -testcache + $(GO) test -v ./e2e/server/messages/... -timeout=5m -parallel=1 -failfast +test-e2e-server-keycloak: compose-e2e-server-keycloak + $(GO) get -v ./e2e/... + $(GO) clean -testcache + $(GO) test -v ./e2e/server/keycloak/... -timeout=5m -parallel=1 -failfast + +# ========================================================================================= # # Run all steps required to pass on pipeline pipeline: fmt lint test coverage build install-manager lint-manager build-manager @@ -75,28 +93,38 @@ compose: compose-down compose-up # Down all containers on depends to the project run compose-down: - docker-compose -f deployments/$(COMPOSE_FILE_NAME) down -v + $(DOCKER_COMPOSE) -f deployments/$(COMPOSE_FILE_NAME) down -v # Up all containers on depends to the project run compose-up: - docker-compose -f deployments/$(COMPOSE_FILE_NAME) up -d --build --force-recreate + $(DOCKER_COMPOSE) -f deployments/$(COMPOSE_FILE_NAME) up -d --build --force-recreate # ========================================================================================= # compose-development-kit: - docker-compose -f development-kit/deployments/docker-compose.yaml up -d --build --force-recreate + $(DOCKER_COMPOSE) -f development-kit/deployments/docker-compose.yaml up -d --build --force-recreate compose-horusec-api: - docker-compose -f horusec-api/deployments/docker-compose.yaml up -d --build --force-recreate + $(DOCKER_COMPOSE) -f horusec-api/deployments/docker-compose.yaml up -d --build --force-recreate compose-horusec-messages: - docker-compose -f horusec-messages/deployments/docker-compose.yaml up -d --build --force-recreate + $(DOCKER_COMPOSE) -f horusec-messages/deployments/docker-compose.yaml up -d --build --force-recreate compose-horusec-account: - docker-compose -f horusec-account/deployments/docker-compose.yaml up -d --build --force-recreate + $(DOCKER_COMPOSE) -f horusec-account/deployments/docker-compose.yaml up -d --build --force-recreate compose-horusec-analytic: - docker-compose -f horusec-analytic/deployments/docker-compose.yaml up -d --build --force-recreate + $(DOCKER_COMPOSE) -f horusec-analytic/deployments/docker-compose.yaml up -d --build --force-recreate compose-horusec-auth: - docker-compose -f horusec-auth/deployments/docker-compose.yaml up -d --build --force-recreate -compose-e2e: - docker-compose -f e2e/deployments/docker-compose.yaml up -d --build --force-recreate + $(DOCKER_COMPOSE) -f horusec-auth/deployments/docker-compose.yaml up -d --build --force-recreate +compose-e2e-server-horusec: + $(DOCKER_COMPOSE) -f e2e/deployments/docker-compose.server.horusec.yaml down -v + $(DOCKER_COMPOSE) -f e2e/deployments/docker-compose.server.horusec.yaml up -d --build --force-recreate +compose-e2e-application-admin-horusec: + $(DOCKER_COMPOSE) -f e2e/deployments/docker-compose.application-admin.horusec.yaml down -v + $(DOCKER_COMPOSE) -f e2e/deployments/docker-compose.application-admin.horusec.yaml up -d --build --force-recreate +compose-e2e-messages: + $(DOCKER_COMPOSE) -f e2e/deployments/docker-compose.server.messages.yaml down -v + $(DOCKER_COMPOSE) -f e2e/deployments/docker-compose.server.messages.yaml up -d --build --force-recreate +compose-e2e-server-keycloak: + $(DOCKER_COMPOSE) -f e2e/deployments/docker-compose.server.keycloak.yaml down -v + $(DOCKER_COMPOSE) -f e2e/deployments/docker-compose.server.keycloak.yaml up -d --build --force-recreate postgresql postgresql_keycloak keycloak horusec-account horusec-analytic # ========================================================================================= # @@ -114,7 +142,7 @@ install-cli: curl -fsSL https://horusec-cli.s3.amazonaws.com/install.sh | bash build-install-cli: - go build -o horusec ./horusec-cli/cmd/horusec/main.go + $(GO) build -o horusec ./horusec-cli/cmd/horusec/main.go chmod +x horusec rm -rf $(GOPATH)/bin/horusec mv horusec $(GOPATH)/bin @@ -122,7 +150,7 @@ build-install-cli: horusec version build-install-leaks-cli: - go build -o horusec ./horusec-leaks/cmd/app/main.go + $(GO) build -o horusec ./horusec-leaks/cmd/app/main.go chmod +x horusec rm -rf $(GOPATH)/bin/horusec-leaks mv horusec $(GOPATH)/bin/horusec-leaks @@ -130,7 +158,7 @@ build-install-leaks-cli: horusec-leaks version build-install-kotlin-cli: - go build -o horusec ./horusec-kotlin/cmd/app/main.go + $(GO) build -o horusec ./horusec-kotlin/cmd/app/main.go chmod +x horusec rm -rf $(GOPATH)/bin/horusec-kotlin mv horusec $(GOPATH)/bin/horusec-kotlin @@ -138,7 +166,7 @@ build-install-kotlin-cli: horusec-kotlin version build-install-java-cli: - go build -o horusec ./horusec-java/cmd/app/main.go + $(GO) build -o horusec ./horusec-java/cmd/app/main.go chmod +x horusec rm -rf $(GOPATH)/bin/horusec-java mv horusec $(GOPATH)/bin/horusec-java @@ -149,4 +177,4 @@ build-install-java-cli: update-cli: chmod +x ./horusec-cli/deployments/scripts/update-image.sh - ./horusec-cli/deployments/scripts/update-image.sh $UPDATE_TYPE $SEND_NEW_VERSION_TO_S3 $IS_TO_UPDATE_LATEST + ./horusec-cli/deployments/scripts/update-image.sh $UPDATE_TYPE $SEND_NEW_VERSION_TO_S3 $IS_TO_UPDATE_LATEST \ No newline at end of file diff --git a/development-kit/pkg/entities/account/invite_user.go b/development-kit/pkg/entities/account/invite_user.go index 175e31052..746428630 100644 --- a/development-kit/pkg/entities/account/invite_user.go +++ b/development-kit/pkg/entities/account/invite_user.go @@ -15,6 +15,7 @@ package account import ( + "encoding/json" "github.com/ZupIT/horusec/development-kit/pkg/entities/account/roles" accountEnums "github.com/ZupIT/horusec/development-kit/pkg/enums/account" validation "github.com/go-ozzo/ozzo-validation/v4" @@ -60,3 +61,8 @@ func (i *InviteUser) SetInviteUserRepositoryAndCompanyID(companyID, repositoryID i.RepositoryID = repositoryID return i } + +func (i *InviteUser) ToBytes() []byte { + content, _ := json.Marshal(i) + return content +} diff --git a/development-kit/pkg/entities/account/invite_user_test.go b/development-kit/pkg/entities/account/invite_user_test.go index 84611aa3e..1e8b8c31c 100644 --- a/development-kit/pkg/entities/account/invite_user_test.go +++ b/development-kit/pkg/entities/account/invite_user_test.go @@ -61,3 +61,13 @@ func TestSetInviteUserCompanyID(t *testing.T) { assert.NotEmpty(t, inviteUser.CompanyID) }) } + +func TestInviteUserToBytes(t *testing.T) { + t.Run("Should return content in bytes not empty", func(t *testing.T) { + inviteUser := InviteUser{ + Role: account.Admin, + Email: "test@test.com", + } + assert.NotEmpty(t, inviteUser.ToBytes()) + }) +} diff --git a/development-kit/pkg/entities/account/roles/account_company.go b/development-kit/pkg/entities/account/roles/account_company.go index 6ef6f6be1..d31e78a45 100644 --- a/development-kit/pkg/entities/account/roles/account_company.go +++ b/development-kit/pkg/entities/account/roles/account_company.go @@ -15,6 +15,7 @@ package roles import ( + "encoding/json" "time" "github.com/go-ozzo/ozzo-validation/v4/is" @@ -65,3 +66,8 @@ func (a *AccountCompany) SetCompanyAndAccountID(companyID, accountID uuid.UUID) func (a *AccountCompany) IsNotAdmin() bool { return a.Role != accountEnums.Admin } + +func (a *AccountCompany) ToBytes() []byte { + content, _ := json.Marshal(a) + return content +} diff --git a/development-kit/pkg/entities/account/roles/account_company_test.go b/development-kit/pkg/entities/account/roles/account_company_test.go index 9c5a8f080..e97a452c5 100644 --- a/development-kit/pkg/entities/account/roles/account_company_test.go +++ b/development-kit/pkg/entities/account/roles/account_company_test.go @@ -15,11 +15,10 @@ package roles import ( - "testing" - rolesEnum "github.com/ZupIT/horusec/development-kit/pkg/enums/account" "github.com/google/uuid" "github.com/stretchr/testify/assert" + "testing" ) func TestValidate(t *testing.T) { @@ -83,3 +82,14 @@ func TestIsNotAdmin(t *testing.T) { assert.False(t, accountCompany.IsNotAdmin()) }) } + +func TestAccountCompanyToBytes(t *testing.T) { + t.Run("Should return content in bytes not empty", func(t *testing.T) { + inviteUser := AccountCompany{ + CompanyID: uuid.New(), + AccountID: uuid.New(), + Role: rolesEnum.Member, + } + assert.NotEmpty(t, inviteUser.ToBytes()) + }) +} diff --git a/development-kit/pkg/entities/api/dto/update_vuln_type.go b/development-kit/pkg/entities/api/dto/update_vuln_type.go index ce1175f3b..ea4e1fab4 100644 --- a/development-kit/pkg/entities/api/dto/update_vuln_type.go +++ b/development-kit/pkg/entities/api/dto/update_vuln_type.go @@ -15,6 +15,7 @@ package dto import ( + "encoding/json" horusecEnums "github.com/ZupIT/horusec/development-kit/pkg/enums/horusec" validation "github.com/go-ozzo/ozzo-validation/v4" ) @@ -29,6 +30,11 @@ func (u *UpdateVulnType) Validate() error { ) } +func (u *UpdateVulnType) ToBytes() []byte { + content, _ := json.Marshal(u) + return content +} + func (u UpdateVulnType) TypeValues() []interface{} { return []interface{}{ horusecEnums.FalsePositive, diff --git a/development-kit/pkg/entities/api/dto/update_vuln_type_test.go b/development-kit/pkg/entities/api/dto/update_vuln_type_test.go index c261c931d..19fd30a99 100644 --- a/development-kit/pkg/entities/api/dto/update_vuln_type_test.go +++ b/development-kit/pkg/entities/api/dto/update_vuln_type_test.go @@ -39,4 +39,11 @@ func TestValidateUpdateVulnType(t *testing.T) { assert.Error(t, err) assert.Equal(t, "type: must be a valid value.", err.Error()) }) + t.Run("Should not return empty content and parse to bytes", func(t *testing.T) { + updateManagementData := &UpdateVulnType{ + Type: "test", + } + + assert.NotEmpty(t, updateManagementData.ToBytes()) + }) } diff --git a/development-kit/pkg/services/keycloak/keycloak.go b/development-kit/pkg/services/keycloak/keycloak.go index 564ce0ce4..ff8950183 100644 --- a/development-kit/pkg/services/keycloak/keycloak.go +++ b/development-kit/pkg/services/keycloak/keycloak.go @@ -83,7 +83,7 @@ func (s *Service) GetUserInfo(accessToken string) (*gocloak.UserInfo, error) { return nil, errorsEnum.ErrorUnauthorized } - return s.client.GetUserInfo(s.ctx, accessToken, s.realm) + return s.client.GetUserInfo(s.ctx, s.removeBearer(accessToken), s.realm) } func (s *Service) removeBearer(accessToken string) string { diff --git a/e2e/TESTBOOK.md b/e2e/TESTBOOK.md index 73f4b5dc5..22d43c9c9 100644 --- a/e2e/TESTBOOK.md +++ b/e2e/TESTBOOK.md @@ -1,42 +1,72 @@ # Test book +# Table of Contents + + * [Horusec server](#horusec-server) + * [Horusec messages](#horusec-messages) + * [Horusec application admin](#horusec-application-admin) + * [Horusec CLI](#horusec-cli) + + ## Horusec server - [ ] Create account - [X] Horusec auth type - [ ] Ldap auth type - - [ ] Keycloak auth type -- [ ] Logout + - [X] Keycloak auth type +- [ ] Login - [X] Horusec auth type - [ ] Ldap auth type - - [ ] Keycloak auth type + - [X] Keycloak auth type +- [ ] Logout + - [X] Horusec auth type - [ ] Authorize - [X] Horusec auth type - [ ] Ldap auth type - - [ ] Keycloak auth type -- [ ] Reset account password + - [X] Keycloak auth type - [ ] Create, Read, Update and Delete company - [X] Horusec auth type - [ ] Ldap auth type - - [ ] Keycloak auth type -- [ ] Create, Read, Update and Delete company with application admin enable - - [ ] Horusec auth type + - [X] Keycloak auth type +- [X] Create, Read, and Delete company token +- [X] Create, Read, Update, and Delete repositories +- [X] Create, Read, and Delete repository token +- [X] Invite, Read, Update and Remove users in company + - [X] Horusec auth type + - [X] Keycloak auth +- [X] Create and Read analysis + - [X] Repository Token + - [X] Company Token + repository name +- [ ] Invite, Read, Update and Remove users in repository + - [X] Horusec auth type - [ ] Ldap auth type - - [ ] Keycloak auth type -- [ ] Create, Read, and Delete company token -- [ ] Create, Read, and Delete repositories -- [ ] Invite, Read, Update and Remove users in company - - [ ] Horusec auth type +- [X] Get Dashboard content + - [X] Company view + - [X] Repository view +- [X] Manager vulnerabilities found and change type into: False Positive, Risk accept, Corrected, Vulnerability + +## Horusec messages +- [X] Create account +- [X] Validate account +- [X] Login +- [X] Logout +- [ ] Reset account password + +## Horusec application admin +- [ ] Create account + - [X] Horusec auth type - [ ] Ldap auth type - - [ ] Keycloak auth type -- [ ] Invite, Read, Update and Remove users in repository - - [ ] Horusec auth type +- [ ] Login + - [X] Horusec auth type + - [ ] Ldap auth type +- [ ] Logout + - [X] Horusec auth type + - [ ] Ldap auth type +- [ ] Authorize + - [X] Horusec auth type + - [ ] Ldap auth type +- [ ] Create, Read, Update and Delete company + - [X] Horusec auth type - [ ] Ldap auth type - - [ ] Keycloak auth type -- [ ] Create, Read, and Delete repository token -- [ ] Get Dashboard content - - [ ] Company view - - [ ] Repository view -- [ ] Manager vulnerabilities found and change type into: False Positive, Risk accept, Corrected, Vulnerability ## Horusec CLI - [ ] Setup log level @@ -72,17 +102,15 @@ - [ ] javaScript - [ ] leaks - [ ] hlc - -### Run analysis examples - - [X] GoLang - - [X] C# - - [X] Ruby - - [X] Python - - [X] Java - - [X] Kotlin - - [X] Javascript - - [X] Leaks - - [X] Terraform +- [X] Scan languages GoLang +- [X] Scan languages C# +- [X] Scan languages Ruby +- [X] Scan languages Python +- [X] Scan languages Java +- [X] Scan languages Kotlin +- [X] Scan languages Javascript +- [X] Scan languages Leaks +- [X] Scan languages Terraform ### Generics repositories to test - [ ] Kubernetes alone diff --git a/e2e/application_admin/horusec/http_test.go b/e2e/application_admin/horusec/http_test.go new file mode 100644 index 000000000..5fc52839b --- /dev/null +++ b/e2e/application_admin/horusec/http_test.go @@ -0,0 +1,115 @@ +// Test e2e refers workflow: .github/workflows/e2e.yml +// In step: e2e-application-admin-horusec +package horusec + +import ( + "fmt" + accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/ZupIT/horusec/development-kit/pkg/utils/env" + "github.com/ZupIT/horusec/development-kit/pkg/utils/logger" + "github.com/golang-migrate/migrate/v4" + _ "github.com/golang-migrate/migrate/v4/database/postgres" + _ "github.com/golang-migrate/migrate/v4/source/file" + "github.com/stretchr/testify/assert" + "os" + "os/exec" + "testing" + "time" +) + +func TestMain(m *testing.M) { + folderOfMigration := "file://../../../development-kit/pkg/databases/relational/migration" + connectionStringDB := env.GetEnvOrDefault("HORUSEC_DATABASE_SQL_URI", "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable") + migration, err := migrate.New(folderOfMigration, connectionStringDB) + if err != nil { + logger.LogPanic("Error in create first instance migration: ", err) + } + if err := migration.Drop(); err != nil { + logger.LogPanic("Error in drop migration: ", err) + } + sourceErr, dbErr := migration.Close() + if sourceErr != nil { + logger.LogPanic("Error in source err to close connection: ", sourceErr) + } + if dbErr != nil { + logger.LogPanic("Error in database err to close connection: ", dbErr) + } + migration, err = migrate.New(folderOfMigration, connectionStringDB) + if err != nil { + logger.LogPanic("Error in create second instance migration: ", err) + } + if err := migration.Up(); err != nil { + if err.Error() != "no change" { + logger.LogPanic("Error in up migration: ", err) + } + } + output, err := exec.Command("docker", "restart", "horusec-auth").Output() + if err != nil { + logger.LogPanic("Error restart auth service: "+string(output), err) + } + time.Sleep(3 * time.Second) + code := m.Run() + os.Exit(code) +} + +func TestServer(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + t.Run("Should tests default auth-type (horusec) http requests in application admin enable", func(t *testing.T) { + time.Sleep(5 * time.Second) + // Login with default application admin + contentLogin := Login(t, &accountentities.LoginData{ + Email: "horusec-admin@example.com", + Password: "Devpass0*", + }) + bearerToken := contentLogin["accessToken"] + + // create company and add to logged user + companyID := CreateCompanyApplicationAdmin(t, bearerToken, &accountentities.CompanyApplicationAdmin{ + Name: "zup", + AdminEmail: "horusec-admin@example.com", + }) + // check if company show to logged user + allCompanies := ReadAllCompanies(t, bearerToken, true) + assert.Contains(t, allCompanies, "zup") + // Update company name + UpdateCompany(t, bearerToken, companyID, &accountentities.Company{ + Name: "zup-1", + }) + // Check if company was updated + allCompaniesUpdated := ReadAllCompanies(t, bearerToken, true) + assert.Contains(t, allCompaniesUpdated, "zup-1") + // Delete company + DeleteCompany(t, bearerToken, companyID) + + // Create new user + CreateAccount(t, &accountentities.Account{ + Email: "e2e@example.com", + Password: "Ch@ng3m3", + Username: "e2e_user", + }) + // Create new company to new user in system + _ = CreateCompanyApplicationAdmin(t, bearerToken, &accountentities.CompanyApplicationAdmin{ + Name: "zup", + AdminEmail: "e2e@example.com", + }) + // Not can possible show company to first user + allCompanies = ReadAllCompanies(t, bearerToken, false) + assert.NotContains(t, allCompanies, "zup") + + // Login with new user + contentLoginNewUser := Login(t, &accountentities.LoginData{ + Email: "e2e@example.com", + Password: "Ch@ng3m3", + }) + bearerTokenNewUser := contentLoginNewUser["accessToken"] + // Check if exists an company for new user + allCompanies = ReadAllCompanies(t, bearerTokenNewUser, true) + assert.Contains(t, allCompanies, "zup") + // Logout both users + Logout(t, bearerToken) + Logout(t, bearerTokenNewUser) + }) + fmt.Println("All tests was finished in server test") +} diff --git a/e2e/application_admin/horusec/requests.go b/e2e/application_admin/horusec/requests.go new file mode 100644 index 000000000..239273dc0 --- /dev/null +++ b/e2e/application_admin/horusec/requests.go @@ -0,0 +1,115 @@ +// Requests save in this file are exclusive of horusec e2e +package horusec + +import ( + "bytes" + "encoding/json" + "fmt" + accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/stretchr/testify/assert" + "net/http" + "testing" +) + +func CreateAccount(t *testing.T, account *accountentities.Account) { + fmt.Println("Running test for CreateAccount") + createAccountResp, err := http.Post("http://127.0.0.1:8003/api/account/create-account", "text/json", bytes.NewReader(account.ToBytes())) + assert.NoError(t, err, "create account error mount request") + assert.Equal(t, http.StatusCreated, createAccountResp.StatusCode, "create account error send request") + + var createAccountResponse map[string]interface{} + _ = json.NewDecoder(createAccountResp.Body).Decode(&createAccountResponse) + assert.NoError(t, createAccountResp.Body.Close()) + assert.NotEmpty(t, createAccountResponse["content"]) +} + +func Login(t *testing.T, credentials *accountentities.LoginData) map[string]string { + fmt.Println("Running test for Login") + loginResp, err := http.Post( + "http://127.0.0.1:8003/api/account/login", + "text/json", + bytes.NewReader(credentials.ToBytes()), + ) + assert.NoError(t, err, "login, error mount request") + assert.Equal(t, http.StatusOK, loginResp.StatusCode, "login error send request") + + var loginResponse map[string]map[string]string + _ = json.NewDecoder(loginResp.Body).Decode(&loginResponse) + assert.NoError(t, loginResp.Body.Close()) + return loginResponse["content"] +} + +func Logout(t *testing.T, bearerToken string) { + fmt.Println("Running test for Logout") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8003/api/account/logout", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "logout error mount request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "logout error send request") + + var logoutResponse map[string]map[string]string + _ = json.NewDecoder(resp.Body).Decode(&logoutResponse) + assert.NoError(t, resp.Body.Close()) +} + +func CreateCompanyApplicationAdmin(t *testing.T, bearerToken string, company *accountentities.CompanyApplicationAdmin) (CompanyID string) { + companyBytes, _ := json.Marshal(company) + fmt.Println("Running test for CreateCompany") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8003/api/companies", bytes.NewReader(companyBytes)) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + createCompanyResp, err := httpClient.Do(req) + assert.NoError(t, err, "create company error send request") + assert.Equal(t, http.StatusCreated, createCompanyResp.StatusCode, "create company error check response") + var createdCompany map[string]map[string]string + _ = json.NewDecoder(createCompanyResp.Body).Decode(&createdCompany) + assert.NoError(t, createCompanyResp.Body.Close()) + assert.NotEmpty(t, createdCompany["content"]["companyID"]) + return createdCompany["content"]["companyID"] +} + +func UpdateCompany(t *testing.T, bearerToken string, companyID string, company *accountentities.Company) { + fmt.Println("Running test for UpdateCompany") + req, _ := http.NewRequest(http.MethodPatch, "http://127.0.0.1:8003/api/companies/"+companyID, bytes.NewReader(company.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "update company error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "update company error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) +} + +func ReadAllCompanies(t *testing.T, bearerToken string, isCheckBodyEmpty bool) string { + fmt.Println("Running test for ReadAllCompanies") + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8003/api/companies", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read all companies error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read all companies error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + if isCheckBodyEmpty { + assert.NotEmpty(t, body["content"]) + } + content, _ := json.Marshal(body["content"]) + return string(content) +} + +func DeleteCompany(t *testing.T, bearerToken, companyID string) { + fmt.Println("Running test for DeleteCompany") + req, _ := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8003/api/companies/"+companyID, nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "delete company error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "delete company error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} diff --git a/e2e/application_admin/keycloak/http_test.go b/e2e/application_admin/keycloak/http_test.go new file mode 100644 index 000000000..59863d67f --- /dev/null +++ b/e2e/application_admin/keycloak/http_test.go @@ -0,0 +1,3 @@ +// Test e2e refers workflow: .github/workflows/e2e.yml +// In step: e2e-application-admin-keycloak +package ldap diff --git a/e2e/application_admin/ldap/http_test.go b/e2e/application_admin/ldap/http_test.go new file mode 100644 index 000000000..c8367d5da --- /dev/null +++ b/e2e/application_admin/ldap/http_test.go @@ -0,0 +1,3 @@ +// Test e2e refers workflow: .github/workflows/e2e.yml +// In step: e2e-application-admin-ldap +package ldap diff --git a/e2e/cli/scan_languages/scan_languages_test.go b/e2e/cli/scan_languages/scan_languages_test.go index cd7a0e074..63d3a9307 100644 --- a/e2e/cli/scan_languages/scan_languages_test.go +++ b/e2e/cli/scan_languages/scan_languages_test.go @@ -1,3 +1,5 @@ +// Test e2e refers workflow: .github/workflows/e2e.yml +// In step: e2e-cli package scan_languages import ( diff --git a/e2e/deployments/docker-compose.application-admin.horusec.yaml b/e2e/deployments/docker-compose.application-admin.horusec.yaml new file mode 100644 index 000000000..e92d76f4d --- /dev/null +++ b/e2e/deployments/docker-compose.application-admin.horusec.yaml @@ -0,0 +1,54 @@ +version: '3' +services: + postgresql: + container_name: postgresql + image: postgres:12 + ports: + - "5432:5432" + environment: + POSTGRES_PASSWORD: root + POSTGRES_USER: root + POSTGRES_DB: horusec_db + volumes: + - /var/lib/postgres/db/data:/var/lib/postgresql/data + tty: true + logging: + driver: json-file + options: + max-size: 10m + horusec-account: + build: + context: ../../ + dockerfile: ./horusec-account/deployments/Dockerfile.dev + depends_on: + - postgresql + restart: always + container_name: horusec-account + ports: + - "8003:8003" + network_mode: "host" + environment: + HORUSEC_ACCOUNT_DISABLE_EMAIL_SERVICE: "true" + HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" + HORUSEC_DATABASE_SQL_DIALECT: "postgres" + HORUSEC_JWT_SECRET_KEY: "horusec-secret" + HORUSEC_AUTH_URL: "127.0.0.1:8007" + horusec-auth: + build: + context: ../../ + dockerfile: ./horusec-auth/deployments/Dockerfile.dev + depends_on: + - postgresql + restart: always + container_name: horusec-auth + ports: + - "8006:8006" + - "8007:8007" + network_mode: "host" + environment: + HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" + HORUSEC_DATABASE_SQL_DIALECT: "postgres" + HORUSEC_JWT_SECRET_KEY: "horusec-secret" + HORUSEC_ENABLE_APPLICATION_ADMIN: "true" + HORUSEC_APPLICATION_ADMIN_DATA: "{\"username\": \"horusec-admin\", \"email\":\"horusec-admin@example.com\", \"password\":\"Devpass0*\"}" + HORUSEC_AUTH_TYPE: "horusec" diff --git a/e2e/deployments/docker-compose.yaml b/e2e/deployments/docker-compose.server.horusec.yaml similarity index 66% rename from e2e/deployments/docker-compose.yaml rename to e2e/deployments/docker-compose.server.horusec.yaml index 5804012d6..dc4574777 100644 --- a/e2e/deployments/docker-compose.yaml +++ b/e2e/deployments/docker-compose.server.horusec.yaml @@ -1,12 +1,5 @@ version: '3' services: -# rabbit: -# container_name: rabbit -# image: rabbitmq:3-management -# network_mode: "host" -# ports: -# - "5672:5672" -# - "15672:15672" postgresql: container_name: postgresql image: postgres:12 @@ -24,34 +17,11 @@ services: driver: json-file options: max-size: 10m -# horusec-messages: -# build: -# context: ../../ -# dockerfile: ./horusec-messages/deployments/Dockerfile.dev -# depends_on: -# - "rabbit" -# restart: always -# container_name: horusec-messages -# network_mode: "host" -# ports: -# - "8004:8004" -# environment: -# HORUSEC_BROKER_HOST: "127.0.0.1" -# HORUSEC_BROKER_PORT: "5672" -# HORUSEC_BROKER_USERNAME: "guest" -# HORUSEC_BROKER_PASSWORD: "guest" -# HORUSEC_SMTP_ADDRESS: "smtp.mailtrap.io" -# HORUSEC_SMTP_USERNAME: ${HORUSEC_SMTP_USERNAME} -# HORUSEC_SMTP_PASSWORD: ${HORUSEC_SMTP_PASSWORD} -# HORUSEC_SMTP_HOST: "smtp.mailtrap.io" -# HORUSEC_SMTP_PORT: "2525" -# HORUSEC_EMAIL_FROM: "horusec@zup.com.br" horusec-account: build: context: ../../ dockerfile: ./horusec-account/deployments/Dockerfile.dev depends_on: -# - "rabbit" - postgresql restart: always container_name: horusec-account @@ -60,10 +30,6 @@ services: - "8003:8003" environment: HORUSEC_ACCOUNT_DISABLE_EMAIL_SERVICE: "true" -# HORUSEC_BROKER_HOST: "127.0.0.1" -# HORUSEC_BROKER_PORT: "5672" -# HORUSEC_BROKER_USERNAME: "guest" -# HORUSEC_BROKER_PASSWORD: "guest" HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" HORUSEC_DATABASE_SQL_DIALECT: "postgres" HORUSEC_JWT_SECRET_KEY: "horusec-secret" @@ -84,10 +50,6 @@ services: HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" HORUSEC_DATABASE_SQL_DIALECT: "postgres" HORUSEC_JWT_SECRET_KEY: "horusec-secret" - HORUSEC_KEYCLOAK_BASE_PATH: ${HORUSEC_KEYCLOAK_BASE_PATH} - HORUSEC_KEYCLOAK_CLIENT_ID: ${HORUSEC_KEYCLOAK_CLIENT_ID} - HORUSEC_KEYCLOAK_CLIENT_SECRET: ${HORUSEC_KEYCLOAK_CLIENT_SECRET} - HORUSEC_KEYCLOAK_REALM: ${HORUSEC_KEYCLOAK_REALM} HORUSEC_ENABLE_APPLICATION_ADMIN: "false" HORUSEC_APPLICATION_ADMIN_DATA: "{\"username\": \"horusec-admin\", \"email\":\"horusec-admin@example.com\", \"password\":\"Devpass0*\"}" HORUSEC_AUTH_TYPE: "horusec" diff --git a/e2e/deployments/docker-compose.server.keycloak.yaml b/e2e/deployments/docker-compose.server.keycloak.yaml new file mode 100644 index 000000000..fdf783f37 --- /dev/null +++ b/e2e/deployments/docker-compose.server.keycloak.yaml @@ -0,0 +1,102 @@ +version: '3' + +services: + postgresql: + container_name: postgresql + image: postgres:12 + ports: + - "5432:5432" + environment: + POSTGRES_PASSWORD: root + POSTGRES_USER: root + POSTGRES_DB: horusec_db + volumes: + - /var/lib/postgres/db/data:/var/lib/postgresql/data + tty: true + logging: + driver: json-file + options: + max-size: 10m + postgresql_keycloak: + container_name: postgresql_keycloak + image: postgres:12 + ports: + - "5433:5433" + expose: + - "5433" + command: -p 5433 + environment: + POSTGRES_PASSWORD: root + POSTGRES_USER: root + POSTGRES_DB: keycloak + keycloak: + container_name: keycloak + image: jboss/keycloak + ports: + - "8080:8080" + network_mode: "host" + environment: + DB_VENDOR: "postgres" + DB_ADDR: "127.0.0.1" + DB_PORT: "5433" + DB_USER: "root" + DB_PASSWORD: "root" + KEYCLOAK_USER: "keycloak" + KEYCLOAK_PASSWORD: "keycloak" + horusec-account: + build: + context: ../../ + dockerfile: ./horusec-account/deployments/Dockerfile.dev + depends_on: + - postgresql + - keycloak + restart: always + container_name: horusec-account + ports: + - "8003:8003" + network_mode: "host" + environment: + HORUSEC_ACCOUNT_DISABLE_EMAIL_SERVICE: "true" + HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" + HORUSEC_DATABASE_SQL_DIALECT: "postgres" + HORUSEC_AUTH_URL: "127.0.0.1:8007" + horusec-auth: + build: + context: ../../ + dockerfile: ./horusec-auth/deployments/Dockerfile.dev + depends_on: + - postgresql + - keycloak + restart: always + container_name: horusec-auth + network_mode: "host" + ports: + - "8006:8006" + - "8007:8007" + environment: + HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" + HORUSEC_DATABASE_SQL_DIALECT: "postgres" + HORUSEC_JWT_SECRET_KEY: "horusec-secret" + HORUSEC_KEYCLOAK_BASE_PATH: "http://127.0.0.1:8080" + HORUSEC_KEYCLOAK_CLIENT_ID: "account" + HORUSEC_KEYCLOAK_CLIENT_SECRET: ${HORUSEC_KEYCLOAK_CLIENT_SECRET} + HORUSEC_KEYCLOAK_REALM: "master" + HORUSEC_ENABLE_APPLICATION_ADMIN: "false" + HORUSEC_APPLICATION_ADMIN_DATA: "{\"username\": \"horusec-admin\", \"email\":\"horusec-admin@example.com\", \"password\":\"Devpass0*\"}" + HORUSEC_AUTH_TYPE: "keycloak" + horusec-analytic: + build: + context: ../../ + dockerfile: ./horusec-analytic/deployments/Dockerfile.dev + depends_on: + - postgresql + - keycloak + restart: always + container_name: horusec-analytic + ports: + - "8005:8005" + network_mode: "host" + environment: + HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" + HORUSEC_DATABASE_SQL_DIALECT: "postgres" + HORUSEC_AUTH_URL: "127.0.0.1:8007" diff --git a/e2e/deployments/docker-compose.server.messages.yaml b/e2e/deployments/docker-compose.server.messages.yaml new file mode 100644 index 000000000..6c94c2090 --- /dev/null +++ b/e2e/deployments/docker-compose.server.messages.yaml @@ -0,0 +1,88 @@ +version: '3' +services: + postgresql: + container_name: postgresql + image: postgres:12 + ports: + - "5432:5432" + environment: + POSTGRES_PASSWORD: root + POSTGRES_USER: root + POSTGRES_DB: horusec_db + volumes: + - /var/lib/postgres/db/data:/var/lib/postgresql/data + tty: true + logging: + driver: json-file + options: + max-size: 10m + rabbit: + container_name: rabbit + image: rabbitmq:3-management + ports: + - "5672:5672" + - "15672:15672" + horusec-messages: + build: + context: ../../ + dockerfile: ./horusec-messages/deployments/Dockerfile.dev + depends_on: + - "rabbit" + restart: always + container_name: horusec-messages + ports: + - "8004:8004" + network_mode: "host" + environment: + HORUSEC_BROKER_HOST: "127.0.0.1" + HORUSEC_BROKER_PORT: "5672" + HORUSEC_BROKER_USERNAME: "guest" + HORUSEC_BROKER_PASSWORD: "guest" + HORUSEC_SMTP_ADDRESS: "smtp.mailtrap.io" + HORUSEC_SMTP_USERNAME: ${HORUSEC_SMTP_USERNAME} + HORUSEC_SMTP_PASSWORD: ${HORUSEC_SMTP_PASSWORD} + HORUSEC_SMTP_HOST: "smtp.mailtrap.io" + HORUSEC_SMTP_PORT: "2525" + HORUSEC_EMAIL_FROM: "horusec@zup.com.br" + horusec-account: + build: + context: ../../ + dockerfile: ./horusec-account/deployments/Dockerfile.dev + depends_on: + - "rabbit" + - postgresql + restart: always + container_name: horusec-account + ports: + - "8003:8003" + network_mode: "host" + environment: + HORUSEC_ACCOUNT_DISABLE_EMAIL_SERVICE: "false" + HORUSEC_BROKER_HOST: "127.0.0.1" + HORUSEC_BROKER_PORT: "5672" + HORUSEC_BROKER_USERNAME: "guest" + HORUSEC_BROKER_PASSWORD: "guest" + HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" + HORUSEC_DATABASE_SQL_DIALECT: "postgres" + HORUSEC_JWT_SECRET_KEY: "horusec-secret" + HORUSEC_AUTH_URL: "127.0.0.1:8007" + HORUSEC_MANAGER_URL: "http://127.0.0.1:8043" + horusec-auth: + build: + context: ../../ + dockerfile: ./horusec-auth/deployments/Dockerfile.dev + depends_on: + - postgresql + restart: always + container_name: horusec-auth + ports: + - "8006:8006" + - "8007:8007" + network_mode: "host" + environment: + HORUSEC_DATABASE_SQL_URI: "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable" + HORUSEC_DATABASE_SQL_DIALECT: "postgres" + HORUSEC_JWT_SECRET_KEY: "horusec-secret" + HORUSEC_ENABLE_APPLICATION_ADMIN: "false" + HORUSEC_APPLICATION_ADMIN_DATA: "{\"username\": \"horusec-admin\", \"email\":\"horusec-admin@example.com\", \"password\":\"Devpass0*\"}" + HORUSEC_AUTH_TYPE: "horusec" \ No newline at end of file diff --git a/e2e/server/horusec/http_test.go b/e2e/server/horusec/http_test.go new file mode 100644 index 000000000..d797c37ec --- /dev/null +++ b/e2e/server/horusec/http_test.go @@ -0,0 +1,438 @@ +// Test e2e refers workflow: .github/workflows/e2e.yml +// In step: e2e-server-horusec +package horusec + +import ( + "encoding/json" + "fmt" + "github.com/ZupIT/horusec/development-kit/pkg/entities/account/roles" + "github.com/ZupIT/horusec/development-kit/pkg/entities/api" + "github.com/ZupIT/horusec/development-kit/pkg/entities/api/dto" + "github.com/ZupIT/horusec/development-kit/pkg/entities/horusec" + rolesEnum "github.com/ZupIT/horusec/development-kit/pkg/enums/account" + horusecEnums "github.com/ZupIT/horusec/development-kit/pkg/enums/horusec" + "github.com/ZupIT/horusec/development-kit/pkg/utils/test" + "github.com/ZupIT/horusec/e2e/server" + "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "net/http" + "os" + "testing" + + accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/ZupIT/horusec/development-kit/pkg/utils/env" + "github.com/ZupIT/horusec/development-kit/pkg/utils/logger" + "github.com/golang-migrate/migrate/v4" + _ "github.com/golang-migrate/migrate/v4/database/postgres" + _ "github.com/golang-migrate/migrate/v4/source/file" +) + +func TestMain(m *testing.M) { + folderOfMigration := "file://../../../development-kit/pkg/databases/relational/migration" + connectionStringDB := env.GetEnvOrDefault("HORUSEC_DATABASE_SQL_URI", "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable") + migration, err := migrate.New(folderOfMigration, connectionStringDB) + if err != nil { + logger.LogPanic("Error in create first instance migration: ", err) + } + if err := migration.Drop(); err != nil { + logger.LogPanic("Error in drop migration: ", err) + } + sourceErr, dbErr := migration.Close() + if sourceErr != nil { + logger.LogPanic("Error in source err to close connection: ", sourceErr) + } + if dbErr != nil { + logger.LogPanic("Error in database err to close connection: ", dbErr) + } + migration, err = migrate.New(folderOfMigration, connectionStringDB) + if err != nil { + logger.LogPanic("Error in create second instance migration: ", err) + } + if err := migration.Up(); err != nil { + if err.Error() != "no change" { + logger.LogPanic("Error in up migration: ", err) + } + } + code := m.Run() + os.Exit(code) +} + +func TestServer(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + t.Run("Should tests default auth-type (horusec) http requests", func(t *testing.T) { + // TESTBOOK: Create account + CreateAccount(t, &accountentities.Account{ + Email: "e2e@example.com", + Password: "Ch@ng3m3", + Username: "e2e_user", + }) + // TESTBOOK: Login + contentLogin := Login(t, &accountentities.LoginData{ + Email: "e2e@example.com", + Password: "Ch@ng3m3", + }) + bearerToken := contentLogin["accessToken"] + // TESTBOOK: Authorize + // TESTBOOK: Create, Read, Update and Delete company + companyID := RunCompanyCRUD(t, bearerToken) + // TESTBOOK: Authorize + // TESTBOOK: Create, Read, Update, and Delete repositories + repositoryID := RunRepositoryCRUD(t, bearerToken, companyID) + // TESTBOOK: Authorize + // TESTBOOK: Create, Read, and Delete repository token + repositoryToken := RunRepositoryTokenCRUD(t, bearerToken, companyID, repositoryID) + // TESTBOOK: Authorize + // TESTBOOK: Create, Read, and Delete company token + companyToken := RunCompanyTokenCRUD(t, bearerToken, companyID) + // TESTBOOK: Create and Read analysis - Repository Token + // TESTBOOK: Create and Read analysis - Company Token + repository name + RunAnalysisRoutes(t, repositoryToken, companyToken) + // TESTBOOK: Get Dashboard content - Company view + RunDashboardByCompany(t, bearerToken, companyID) + // TESTBOOK: Get Dashboard content - Repository view + RunDashboardByRepository(t, bearerToken, companyID, repositoryID) + // TESTBOOK: Get Dashboard content - Repository view + RunManagerVulnerabilities(t, bearerToken, companyID, repositoryID) + // TESTBOOK: Invite, Read, Update and Remove users in company + RunCRUDUserInCompany(t, bearerToken, companyID) + // TESTBOOK: Invite, Read, Update and Remove users in repository + RunCRUDUserInRepository(t, bearerToken, companyID, repositoryID) + // TESTBOOK: Logout + Logout(t, bearerToken) + }) + fmt.Println("All tests was finished in server test") +} + +func RunCompanyCRUD(t *testing.T, bearerToken string) string { + t.Run("Should create an company, check if it exists, update your name check if name was updated delete a company and return new company to manager in other steps", func(t *testing.T) { + companyID := server.CreateCompany(t, bearerToken, &accountentities.Company{ + Name: "zup", + }) + allCompanies := server.ReadAllCompanies(t, bearerToken, true) + assert.Contains(t, allCompanies, "zup") + server.UpdateCompany(t, bearerToken, companyID, &accountentities.Company{ + Name: "zup-1", + }) + allCompaniesUpdated := server.ReadAllCompanies(t, bearerToken, true) + assert.Contains(t, allCompaniesUpdated, "zup-1") + server.DeleteCompany(t, bearerToken, companyID) + }) + return server.CreateCompany(t, bearerToken, &accountentities.Company{ + Name: "zup", + }) +} + +func RunRepositoryCRUD(t *testing.T, bearerToken, companyID string) string { + t.Run("Should create an repository, check if it exists, update your name check if name was updated delete a repository and return new repository to manager in other steps", func(t *testing.T) { + repositoryID := CreateRepository(t, bearerToken, companyID, &accountentities.Repository{ + Name: "horusec", + }) + allRepositories := ReadAllRepositories(t, bearerToken, companyID, true) + assert.Contains(t, allRepositories, "horusec") + UpdateRepository(t, bearerToken, companyID, repositoryID, &accountentities.Repository{ + Name: "horusec-1", + }) + allRepositoriesUpdated := ReadAllRepositories(t, bearerToken, companyID, true) + assert.Contains(t, allRepositoriesUpdated, "horusec-1") + DeleteRepository(t, bearerToken, companyID, repositoryID) + }) + return CreateRepository(t, bearerToken, companyID, &accountentities.Repository{ + Name: "horusec", + }) +} + +func RunRepositoryTokenCRUD(t *testing.T, bearerToken, companyID, repositoryID string) string { + t.Run("Should create an repository token, check if return your content correctly and delete a repository token and return new repository token to manager in other steps", func(t *testing.T) { + _ = GenerateRepositoryToken(t, bearerToken, companyID, repositoryID, api.Token{Description: "access_token"}) + allTokens := ReadAllRepositoryToken(t, bearerToken, companyID, repositoryID) + assert.Contains(t, allTokens, "access_token") + allTokensStruct := []api.Token{} + assert.NoError(t, json.Unmarshal([]byte(allTokens), &allTokensStruct)) + assert.NotEmpty(t, allTokensStruct) + RevokeRepositoryToken(t, bearerToken, companyID, repositoryID, allTokensStruct[0].TokenID.String()) + }) + return GenerateRepositoryToken(t, bearerToken, companyID, repositoryID, api.Token{Description: "access_token"}) +} + +func RunCompanyTokenCRUD(t *testing.T, bearerToken string, companyID string) string { + t.Run("Should create an company token, check if return your content correctly and delete a company token and return new company token to manager in other steps", func(t *testing.T) { + _ = GenerateCompanyToken(t, bearerToken, companyID, api.Token{Description: "access_token"}) + allTokens := ReadAllCompanyToken(t, bearerToken, companyID) + assert.Contains(t, allTokens, "access_token") + allTokensStruct := []api.Token{} + assert.NoError(t, json.Unmarshal([]byte(allTokens), &allTokensStruct)) + assert.NotEmpty(t, allTokensStruct) + RevokeCompanyToken(t, bearerToken, companyID, allTokensStruct[0].TokenID.String()) + }) + return GenerateCompanyToken(t, bearerToken, companyID, api.Token{Description: "access_token"}) +} + +func RunAnalysisRoutes(t *testing.T, repositoryToken, companyToken string) { + t.Run("Should create an analysis using repository token and check if exists your content in system", func(t *testing.T) { + analysisIDInsertedWithRepositoryToken := InsertAnalysisWithRepositoryToken(t, &api.AnalysisData{ + Analysis: test.CreateAnalysisMock(), + }, repositoryToken) + contentInsertedWithRepositoryToken := GetAnalysisByID(t, analysisIDInsertedWithRepositoryToken, repositoryToken) + analysisInsertedWithRepositoryToken := horusec.Analysis{} + assert.NoError(t, json.Unmarshal([]byte(contentInsertedWithRepositoryToken), &analysisInsertedWithRepositoryToken)) + assert.NotEmpty(t, analysisInsertedWithRepositoryToken) + assert.Greater(t, len(analysisInsertedWithRepositoryToken.AnalysisVulnerabilities), 0) + }) + t.Run("Should create an analysis using company token and check if exists your content in system", func(t *testing.T) { + analysisIDInsertedWithCompanyToken := InsertAnalysisWithCompanyToken(t, &api.AnalysisData{ + Analysis: test.CreateAnalysisMock(), + RepositoryName: "new-repository", + }, companyToken) + contentInsertedWithCompanyToken := GetAnalysisByID(t, analysisIDInsertedWithCompanyToken, repositoryToken) + analysisInsertedWithCompanyToken := horusec.Analysis{} + assert.NoError(t, json.Unmarshal([]byte(contentInsertedWithCompanyToken), &analysisInsertedWithCompanyToken)) + assert.NotEmpty(t, analysisInsertedWithCompanyToken) + assert.Greater(t, len(analysisInsertedWithCompanyToken.AnalysisVulnerabilities), 0) + }) +} + +func RunDashboardByCompany(t *testing.T, bearerToken, companyID string) { + t.Run("Check if all graphs routes return content in view by company", func(t *testing.T) { + bodyAllVulnerabilities := GetChartContent(t, "all-vulnerabilities", bearerToken, companyID, "") + bodyAllVulnerabilitiesString := string(bodyAllVulnerabilities) + assert.NotEmpty(t, bodyAllVulnerabilitiesString) + + bodyVulnerabilitiesByAuthor := GetChartContent(t, "vulnerabilities-by-author", bearerToken, companyID, "") + bodyVulnerabilitiesByAuthorString := string(bodyVulnerabilitiesByAuthor) + assert.NotEmpty(t, bodyVulnerabilitiesByAuthorString) + + bodyVulnerabilitiesByLanguage := GetChartContent(t, "vulnerabilities-by-language", bearerToken, companyID, "") + bodyVulnerabilitiesByLanguageString := string(bodyVulnerabilitiesByLanguage) + assert.NotEmpty(t, bodyVulnerabilitiesByLanguageString) + + bodyVulnerabilitiesByRepository := GetChartContent(t, "vulnerabilities-by-repository", bearerToken, companyID, "") + bodyVulnerabilitiesByRepositoryString := string(bodyVulnerabilitiesByRepository) + assert.NotEmpty(t, bodyVulnerabilitiesByRepositoryString) + + bodyVulnerabilitiesByTime := GetChartContent(t, "vulnerabilities-by-time", bearerToken, companyID, "") + bodyVulnerabilitiesByTimeString := string(bodyVulnerabilitiesByTime) + assert.NotEmpty(t, bodyVulnerabilitiesByTimeString) + + bodyTotalDevelopers := GetChartContent(t, "total-developers", bearerToken, companyID, "") + bodyTotalDevelopersString := string(bodyTotalDevelopers) + assert.NotEmpty(t, bodyTotalDevelopersString) + + bodyTotalRepositories := GetChartContent(t, "total-repositories", bearerToken, companyID, "") + bodyTotalRepositoriesString := string(bodyTotalRepositories) + assert.NotEmpty(t, bodyTotalRepositoriesString) + + bodyDetailsChart := GetChartDetailsUsingGraphQLAndReturnBody(t, bearerToken, companyID, "") + bodyDetailsChartString := string(bodyDetailsChart) + assert.NotEmpty(t, bodyDetailsChartString) + }) +} + +func RunDashboardByRepository(t *testing.T, bearerToken, companyID, repositoryID string) { + t.Run("Check if all graphs routes return content in view by repository", func(t *testing.T) { + bodyAllVulnerabilities := GetChartContent(t, "all-vulnerabilities", bearerToken, companyID, repositoryID) + bodyAllVulnerabilitiesString := string(bodyAllVulnerabilities) + assert.NotEmpty(t, bodyAllVulnerabilitiesString) + + bodyVulnerabilitiesByAuthor := GetChartContent(t, "vulnerabilities-by-author", bearerToken, companyID, repositoryID) + bodyVulnerabilitiesByAuthorString := string(bodyVulnerabilitiesByAuthor) + assert.NotEmpty(t, bodyVulnerabilitiesByAuthorString) + + bodyVulnerabilitiesByLanguage := GetChartContent(t, "vulnerabilities-by-language", bearerToken, companyID, repositoryID) + bodyVulnerabilitiesByLanguageString := string(bodyVulnerabilitiesByLanguage) + assert.NotEmpty(t, bodyVulnerabilitiesByLanguageString) + + bodyVulnerabilitiesByRepository := GetChartContent(t, "vulnerabilities-by-repository", bearerToken, companyID, repositoryID) + bodyVulnerabilitiesByRepositoryString := string(bodyVulnerabilitiesByRepository) + assert.NotEmpty(t, bodyVulnerabilitiesByRepositoryString) + + bodyVulnerabilitiesByTime := GetChartContent(t, "vulnerabilities-by-time", bearerToken, companyID, repositoryID) + bodyVulnerabilitiesByTimeString := string(bodyVulnerabilitiesByTime) + assert.NotEmpty(t, bodyVulnerabilitiesByTimeString) + + bodyTotalDevelopers := GetChartContent(t, "total-developers", bearerToken, companyID, repositoryID) + bodyTotalDevelopersString := string(bodyTotalDevelopers) + assert.NotEmpty(t, bodyTotalDevelopersString) + + bodyTotalRepositories := GetChartContent(t, "total-repositories", bearerToken, companyID, repositoryID) + bodyTotalRepositoriesString := string(bodyTotalRepositories) + assert.NotEmpty(t, bodyTotalRepositoriesString) + + bodyDetailsChart := GetChartDetailsUsingGraphQLAndReturnBody(t, bearerToken, companyID, repositoryID) + bodyDetailsChartString := string(bodyDetailsChart) + assert.NotEmpty(t, bodyDetailsChartString) + }) +} + +func RunManagerVulnerabilities(t *testing.T, bearerToken, companyID, repositoryID string) { + t.Run("Should get all vulnerabilities in system and check if all are vulnerabilities after we need update one item to false positive and check if exists how false positive in list", func(t *testing.T) { + allVulnerabilitiesString := GetAllVulnerabilitiesToManager(t, bearerToken, companyID, repositoryID, "page=1&size=10") + allVulnerabilities := dto.VulnManagement{} + assert.NoError(t, json.Unmarshal([]byte(allVulnerabilitiesString), &allVulnerabilities)) + assert.NotEmpty(t, allVulnerabilities) + assert.Equal(t, allVulnerabilities.TotalItems, 11) + assert.Equal(t, len(allVulnerabilities.Data), 10) + for _, vuln := range allVulnerabilities.Data { + assert.Equal(t, vuln.Type, horusecEnums.Vulnerability) + } + vulnIDToUpdate := allVulnerabilities.Data[0].VulnerabilityID.String() + _ = UpdateVulnerabilitiesType(t, bearerToken, companyID, repositoryID, vulnIDToUpdate, dto.UpdateVulnType{Type: horusecEnums.FalsePositive}) + allVulnerabilitiesUpdatedString := GetAllVulnerabilitiesToManager(t, bearerToken, companyID, repositoryID, "page=1&size=11") + allVulnerabilitiesUpdated := dto.VulnManagement{} + assert.NoError(t, json.Unmarshal([]byte(allVulnerabilitiesUpdatedString), &allVulnerabilitiesUpdated)) + assert.NotEmpty(t, allVulnerabilitiesUpdated) + assert.Equal(t, allVulnerabilitiesUpdated.TotalItems, 11) + assert.Equal(t, len(allVulnerabilitiesUpdated.Data), 11) + for _, vuln := range allVulnerabilitiesUpdated.Data { + if vuln.VulnerabilityID.String() == vulnIDToUpdate { + assert.Equal(t, vuln.Type, horusecEnums.FalsePositive) + } else { + assert.Equal(t, vuln.Type, horusecEnums.Vulnerability) + } + } + }) +} + +func RunCRUDUserInCompany(t *testing.T, bearerTokenAccount1, companyID string) { + t.Run("Should create new user and invite to existing company with permission of the member after update your permission to admin and check if is enable view dashboard by company and remove user from company", func(t *testing.T) { + account2 := &accountentities.Account{ + Email: "e2e_test2@example.com", + Password: "Ch@ng3m3", + Username: "e2e_user_test2", + } + companyIDParsed, _ := uuid.Parse(companyID) + + // Add new user to invite + CreateAccount(t, account2) + + // Invite user to existing company + server.InviteUserToCompany(t, bearerTokenAccount1, companyID, &accountentities.InviteUser{ + Role: rolesEnum.Member, + Email: account2.Email, + CompanyID: companyIDParsed, + }) + + // Check if exist two users in company + allUsersInCompany := server.ReadAllUserInCompany(t, bearerTokenAccount1, companyID) + accountRoles := []roles.AccountRole{} + assert.NoError(t, json.Unmarshal([]byte(allUsersInCompany), &accountRoles)) + assert.NotEmpty(t, accountRoles) + assert.Equal(t, 2, len(accountRoles)) + accountID := "" + for _, user := range accountRoles { + if user.Email == account2.Email { + accountID = user.AccountID.String() + } + } + assert.NotEmpty(t, accountID) + // Login with new user + contentLoginAccount2 := Login(t, &accountentities.LoginData{ + Email: account2.Email, + Password: account2.Password, + }) + bearerTokenAccount2 := contentLoginAccount2["accessToken"] + + // Check if company exists to new user + allCompanies := server.ReadAllCompanies(t, bearerTokenAccount2, true) + assert.Contains(t, allCompanies, "zup") + + // Expected return unauthorized because user is not admin of company to see dashboard in company view + responseChart := server.GetChartContentWithoutTreatment(t, "total-repositories", bearerTokenAccount2, companyID, "") + assert.Equal(t, http.StatusUnauthorized, responseChart.GetStatusCode()) + + // Update permission of new user to admin + server.UpdateUserInCompany(t, bearerTokenAccount1, companyID, accountID, &roles.AccountCompany{ + Role: rolesEnum.Admin, + }) + + // Expected return OK because user is authorized view dashboard in company view + responseChart = server.GetChartContentWithoutTreatment(t, "total-repositories", bearerTokenAccount2, companyID, "") + assert.Equal(t, http.StatusOK, responseChart.GetStatusCode()) + + // Expected remove user from company + server.RemoveUserInCompany(t, bearerTokenAccount1, companyID, accountID) + + // Not show company for user when get all companies + allCompanies = server.ReadAllCompanies(t, bearerTokenAccount2, false) + assert.NotContains(t, allCompanies, "zup") + + // Logout session new user + Logout(t, bearerTokenAccount2) + }) +} + +func RunCRUDUserInRepository(t *testing.T, bearerTokenAccount1, companyID, repositoryID string) { + t.Run("Should create new user and invite to existing company and invite to existing repository, with permission of the member in repository after update your permission to admin of repository and check if is enable show all tokens in repository and remove user from repository", func(t *testing.T) { + account2 := &accountentities.Account{ + Email: "e2e_test3@example.com", + Password: "Ch@ng3m3", + Username: "e2e_user_test3", + } + companyIDParsed, _ := uuid.Parse(companyID) + + // Add new user to invite + CreateAccount(t, account2) + + // Invite new user to existing company + server.InviteUserToCompany(t, bearerTokenAccount1, companyID, &accountentities.InviteUser{ + Role: rolesEnum.Member, + Email: account2.Email, + CompanyID: companyIDParsed, + }) + // Invite new user to existing repository + InviteUserToRepository(t, bearerTokenAccount1, companyID, repositoryID, &accountentities.InviteUser{ + Role: rolesEnum.Member, + Email: account2.Email, + CompanyID: companyIDParsed, + }) + + // Check if exist two users in repository + allUsersInRepository := ReadAllUserInRepository(t, bearerTokenAccount1, companyID, repositoryID) + accountRoles := []roles.AccountRole{} + assert.NoError(t, json.Unmarshal([]byte(allUsersInRepository), &accountRoles)) + assert.NotEmpty(t, accountRoles) + assert.Equal(t, 2, len(accountRoles)) + accountID := "" + for _, user := range accountRoles { + if user.Email == account2.Email { + accountID = user.AccountID.String() + } + } + assert.NotEmpty(t, accountID) + + // Login with new user + contentLoginAccount2 := Login(t, &accountentities.LoginData{ + Email: account2.Email, + Password: account2.Password, + }) + bearerTokenAccount2 := contentLoginAccount2["accessToken"] + + // Check if repository exists to new user + allRepositories := ReadAllRepositories(t, bearerTokenAccount2, companyID, true) + assert.Contains(t, allRepositories, "horusec") + + // Expected return unauthorized because user is not admin of repository to see tokens of repository + responseRepositoryToken := ReadAllRepositoryTokenWithoutTreatment(t, bearerTokenAccount2, companyID, repositoryID) + assert.Equal(t, http.StatusUnauthorized, responseRepositoryToken.GetStatusCode()) + + // Update permission of new user to admin in repository + UpdateUserInRepository(t, bearerTokenAccount1, companyID, repositoryID, accountID, &roles.AccountCompany{ + Role: rolesEnum.Admin, + }) + + // Expected return OK because user is authorized to see tokens of repository + responseRepositoryToken = ReadAllRepositoryTokenWithoutTreatment(t, bearerTokenAccount2, companyID, repositoryID) + assert.Equal(t, http.StatusOK, responseRepositoryToken.GetStatusCode()) + + // Expected remove user from company + RemoveUserInRepository(t, bearerTokenAccount1, companyID, repositoryID, accountID) + + // Not show repository for user when get all repositories + allRepositories = ReadAllRepositories(t, bearerTokenAccount2, companyID, false) + assert.NotContains(t, allRepositories, "horusec") + + // Logout session new user + Logout(t, bearerTokenAccount2) + }) +} diff --git a/e2e/server/horusec/requests.go b/e2e/server/horusec/requests.go new file mode 100644 index 000000000..4ce509ce6 --- /dev/null +++ b/e2e/server/horusec/requests.go @@ -0,0 +1,455 @@ +// Requests save in this file are exclusive of horusec e2e +package horusec + +import ( + "bytes" + "crypto/tls" + "encoding/json" + "fmt" + accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/ZupIT/horusec/development-kit/pkg/entities/account/roles" + "github.com/ZupIT/horusec/development-kit/pkg/entities/api" + "github.com/ZupIT/horusec/development-kit/pkg/entities/api/dto" + "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/client" + "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/request" + httpResponse "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/response" + "github.com/stretchr/testify/assert" + "net/http" + "strings" + "testing" + "time" +) + +func CreateAccount(t *testing.T, account *accountentities.Account) { + fmt.Println("Running test for CreateAccount") + createAccountResp, err := http.Post("http://127.0.0.1:8003/api/account/create-account", "text/json", bytes.NewReader(account.ToBytes())) + assert.NoError(t, err, "create account error mount request") + assert.Equal(t, http.StatusCreated, createAccountResp.StatusCode, "create account error send request") + + var createAccountResponse map[string]interface{} + _ = json.NewDecoder(createAccountResp.Body).Decode(&createAccountResponse) + assert.NoError(t, createAccountResp.Body.Close()) + assert.NotEmpty(t, createAccountResponse["content"]) +} + +func Login(t *testing.T, credentials *accountentities.LoginData) map[string]string { + fmt.Println("Running test for Login") + loginResp, err := http.Post( + "http://127.0.0.1:8003/api/account/login", + "text/json", + bytes.NewReader(credentials.ToBytes()), + ) + assert.NoError(t, err, "login, error mount request") + assert.Equal(t, http.StatusOK, loginResp.StatusCode, "login error send request") + + var loginResponse map[string]map[string]string + _ = json.NewDecoder(loginResp.Body).Decode(&loginResponse) + assert.NoError(t, loginResp.Body.Close()) + return loginResponse["content"] +} + +func Logout(t *testing.T, bearerToken string) { + fmt.Println("Running test for Logout") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8003/api/account/logout", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "logout error mount request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "logout error send request") + + var logoutResponse map[string]map[string]string + _ = json.NewDecoder(resp.Body).Decode(&logoutResponse) + assert.NoError(t, resp.Body.Close()) +} + +func CreateRepository(t *testing.T, bearerToken, companyID string, repository *accountentities.Repository) string { + repositoryBytes, _ := json.Marshal(repository) + fmt.Println("Running test for CreateRepository") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8003/api/companies/"+companyID+"/repositories", bytes.NewReader(repositoryBytes)) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "create repository error send request") + assert.Equal(t, http.StatusCreated, resp.StatusCode, "create repository error check response") + var body map[string]map[string]string + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]["repositoryID"]) + return body["content"]["repositoryID"] +} + +func UpdateRepository(t *testing.T, bearerToken, companyID, repositoryID string, repository *accountentities.Repository) { + fmt.Println("Running test for UpdateRepository") + repositoryBytes, _ := json.Marshal(repository) + fmt.Println("Running test for UpdateRepository") + req, _ := http.NewRequest(http.MethodPatch, "http://127.0.0.1:8003/api/companies/"+companyID+"/repositories/"+repositoryID, bytes.NewReader(repositoryBytes)) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "update repository error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "update repository error check response") + var body map[string]map[string]string + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} + +func ReadAllRepositories(t *testing.T, bearerToken, companyID string, isCheckBodyEmpty bool) string { + fmt.Println("Running test for ReadAllRepositories") + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8003/api/companies/"+companyID+"/repositories", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read all repositories error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read all repositories error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + if isCheckBodyEmpty { + assert.NotEmpty(t, body["content"]) + } + content, _ := json.Marshal(body["content"]) + return string(content) +} + +func DeleteRepository(t *testing.T, bearerToken, companyID, repositoryID string) { + fmt.Println("Running test for DeleteRepository") + req, _ := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8003/api/companies/"+companyID+"/repositories/"+repositoryID, nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "delete repository error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "delete repository error check response") + var body map[string]map[string]string + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} + +func GenerateRepositoryToken(t *testing.T, bearerToken, companyID, repositoryID string, token api.Token) string { + fmt.Println("Running test for GenerateRepositoryToken") + req, _ := http.NewRequest( + http.MethodPost, + "http://127.0.0.1:8000/api/companies/"+companyID+"/repositories/"+repositoryID+"/tokens", + bytes.NewReader(token.ToBytes()), + ) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + apiTokenResp, err := httpClient.Do(req) + assert.NoError(t, err, "generate repository token error send response") + assert.Equal(t, http.StatusCreated, apiTokenResp.StatusCode, "generate repository token error check response") + + var apiToken map[string]string + _ = json.NewDecoder(apiTokenResp.Body).Decode(&apiToken) + assert.NoError(t, apiTokenResp.Body.Close()) + assert.NotEmpty(t, apiToken["content"]) + return apiToken["content"] +} + +func ReadAllRepositoryToken(t *testing.T, bearerToken, companyID, repositoryID string) string { + fmt.Println("Running test for ReadAllRepositoryToken") + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/api/companies/"+companyID+"/repositories/"+repositoryID+"/tokens", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read all repositories tokens error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read all repositories tokens error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + content, _ := json.Marshal(body["content"]) + return string(content) +} +func ReadAllRepositoryTokenWithoutTreatment(t *testing.T, bearerToken, companyID, repositoryID string) httpResponse.Interface { + fmt.Println("Running test for ReadAllRepositoryToken") + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/api/companies/"+companyID+"/repositories/"+repositoryID+"/tokens", nil) + req.Header.Add("Authorization", bearerToken) + res, err := client.NewHTTPClient(15).DoRequest(req, &tls.Config{}) + assert.NoError(t, err) + return res +} +func RevokeRepositoryToken(t *testing.T, bearerToken, companyID, repositoryID, tokenID string) { + fmt.Println("Running test for RevokeRepositoryToken") + req, _ := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8000/api/companies/"+companyID+"/repositories/"+repositoryID+"/tokens/"+tokenID, nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "delete repository token error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "delete repository token error check response") + var body map[string]map[string]string + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} + +func GenerateCompanyToken(t *testing.T, bearerToken, companyID string, token api.Token) string { + fmt.Println("Running test for GenerateCompanyToken") + req, _ := http.NewRequest( + http.MethodPost, + "http://127.0.0.1:8000/api/companies/"+companyID+"/tokens", + bytes.NewReader(token.ToBytes()), + ) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + apiTokenResp, err := httpClient.Do(req) + assert.NoError(t, err, "generate company token error send response") + assert.Equal(t, http.StatusCreated, apiTokenResp.StatusCode, "generate company token error check response") + + var apiToken map[string]string + _ = json.NewDecoder(apiTokenResp.Body).Decode(&apiToken) + assert.NoError(t, apiTokenResp.Body.Close()) + assert.NotEmpty(t, apiToken["content"]) + return apiToken["content"] +} + +func ReadAllCompanyToken(t *testing.T, bearerToken, companyID string) string { + fmt.Println("Running test for ReadAllCompanyToken") + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/api/companies/"+companyID+"/tokens", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read all companies tokens error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read all companies tokens error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + content, _ := json.Marshal(body["content"]) + return string(content) +} + +func RevokeCompanyToken(t *testing.T, bearerToken, companyID, tokenID string) { + fmt.Println("Running test for RevokeCompanyToken") + req, _ := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8000/api/companies/"+companyID+"/tokens/"+tokenID, nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "delete company token error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "delete company token error check response") + var body map[string]map[string]string + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} + +func InsertAnalysisWithRepositoryToken(t *testing.T, analysisData *api.AnalysisData, repositoryToken string) string { + fmt.Println("Running test for InsertAnalysisWithRepositoryToken") + req, _ := http.NewRequest( + http.MethodPost, + "http://127.0.0.1:8000/api/analysis", + bytes.NewReader(analysisData.ToBytes()), + ) + req.Header.Add("Authorization", repositoryToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "InsertAnalysisWithRepositoryToken error send response") + assert.Equal(t, http.StatusCreated, resp.StatusCode, "InsertAnalysisWithRepositoryToken error check response") + + var body map[string]string + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + return body["content"] +} + +func InsertAnalysisWithCompanyToken(t *testing.T, analysisData *api.AnalysisData, companyToken string) string { + fmt.Println("Running test for InsertAnalysisWithRepositoryToken") + req, _ := http.NewRequest( + http.MethodPost, + "http://127.0.0.1:8000/api/analysis", + bytes.NewReader(analysisData.ToBytes()), + ) + req.Header.Add("Authorization", companyToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "InsertAnalysisWithRepositoryToken error send response") + assert.Equal(t, http.StatusCreated, resp.StatusCode, "InsertAnalysisWithRepositoryToken error check response") + + var body map[string]string + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + return body["content"] +} + +func GetAnalysisByID(t *testing.T, analysisID, authorization string) string { + fmt.Println("Running test for GetAnalysisByID") + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/api/analysis/"+analysisID, nil) + req.Header.Add("Authorization", authorization) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read analysis by ID error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read analysis by ID error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + content, _ := json.Marshal(body["content"]) + return string(content) +} + +func GetChartContent(t *testing.T, route, bearerToken, companyID, repositoryID string) []byte { + fmt.Println("Running test for GetChartContent in route: " + route) + fmt.Println("Running test for GetChartRESTContentAndReturnBody") + now := time.Now() + initialDateStr := now.Format("2006-01-02") + "T00:00:00Z" + finalDateStr := now.Format("2006-01-02") + "T23:59:59Z" + URL := fmt.Sprintf("http://127.0.0.1:8005/api/dashboard/companies/%s/%s?initialDate=%s&finalDate=%s", companyID, route, initialDateStr, finalDateStr) + if repositoryID != "" { + URL = fmt.Sprintf("http://127.0.0.1:8005/api/dashboard/companies/%s/repositories/%s/%s?initialDate=%s&finalDate=%s", companyID, repositoryID, route, initialDateStr, finalDateStr) + } + req, err := request.NewHTTPRequest().Request(http.MethodGet, URL, nil, map[string]string{"Authorization": bearerToken, "Content-type": "application/json"}) + assert.NoError(t, err) + res, err := client.NewHTTPClient(15).DoRequest(req, &tls.Config{}) + assert.NoError(t, err) + assert.Equal(t, res.GetStatusCode(), http.StatusOK) + body, err := res.GetBody() + assert.NoError(t, err) + return body +} + +func GetChartDetailsUsingGraphQLAndReturnBody(t *testing.T, bearerToken, companyID, repositoryID string) []byte { + fmt.Println("Running test for GetChartContent using graphql") + now := time.Now() + initialDateStr := now.Format("2006-01-02") + "T00:00:00Z" + finalDateStr := now.Format("2006-01-02") + "T23:59:59Z" + filterGraphQL := fmt.Sprintf("companyID: \"%s\"", companyID) + if repositoryID != "" { + filterGraphQL = fmt.Sprintf("repositoryID: \"%s\"", repositoryID) + } + filterTotalItemsAndAnalysis := fmt.Sprintf("(%s, initialDate: \"%s\", finalDate: \"%s\")", filterGraphQL, initialDateStr, finalDateStr) + queryGraphQL := "{" + + fmt.Sprintf("totalItems%s", filterTotalItemsAndAnalysis) + + fmt.Sprintf("analysis%s", filterTotalItemsAndAnalysis) + + `{ + repositoryName + companyName + vulnerability { + line + column + confidence + file + code + details + securityTool + language + severity + commitAuthor + commitEmail + commitHash + commitMessage + commitDate + } + } + }` + queryGraphQL = strings.ReplaceAll(queryGraphQL, "\n", "%20") + queryGraphQL = strings.ReplaceAll(queryGraphQL, "\t", "%20") + queryGraphQL = strings.ReplaceAll(queryGraphQL, " ", "%20") + URL := fmt.Sprintf("http://127.0.0.1:8005/api/dashboard/companies/%s/details?query=%s&page=1&size=1000", companyID, queryGraphQL) + if repositoryID != "" { + URL = fmt.Sprintf("http://127.0.0.1:8005/api/dashboard/companies/%s/repositories/%s/details?query=%s&page=1&size=1000", companyID, repositoryID, queryGraphQL) + } + req, err := request.NewHTTPRequest().Request(http.MethodGet, URL, nil, map[string]string{"Authorization": bearerToken, "Content-Type": "application/json"}) + assert.NoError(t, err) + res, err := client.NewHTTPClient(15).DoRequest(req, &tls.Config{}) + assert.NoError(t, err) + assert.Equal(t, res.GetStatusCode(), http.StatusOK) + body, err := res.GetBody() + assert.NoError(t, err) + return body +} + +func GetAllVulnerabilitiesToManager(t *testing.T, bearerToken, companyID, repositoryID string, queryString string) string { + fmt.Println("Running test for GetAllVulnerabilitiesToManager") + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/api/companies/"+companyID+"/repositories/"+repositoryID+"/management?"+queryString, nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read vulnerabilities error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read vulnerabilities error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + content, _ := json.Marshal(body["content"]) + return string(content) +} + +func UpdateVulnerabilitiesType(t *testing.T, bearerToken, companyID, repositoryID, vulnerabilityID string, vulnType dto.UpdateVulnType) string { + fmt.Println("Running test for UpdateVulnerabilitiesType") + req, _ := http.NewRequest( + http.MethodPut, + "http://127.0.0.1:8000/api/companies/"+companyID+"/repositories/"+repositoryID+"/management/"+vulnerabilityID+"/type", + bytes.NewReader(vulnType.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "update vulnerabilities error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "update vulnerabilities error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + content, _ := json.Marshal(body["content"]) + return string(content) +} +func InviteUserToRepository(t *testing.T, bearerToken, companyID, repositoryID string, user *accountentities.InviteUser) { + fmt.Println("Running test for InviteUserToRepository") + req, _ := http.NewRequest( + http.MethodPost, + "http://127.0.0.1:8003/api/companies/"+companyID+"/repositories/"+repositoryID+"/roles", + bytes.NewReader(user.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "invite user in repository error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "invite user in repository error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} +func ReadAllUserInRepository(t *testing.T, bearerToken, companyID, repositoryID string) string { + fmt.Println("Running test for InviteUserToCompany") + req, _ := http.NewRequest( + http.MethodGet, + "http://127.0.0.1:8003/api/companies/"+companyID+"/repositories/"+repositoryID+"/roles", + nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read all user in repository error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read all user in repository error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + content, _ := json.Marshal(body["content"]) + return string(content) +} +func UpdateUserInRepository(t *testing.T, bearerToken, companyID, repositoryID, accountID string, account *roles.AccountCompany) { + fmt.Println("Running test for UpdateUserInRepository") + req, _ := http.NewRequest( + http.MethodPatch, + "http://127.0.0.1:8003/api/companies/"+companyID+"/repositories/"+repositoryID+"/roles/"+accountID, + bytes.NewReader(account.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "update user in repository error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "update user in repository error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} +func RemoveUserInRepository(t *testing.T, bearerToken, companyID, repositoryID, accountID string) { + fmt.Println("Running test for RemoveUserInRepository") + req, _ := http.NewRequest( + http.MethodDelete, + "http://127.0.0.1:8003/api/companies/"+companyID+"/repositories/"+repositoryID+"/roles/"+accountID, + nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "delete user in repository error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "delete user in repository error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} diff --git a/e2e/server/http_test.go b/e2e/server/http_test.go deleted file mode 100644 index 90d12675b..000000000 --- a/e2e/server/http_test.go +++ /dev/null @@ -1,164 +0,0 @@ -package server - -import ( - "encoding/json" - "fmt" - "github.com/ZupIT/horusec/development-kit/pkg/entities/api" - "github.com/ZupIT/horusec/development-kit/pkg/utils/test" - "github.com/stretchr/testify/assert" - "os" - "testing" - - accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" - "github.com/ZupIT/horusec/development-kit/pkg/utils/env" - "github.com/ZupIT/horusec/development-kit/pkg/utils/logger" - "github.com/golang-migrate/migrate/v4" - _ "github.com/golang-migrate/migrate/v4/database/postgres" - _ "github.com/golang-migrate/migrate/v4/source/file" -) - -func TestMain(m *testing.M) { - migration, err := migrate.New( - "file://../../development-kit/pkg/databases/relational/migration", - env.GetEnvOrDefault("HORUSEC_DATABASE_SQL_URI", "postgresql://root:root@localhost:5432/horusec_db?sslmode=disable"), - ) - if err != nil { - logger.LogPanic("Error in create instance migration: ", err) - } - - if err := migration.Down(); err != nil { - if err.Error() != "no change" { - logger.LogPanic("Error in down migration: ", err) - } - } - if err := migration.Up(); err != nil { - if err.Error() != "no change" { - logger.LogPanic("Error in down migration: ", err) - } - } - code := m.Run() - os.Exit(code) -} - -func TestServer(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test") - } - t.Run("Should tests default auth-type (horusec) http requests", func(t *testing.T) { - CreateAccount(t, &accountentities.Account{ - Email: "e2e@example.com", - Password: "Ch@ng3m3", - Username: "e2e_user", - }) - bearerToken, _ := Login(t, &accountentities.LoginData{ - Email: "e2e@example.com", - Password: "Ch@ng3m3", - }) - companyID := RunCompanyCRUD(t, bearerToken) - repositoryID := RunRepositoryCRUD(t, bearerToken, companyID) - repositoryToken := RunRepositoryTokenCRUD(t, bearerToken, companyID, repositoryID) - _ = InsertAnalysisWithRepositoryToken(t, &api.AnalysisData{ - Analysis: test.CreateAnalysisMock(), - }, repositoryToken) - RunDashboardByCompany(t, bearerToken, companyID) - RunDashboardByRepository(t, bearerToken, companyID, repositoryID) - Logout(t, bearerToken) - }) - fmt.Println("All tests was finished in server test") -} - -func RunDashboardByCompany(t *testing.T, bearerToken, companyID string) { - bodyAllVulnerabilities := GetChartContent(t, "all-vulnerabilities", bearerToken, companyID, "") - bodyAllVulnerabilitiesString := string(bodyAllVulnerabilities) - assert.NotEmpty(t, bodyAllVulnerabilitiesString) - - bodyVulnerabilitiesByAuthor := GetChartContent(t, "vulnerabilities-by-author", bearerToken, companyID, "") - bodyVulnerabilitiesByAuthorString := string(bodyVulnerabilitiesByAuthor) - assert.NotEmpty(t, bodyVulnerabilitiesByAuthorString) - - bodyVulnerabilitiesByLanguage := GetChartContent(t, "vulnerabilities-by-language", bearerToken, companyID, "") - bodyVulnerabilitiesByLanguageString := string(bodyVulnerabilitiesByLanguage) - assert.NotEmpty(t, bodyVulnerabilitiesByLanguageString) - - bodyVulnerabilitiesByRepository := GetChartContent(t, "vulnerabilities-by-repository", bearerToken, companyID, "") - bodyVulnerabilitiesByRepositoryString := string(bodyVulnerabilitiesByRepository) - assert.NotEmpty(t, bodyVulnerabilitiesByRepositoryString) - - bodyVulnerabilitiesByTime := GetChartContent(t, "vulnerabilities-by-time", bearerToken, companyID, "") - bodyVulnerabilitiesByTimeString := string(bodyVulnerabilitiesByTime) - assert.NotEmpty(t, bodyVulnerabilitiesByTimeString) - - bodyTotalDevelopers := GetChartContent(t, "total-developers", bearerToken, companyID, "") - bodyTotalDevelopersString := string(bodyTotalDevelopers) - assert.NotEmpty(t, bodyTotalDevelopersString) - - bodyTotalRepositories := GetChartContent(t, "total-repositories", bearerToken, companyID, "") - bodyTotalRepositoriesString := string(bodyTotalRepositories) - assert.NotEmpty(t, bodyTotalRepositoriesString) - - bodyDetailsChart := GetChartDetailsUsingGraphQLAndReturnBody(t, bearerToken, companyID, "") - bodyDetailsChartString := string(bodyDetailsChart) - assert.NotEmpty(t, bodyDetailsChartString) -} - -func RunDashboardByRepository(t *testing.T, bearerToken, companyID, repositoryID string) { - bodyAllVulnerabilities := GetChartContent(t, "all-vulnerabilities", bearerToken, companyID, repositoryID) - bodyAllVulnerabilitiesString := string(bodyAllVulnerabilities) - assert.NotEmpty(t, bodyAllVulnerabilitiesString) - - bodyVulnerabilitiesByAuthor := GetChartContent(t, "vulnerabilities-by-author", bearerToken, companyID, repositoryID) - bodyVulnerabilitiesByAuthorString := string(bodyVulnerabilitiesByAuthor) - assert.NotEmpty(t, bodyVulnerabilitiesByAuthorString) - - bodyVulnerabilitiesByLanguage := GetChartContent(t, "vulnerabilities-by-language", bearerToken, companyID, repositoryID) - bodyVulnerabilitiesByLanguageString := string(bodyVulnerabilitiesByLanguage) - assert.NotEmpty(t, bodyVulnerabilitiesByLanguageString) - - bodyVulnerabilitiesByRepository := GetChartContent(t, "vulnerabilities-by-repository", bearerToken, companyID, repositoryID) - bodyVulnerabilitiesByRepositoryString := string(bodyVulnerabilitiesByRepository) - assert.NotEmpty(t, bodyVulnerabilitiesByRepositoryString) - - bodyVulnerabilitiesByTime := GetChartContent(t, "vulnerabilities-by-time", bearerToken, companyID, repositoryID) - bodyVulnerabilitiesByTimeString := string(bodyVulnerabilitiesByTime) - assert.NotEmpty(t, bodyVulnerabilitiesByTimeString) - - bodyTotalDevelopers := GetChartContent(t, "total-developers", bearerToken, companyID, repositoryID) - bodyTotalDevelopersString := string(bodyTotalDevelopers) - assert.NotEmpty(t, bodyTotalDevelopersString) - - bodyTotalRepositories := GetChartContent(t, "total-repositories", bearerToken, companyID, repositoryID) - bodyTotalRepositoriesString := string(bodyTotalRepositories) - assert.NotEmpty(t, bodyTotalRepositoriesString) - - bodyDetailsChart := GetChartDetailsUsingGraphQLAndReturnBody(t, bearerToken, companyID, repositoryID) - bodyDetailsChartString := string(bodyDetailsChart) - assert.NotEmpty(t, bodyDetailsChartString) -} - -func RunCompanyCRUD(t *testing.T, bearerToken string) string { - companyID := CreateCompany(t, bearerToken, &accountentities.Company{ - Name: "zup", - }) - _ = ReadAllCompanies(t, bearerToken) - UpdateCompany(t, bearerToken, companyID, &accountentities.Company{ - Name: "zup-1", - }) - allCompaniesUpdated := ReadAllCompanies(t, bearerToken) - allCompaniesBytes, _ := json.Marshal(allCompaniesUpdated) - assert.Contains(t, string(allCompaniesBytes), "zup-1") - DeleteCompany(t, bearerToken, companyID) - return CreateCompany(t, bearerToken, &accountentities.Company{ - Name: "zup", - }) -} - -func RunRepositoryCRUD(t *testing.T, bearerToken, companyID string) string { - repositoryID := CreateRepository(t, bearerToken, companyID, &accountentities.Repository{ - Name: "horusec", - }) - return repositoryID -} - -func RunRepositoryTokenCRUD(t *testing.T, bearerToken, companyID, repositoryID string) string { - return GenerateRepositoryToken(t, bearerToken, companyID, repositoryID, api.Token{Description: "access_token"}) -} diff --git a/e2e/server/keycloak/entities/user_representation.go b/e2e/server/keycloak/entities/user_representation.go new file mode 100644 index 000000000..fe80591ed --- /dev/null +++ b/e2e/server/keycloak/entities/user_representation.go @@ -0,0 +1,27 @@ +// Entities created in this files are exclusive from keycloak e2e +package entities + +import "encoding/json" + +type UserRepresentation struct { + Username string `json:"username"` + Email string `json:"email"` + EmailVerified bool `json:"emailVerified"` + Enabled bool `json:"enabled"` +} + +type UserRepresentationCredentials struct { + Temporary bool `json:"temporary"` + Type string `json:"type"` + Value string `json:"value"` +} + +func (u *UserRepresentation) ToBytes() []byte { + content, _ := json.Marshal(u) + return content +} + +func (u *UserRepresentationCredentials) ToBytes() []byte { + content, _ := json.Marshal(u) + return content +} diff --git a/e2e/server/keycloak/http_test.go b/e2e/server/keycloak/http_test.go new file mode 100644 index 000000000..ba50a5e61 --- /dev/null +++ b/e2e/server/keycloak/http_test.go @@ -0,0 +1,211 @@ +// Test e2e refers workflow: .github/workflows/e2e.yml +// In step: e2e-server-keycloak +package keycloak + +import ( + "encoding/json" + "fmt" + accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/ZupIT/horusec/development-kit/pkg/entities/account/roles" + rolesEnum "github.com/ZupIT/horusec/development-kit/pkg/enums/account" + "github.com/ZupIT/horusec/development-kit/pkg/utils/env" + "github.com/ZupIT/horusec/development-kit/pkg/utils/logger" + "github.com/ZupIT/horusec/e2e/server" + "github.com/ZupIT/horusec/e2e/server/keycloak/entities" + "github.com/golang-migrate/migrate/v4" + _ "github.com/golang-migrate/migrate/v4/database/postgres" + _ "github.com/golang-migrate/migrate/v4/source/file" + "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "net/http" + "os" + "os/exec" + "strings" + "testing" + "time" +) + +func TestMain(m *testing.M) { + folderOfMigration := "file://../../../development-kit/pkg/databases/relational/migration" + var connectionStringDB = env.GetEnvOrDefault("HORUSEC_DATABASE_SQL_URI", "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable") + migration, err := migrate.New(folderOfMigration, connectionStringDB) + if err != nil { + logger.LogPanic("Error in create first instance migration: ", err) + } + if err := migration.Drop(); err != nil { + logger.LogPanic("Error in drop migration: ", err) + } + sourceErr, dbErr := migration.Close() + if sourceErr != nil { + logger.LogPanic("Error in source err to close connection: ", sourceErr) + } + if dbErr != nil { + logger.LogPanic("Error in database err to close connection: ", dbErr) + } + migration, err = migrate.New(folderOfMigration, connectionStringDB) + if err != nil { + logger.LogPanic("Error in create second instance migration: ", err) + } + if err := migration.Up(); err != nil { + if err.Error() != "no change" { + logger.LogPanic("Error in up migration: ", err) + } + } + code := m.Run() + os.Exit(code) +} + +func TestServer(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + t.Run("Should tests auth-type keycloak http requests", func(t *testing.T) { + time.Sleep(10 * time.Second) + user := &entities.UserRepresentation{ + Username: "e2e_user", + Email: "e2e@example.com", + EmailVerified: true, + Enabled: true, + } + credential := &entities.UserRepresentationCredentials{ + Temporary: false, + Type: "password", + Value: "Ch@ng3m3", + } + bearerToken := SetupKeycloakAndGetFirstAccessToken(t, user, credential) + assert.NotEmpty(t, bearerToken) + + CreateUserFromKeycloakInHorusec(t, &accountentities.KeycloakToken{AccessToken: bearerToken}) + + bearerToken = LoginInKeycloak(t, user.Username, credential.Value)["access_token"].(string) + + fmt.Println("Waiting register token in keycloak and register new user in horusec...") + time.Sleep(3 * time.Second) + + // TESTBOOK: Authorize + // TESTBOOK: Create, Read, Update and Delete company + companyID := RunCompanyCRUD(t, bearerToken) + assert.NotEmpty(t, companyID) + RunCRUDUserInCompany(t, bearerToken, companyID) + }) +} + +func SetupKeycloakAndGetFirstAccessToken(t *testing.T, user *entities.UserRepresentation, credential *entities.UserRepresentationCredentials) string { + responseLogin := LoginInKeycloak(t, "keycloak", "keycloak") + bearerToken := "Bearer " + responseLogin["access_token"].(string) + UpdateRolesToAcceptOAuth(t, bearerToken) + DeleteAllUsersInKeyCloak(t, bearerToken) + CreateUserInKeyCloak(t, user, credential, bearerToken) + secret := GetClientSecretInAccountClient(t, bearerToken) + assert.NotEmpty(t, secret) + StartAuthHorusecServices(t, secret) + responseLogin = LoginInKeycloak(t, user.Username, credential.Value) + return responseLogin["access_token"].(string) +} + +func StartAuthHorusecServices(t *testing.T, secret string) { + fmt.Println("Starting auth horusec service...") + output, err := exec.Command("whereis", "docker-compose").Output() + assert.NoError(t, err) + assert.NotEmpty(t, output) + pathComposeSplited := strings.Split(string(output), "docker-compose: ") + assert.Len(t, pathComposeSplited, 2) + pathCompose := pathComposeSplited[1][0 : len(pathComposeSplited[1])-1] + cmd := exec.Command(pathCompose, "-f", "../../deployments/docker-compose.server.keycloak.yaml", "up", "-d", "--build", "horusec-auth") + cmd.Env = append(cmd.Env, "HORUSEC_KEYCLOAK_CLIENT_SECRET="+secret) + output, err = cmd.CombinedOutput() + assert.NoError(t, err) + assert.NotEmpty(t, output) + fmt.Println("Waiting container up...") + time.Sleep(3 * time.Second) +} + +func RunCompanyCRUD(t *testing.T, bearerToken string) string { + t.Run("Should create an company, check if it exists, update your name check if name was updated delete a company and return new company to manager in other steps", func(t *testing.T) { + companyID := server.CreateCompany(t, bearerToken, &accountentities.Company{ + Name: "zup", + }) + allCompanies := server.ReadAllCompanies(t, bearerToken, true) + assert.Contains(t, allCompanies, "zup") + server.UpdateCompany(t, bearerToken, companyID, &accountentities.Company{ + Name: "zup-1", + }) + allCompaniesUpdated := server.ReadAllCompanies(t, bearerToken, true) + assert.Contains(t, allCompaniesUpdated, "zup-1") + server.DeleteCompany(t, bearerToken, companyID) + }) + return server.CreateCompany(t, bearerToken, &accountentities.Company{ + Name: "zup", + }) +} + +func RunCRUDUserInCompany(t *testing.T, bearerTokenAccount1, companyID string) { + t.Run("Should create new user and invite to existing company with permission of the member after update your permission to admin and check if is enable view dashboard by company and remove user from company", func(t *testing.T) { + companyIDParsed, _ := uuid.Parse(companyID) + + // Add new user to invite + user := &entities.UserRepresentation{ + Username: "e2e_user_2", + Email: "e2e_2@example.com", + EmailVerified: true, + Enabled: true, + } + credential := &entities.UserRepresentationCredentials{ + Temporary: false, + Type: "password", + Value: "Ch@ng3m3", + } + responseLoginAdmin := LoginInKeycloak(t, "keycloak", "keycloak") + CreateUserInKeyCloak(t, user, credential, "Bearer "+responseLoginAdmin["access_token"].(string)) + responseLoginNewUser := LoginInKeycloak(t, user.Username, credential.Value) + bearerTokenAccount2 := responseLoginNewUser["access_token"].(string) + CreateUserFromKeycloakInHorusec(t, &accountentities.KeycloakToken{AccessToken: bearerTokenAccount2}) + fmt.Println("Waiting register token in keycloak and register new user in horusec...") + time.Sleep(3 * time.Second) + // Invite user to existing company + server.InviteUserToCompany(t, bearerTokenAccount1, companyID, &accountentities.InviteUser{ + Role: rolesEnum.Member, + Email: user.Email, + CompanyID: companyIDParsed, + }) + + // Check if exist two users in company + allUsersInCompany := server.ReadAllUserInCompany(t, bearerTokenAccount1, companyID) + accountRoles := []roles.AccountRole{} + assert.NoError(t, json.Unmarshal([]byte(allUsersInCompany), &accountRoles)) + assert.NotEmpty(t, accountRoles) + assert.Equal(t, 2, len(accountRoles)) + accountID := "" + for _, currentUser := range accountRoles { + if currentUser.Email == user.Email { + accountID = currentUser.AccountID.String() + } + } + assert.NotEmpty(t, accountID) + + // Check if company exists to new user + allCompanies := server.ReadAllCompanies(t, bearerTokenAccount2, true) + assert.Contains(t, allCompanies, "zup") + + // Expected return unauthorized because user is not admin of company to see dashboard in company view + responseChart := server.GetChartContentWithoutTreatment(t, "total-repositories", bearerTokenAccount2, companyID, "") + assert.Equal(t, http.StatusUnauthorized, responseChart.GetStatusCode()) + + // Update permission of new user to admin + server.UpdateUserInCompany(t, bearerTokenAccount1, companyID, accountID, &roles.AccountCompany{ + Role: rolesEnum.Admin, + }) + time.Sleep(1 * time.Second) + + // Expected return OK because user is authorized view dashboard in company view + responseChart = server.GetChartContentWithoutTreatment(t, "total-repositories", bearerTokenAccount2, companyID, "") + assert.Equal(t, http.StatusOK, responseChart.GetStatusCode()) + + // Expected remove user from company + server.RemoveUserInCompany(t, bearerTokenAccount1, companyID, accountID) + + // Not show company for user when get all companies + allCompanies = server.ReadAllCompanies(t, bearerTokenAccount2, false) + assert.NotContains(t, allCompanies, "zup") + }) +} diff --git a/e2e/server/keycloak/requests.go b/e2e/server/keycloak/requests.go new file mode 100644 index 000000000..5a6df07f5 --- /dev/null +++ b/e2e/server/keycloak/requests.go @@ -0,0 +1,233 @@ +// Requests save in this file are exclusive of keycloak e2e +package keycloak + +import ( + "bytes" + "encoding/json" + "fmt" + "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/ZupIT/horusec/e2e/server/keycloak/entities" + "github.com/stretchr/testify/assert" + "net/http" + "strings" + "testing" +) + +func LoginInKeycloak(t *testing.T, username, password string) map[string]interface{} { + fmt.Println("Running test for LoginInKeycloak") + payload := strings.NewReader(fmt.Sprintf("client_id=admin-cli&username=%s&password=%s&grant_type=password", username, password)) + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/token", payload) + req.Header.Add("content-type", "application/x-www-form-urlencoded") + req.Header.Add("cache-control", "no-cache") + + res, _ := http.DefaultClient.Do(req) + assert.Equal(t, http.StatusOK, res.StatusCode, "LoginInKeycloak error send request") + var response map[string]interface{} + _ = json.NewDecoder(res.Body).Decode(&response) + assert.NoError(t, res.Body.Close()) + assert.NotEmpty(t, response) + return response +} + +func CreateUserInKeyCloak(t *testing.T, userRepresentation *entities.UserRepresentation, credentials *entities.UserRepresentationCredentials, bearerToken string) { + fmt.Println("Running test for CreateUserInKeyCloak") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8080/auth/admin/realms/master/users", bytes.NewReader(userRepresentation.ToBytes())) + req.Header.Add("Authorization", bearerToken) + req.Header.Add("content-type", "application/json") + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "CreateUserInKeyCloak, create user error mount request") + assert.Equal(t, http.StatusCreated, resp.StatusCode, "CreateUserInKeyCloak create user error send request") + assert.NoError(t, resp.Body.Close()) + allUsers := ListAllUsersInKeycloak(t, bearerToken) + idToSetCredential := "" + for _, user := range allUsers { + if user["username"] == userRepresentation.Username { + idToSetCredential = user["id"].(string) + } + } + assert.NotEmpty(t, idToSetCredential) + req, _ = http.NewRequest(http.MethodPut, "http://127.0.0.1:8080/auth/admin/realms/master/users/"+idToSetCredential+"/reset-password", bytes.NewReader(credentials.ToBytes())) + req.Header.Add("Authorization", bearerToken) + req.Header.Add("content-type", "application/json") + httpClient = http.Client{} + resp, err = httpClient.Do(req) + assert.NoError(t, err, "CreateUserInKeyCloak, update credentials user error mount request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "CreateUserInKeyCloak update credentials user error send request") + assert.NoError(t, resp.Body.Close()) + + role := GetRoleAdminInKeycloak(t, bearerToken) + var allRoles []map[string]interface{} + allRoles = append(allRoles, role) + allRolesBytes, _ := json.Marshal(allRoles) + req, _ = http.NewRequest(http.MethodPost, "http://127.0.0.1:8080/auth/admin/realms/master/users/"+idToSetCredential+"/role-mappings/realm", bytes.NewReader(allRolesBytes)) + req.Header.Add("Authorization", bearerToken) + req.Header.Add("content-type", "application/json") + httpClient = http.Client{} + resp, err = httpClient.Do(req) + assert.NoError(t, err, "CreateUserInKeyCloak, update role mapping user error mount request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "CreateUserInKeyCloak, update role mapping user error send request") + assert.NoError(t, resp.Body.Close()) +} + +func ListAllUsersInKeycloak(t *testing.T, bearerToken string) []map[string]interface{} { + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/auth/admin/realms/master/users", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "DeleteAllUsersInKeyCloak: get all users error mount request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "DeleteAllUsersInKeyCloak: get all users error send request") + var response []map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&response) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, response) + return response +} + +func DeleteAllUsersInKeyCloak(t *testing.T, bearerToken string) { + fmt.Println("Running test for DeleteAllUsersInKeyCloak") + allUsers := ListAllUsersInKeycloak(t, bearerToken) + idsToRemove := []string{} + for _, user := range allUsers { + if user["username"] != "keycloak" { + idsToRemove = append(idsToRemove, user["id"].(string)) + } + } + assert.Equal(t, len(allUsers)-1, len(idsToRemove)) + for _, id := range idsToRemove { + req, _ := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8080/auth/admin/realms/master/users/"+id, nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "DeleteAllUsersInKeyCloak: remove user of id: "+id+" error mount request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "DeleteAllUsersInKeyCloak: remove user of id: "+id+" error send request") + } +} + +func GetClientSecretInAccountClient(t *testing.T, bearerToken string) string { + fmt.Println("Running test for GetClientSecretInAccountClient") + allClients := ListAllClientsInKeycloak(t, bearerToken) + clientID := "" + for _, client := range allClients { + if client["clientId"] == "account" { + clientID = client["id"].(string) + } + } + assert.NotEmpty(t, clientID) + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/auth/admin/realms/master/clients/"+clientID+"/client-secret", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "GetClientSecretInAccountClient mount request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "GetClientSecretInAccountClient error send request") + var response map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&response) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, response) + return response["value"].(string) +} + +func UpdateRolesToAcceptOAuth(t *testing.T, bearerToken string) { + fmt.Println("Running test for UpdateRolesToAcceptOAuth") + allClients := ListAllClientsInKeycloak(t, bearerToken) + var client map[string]interface{} + for _, actualClient := range allClients { + if actualClient["clientId"] == "account" { + client = actualClient + } + } + assert.NotEmpty(t, client) + client["authorizationServicesEnabled"] = true + client["directAccessGrantsEnabled"] = true + client["enabled"] = true + client["implicitFlowEnabled"] = true + client["serviceAccountsEnabled"] = true + client["standardFlowEnabled"] = true + client["surrogateAuthRequired"] = true + clientID := client["id"].(string) + clientBytes, _ := json.Marshal(client) + req, _ := http.NewRequest(http.MethodPut, "http://127.0.0.1:8080/auth/admin/realms/master/clients/"+clientID, bytes.NewReader(clientBytes)) + req.Header.Add("Authorization", bearerToken) + req.Header.Add("content-type", "application/json") + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "UpdateRolesToAcceptOAuth, update account client content error mount request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "UpdateRolesToAcceptOAuth, update account client error send request") + assert.NoError(t, resp.Body.Close()) + + // Update Role to admin accept all content + role := GetRoleAdminInKeycloak(t, bearerToken) + roleID := role["id"].(string) + allRoles := GetAllRolesFromClientID(t, bearerToken, clientID) + allRolesBytes, _ := json.Marshal(allRoles) + req, _ = http.NewRequest(http.MethodPost, "http://127.0.0.1:8080/auth/admin/realms/master/roles-by-id/"+roleID+"/composites", bytes.NewReader(allRolesBytes)) + req.Header.Add("Authorization", bearerToken) + req.Header.Add("content-type", "application/json") + httpClient = http.Client{} + resp, err = httpClient.Do(req) + assert.NoError(t, err, "UpdateRolesToAcceptOAuth, update account client content error mount request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "UpdateRolesToAcceptOAuth, update account client error send request") + assert.NoError(t, resp.Body.Close()) +} + +func ListAllClientsInKeycloak(t *testing.T, bearerToken string) []map[string]interface{} { + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/auth/admin/realms/master/clients", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "ListAllClientsInKeycloak mount request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "ListAllClientsInKeycloak error send request") + var response []map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&response) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, response) + return response +} + +func GetRoleAdminInKeycloak(t *testing.T, bearerToken string) map[string]interface{} { + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/auth/admin/realms/master/roles", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "ListAllRolesInKeycloak mount request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "ListAllRolesInKeycloak error send request") + var response []map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&response) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, response) + var role map[string]interface{} + for _, currentRole := range response { + if currentRole["name"] == "admin" { + role = currentRole + } + } + assert.NotEmpty(t, role) + return role +} + +func GetAllRolesFromClientID(t *testing.T, bearerToken, clientID string) []map[string]interface{} { + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/auth/admin/realms/master/clients/"+clientID+"/roles", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "ListAllRolesInKeycloak mount request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "ListAllRolesInKeycloak error send request") + var response []map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&response) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, response) + return response +} + +func CreateUserFromKeycloakInHorusec(t *testing.T, token *account.KeycloakToken) { + fmt.Println("Running test for CreateUserFromKeycloakInHorusec") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8006/api/account/create-account-from-keycloak", bytes.NewReader(token.ToBytes())) + httpClient := http.Client{} + createCompanyResp, err := httpClient.Do(req) + assert.NoError(t, err, "CreateUserFromKeycloakInHorusec error send request") + assert.Equal(t, http.StatusOK, createCompanyResp.StatusCode, "CreateUserFromKeycloakInHorusec error check response") + var bodyResponse map[string]interface{} + _ = json.NewDecoder(createCompanyResp.Body).Decode(&bodyResponse) + assert.NoError(t, createCompanyResp.Body.Close()) + assert.NotEmpty(t, bodyResponse) +} diff --git a/e2e/server/ldap/http_test.go b/e2e/server/ldap/http_test.go new file mode 100644 index 000000000..fc363d573 --- /dev/null +++ b/e2e/server/ldap/http_test.go @@ -0,0 +1,3 @@ +// Test e2e refers workflow: .github/workflows/e2e.yml +// In step: e2e-server-ldap +package ldap diff --git a/e2e/server/messages/messages_test.go b/e2e/server/messages/messages_test.go new file mode 100644 index 000000000..b415b7a8f --- /dev/null +++ b/e2e/server/messages/messages_test.go @@ -0,0 +1,94 @@ +// Test e2e refers workflow: .github/workflows/e2e.yml +// In step: e2e-messages +package messages + +import ( + "github.com/ZupIT/horusec/development-kit/pkg/databases/relational/adapter" + "github.com/ZupIT/horusec/development-kit/pkg/utils/test" + "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "net/http" + "os" + "testing" + + accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/ZupIT/horusec/development-kit/pkg/utils/env" + "github.com/ZupIT/horusec/development-kit/pkg/utils/logger" + "github.com/golang-migrate/migrate/v4" + _ "github.com/golang-migrate/migrate/v4/database/postgres" + _ "github.com/golang-migrate/migrate/v4/source/file" +) + +func TestMain(m *testing.M) { + folderOfMigration := "file://../../../development-kit/pkg/databases/relational/migration" + connectionStringDB := env.GetEnvOrDefault("HORUSEC_DATABASE_SQL_URI", "postgresql://root:root@127.0.0.1:5432/horusec_db?sslmode=disable") + migration, err := migrate.New(folderOfMigration, connectionStringDB) + if err != nil { + logger.LogPanic("Error in create first instance migration: ", err) + } + if err := migration.Drop(); err != nil { + logger.LogPanic("Error in drop migration: ", err) + } + sourceErr, dbErr := migration.Close() + if sourceErr != nil { + logger.LogPanic("Error in source err to close connection: ", sourceErr) + } + if dbErr != nil { + logger.LogPanic("Error in database err to close connection: ", dbErr) + } + migration, err = migrate.New(folderOfMigration, connectionStringDB) + if err != nil { + logger.LogPanic("Error in create second instance migration: ", err) + } + if err := migration.Up(); err != nil { + if err.Error() != "no change" { + logger.LogPanic("Error in up migration: ", err) + } + } + code := m.Run() + os.Exit(code) +} + +func TestMessages(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + t.Run("Should run analysis and check if messages are dispatch correctly", func(t *testing.T) { + accountToCreate := &accountentities.Account{ + Email: "e2e@example.com", + Password: "Ch@ng3m3", + Username: "e2e_user", + } + // Create account + CreateAccount(t, accountToCreate) + + // When try login without confirm account return unauthorized + loginResp := Login(t, &accountentities.LoginData{ + Email: "e2e@example.com", + Password: "Ch@ng3m3", + }) + assert.Equal(t, http.StatusForbidden, loginResp.GetStatusCode()) + + // Get Last account created in database + accountCreated := GetLastAccountCreated(t) + + // Confirm account in database + ValidateAccount(t, accountCreated.AccountID.String()) + + // Check if is possible login now + bearerToken := LoginAndReturnAccessToken(t, &accountentities.LoginData{ + Email: "e2e@example.com", + Password: "Ch@ng3m3", + }) + Logout(t, bearerToken) + }) +} + +func GetLastAccountCreated(t *testing.T) (accountCreated accountentities.Account) { + dbRead := adapter.NewRepositoryRead() + sqlUtil := test.NewSQLUtil(dbRead) + sqlUtil.GetLast(&accountCreated) + assert.NotEmpty(t, accountCreated) + assert.NotEqual(t, accountCreated.AccountID, uuid.Nil) + return accountCreated +} diff --git a/e2e/server/messages/requests.go b/e2e/server/messages/requests.go new file mode 100644 index 000000000..600163a02 --- /dev/null +++ b/e2e/server/messages/requests.go @@ -0,0 +1,114 @@ +// Requests save in this file are exclusive of messages e2e +package messages + +import ( + "bytes" + "crypto/tls" + "encoding/json" + "fmt" + accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/client" + httpResponse "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/response" + "github.com/stretchr/testify/assert" + "net/http" + "strings" + "testing" +) + +func CreateAccount(t *testing.T, account *accountentities.Account) { + fmt.Println("Running test for CreateAccount") + createAccountResp, err := http.Post("http://127.0.0.1:8003/api/account/create-account", "text/json", bytes.NewReader(account.ToBytes())) + assert.NoError(t, err, "create account error mount request") + assert.Equal(t, http.StatusCreated, createAccountResp.StatusCode, "create account error send request") + + var createAccountResponse map[string]interface{} + _ = json.NewDecoder(createAccountResp.Body).Decode(&createAccountResponse) + assert.NoError(t, createAccountResp.Body.Close()) + assert.NotEmpty(t, createAccountResponse["content"]) +} + +func Login(t *testing.T, credentials *accountentities.LoginData) httpResponse.Interface { + fmt.Println("Running test for Login") + req, _ := http.NewRequest( + http.MethodPost, + "http://127.0.0.1:8003/api/account/login", + bytes.NewReader(credentials.ToBytes())) + res, err := client.NewHTTPClient(15).DoRequest(req, &tls.Config{}) + assert.NoError(t, err) + return res +} +func LoginAndReturnAccessToken(t *testing.T, credentials *accountentities.LoginData) string { + fmt.Println("Running test for Login") + loginResp, err := http.Post( + "http://127.0.0.1:8003/api/account/login", + "text/json", + bytes.NewReader(credentials.ToBytes()), + ) + assert.NoError(t, err, "login, error mount request") + assert.Equal(t, http.StatusOK, loginResp.StatusCode, "login error send request") + + var loginResponse map[string]map[string]string + _ = json.NewDecoder(loginResp.Body).Decode(&loginResponse) + assert.NoError(t, loginResp.Body.Close()) + return loginResponse["content"]["accessToken"] +} +func ValidateAccount(t *testing.T, accountID string) { + fmt.Println("Running test for ValidateAccount") + req, _ := http.NewRequest( + http.MethodGet, + "http://127.0.0.1:8003/api/account/validate/"+accountID, + nil) + res, err := client.NewHTTPClient(15).DoRequest(req, &tls.Config{}) + if err != nil { + if !strings.Contains(err.Error(), "Get \"http://127.0.0.1:8043\": ") { + assert.NoError(t, err) + } + } else { + assert.Equal(t, http.StatusSeeOther, res.GetStatusCode()) + } +} + +func Logout(t *testing.T, bearerToken string) { + fmt.Println("Running test for Logout") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8003/api/account/logout", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "logout error mount request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "logout error send request") + + var logoutResponse map[string]map[string]string + _ = json.NewDecoder(resp.Body).Decode(&logoutResponse) + assert.NoError(t, resp.Body.Close()) +} + +func CreateCompany(t *testing.T, bearerToken string, company *accountentities.Company) (CompanyID string) { + fmt.Println("Running test for CreateCompany") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8003/api/companies", bytes.NewReader(company.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + createCompanyResp, err := httpClient.Do(req) + assert.NoError(t, err, "create company error send request") + assert.Equal(t, http.StatusCreated, createCompanyResp.StatusCode, "create company error check response") + var createdCompany map[string]map[string]string + _ = json.NewDecoder(createCompanyResp.Body).Decode(&createdCompany) + assert.NoError(t, createCompanyResp.Body.Close()) + assert.NotEmpty(t, createdCompany["content"]["companyID"]) + return createdCompany["content"]["companyID"] +} + +func InviteUserToCompany(t *testing.T, bearerToken, companyID string, user *accountentities.InviteUser) { + fmt.Println("Running test for InviteUserToCompany") + req, _ := http.NewRequest( + http.MethodPost, + "http://127.0.0.1:8003/api/companies/"+companyID+"/roles", + bytes.NewReader(user.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "invite user error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "invite user error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} diff --git a/e2e/server/requests.go b/e2e/server/requests.go deleted file mode 100644 index 20981c90e..000000000 --- a/e2e/server/requests.go +++ /dev/null @@ -1,256 +0,0 @@ -package server - -import ( - "bytes" - "crypto/tls" - "encoding/json" - "fmt" - accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" - "github.com/ZupIT/horusec/development-kit/pkg/entities/api" - "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/client" - "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/request" - "github.com/stretchr/testify/assert" - "net/http" - "strings" - "testing" - "time" -) - -func CreateAccount(t *testing.T, account *accountentities.Account) { - fmt.Println("Running test for CreateAccount") - createAccountResp, err := http.Post("http://localhost:8003/api/account/create-account", "text/json", bytes.NewReader(account.ToBytes())) - assert.NoError(t, err, "create account error mount request") - assert.Equal(t, http.StatusCreated, createAccountResp.StatusCode, "create account error send request") - - var createAccountResponse map[string]interface{} - _ = json.NewDecoder(createAccountResp.Body).Decode(&createAccountResponse) - assert.NoError(t, createAccountResp.Body.Close()) - assert.NotEmpty(t, createAccountResponse["content"]) -} - -func ValidateAccount(t *testing.T, accountID string) { - validateAccountResp, err := http.Get("http://localhost:8003/api/account/validate/" + accountID) - if err != nil { - assert.Contains(t, err.Error(), "Get \"http://localhost:8043\": ") - } else { - assert.NoError(t, err, "validate account, error mount request") - assert.Equal(t, http.StatusOK, validateAccountResp.StatusCode, "validate account, error send request") - assert.NoError(t, validateAccountResp.Body.Close()) - } -} - -func Login(t *testing.T, credentials *accountentities.LoginData) (bearerToken string, refreshToken string) { - fmt.Println("Running test for Login") - loginResp, err := http.Post( - "http://localhost:8003/api/account/login", - "text/json", - bytes.NewReader(credentials.ToBytes()), - ) - assert.NoError(t, err, "login, error mount request") - assert.Equal(t, http.StatusOK, loginResp.StatusCode, "login error send request") - - var loginResponse map[string]map[string]string - _ = json.NewDecoder(loginResp.Body).Decode(&loginResponse) - assert.NoError(t, loginResp.Body.Close()) - bearerToken = "Bearer " + loginResponse["content"]["accessToken"] - refreshToken = loginResponse["content"]["refreshToken"] - return bearerToken, refreshToken -} - -func Logout(t *testing.T, bearerToken string) { - fmt.Println("Running test for Logout") - req, _ := http.NewRequest(http.MethodPost, "http://localhost:8003/api/account/logout", nil) - req.Header.Add("Authorization", bearerToken) - httpClient := http.Client{} - resp, err := httpClient.Do(req) - assert.NoError(t, err, "logout error mount request") - assert.Equal(t, http.StatusNoContent, resp.StatusCode, "logout error send request") - - var logoutResponse map[string]map[string]string - _ = json.NewDecoder(resp.Body).Decode(&logoutResponse) - assert.NoError(t, resp.Body.Close()) -} - -func CreateCompany(t *testing.T, bearerToken string, company *accountentities.Company) (CompanyID string) { - fmt.Println("Running test for CreateCompany") - req, _ := http.NewRequest(http.MethodPost, "http://localhost:8003/api/companies", bytes.NewReader(company.ToBytes())) - req.Header.Add("Authorization", bearerToken) - httpClient := http.Client{} - createCompanyResp, err := httpClient.Do(req) - assert.NoError(t, err, "create company error send request") - assert.Equal(t, http.StatusCreated, createCompanyResp.StatusCode, "create company error check response") - var createdCompany map[string]map[string]string - _ = json.NewDecoder(createCompanyResp.Body).Decode(&createdCompany) - assert.NoError(t, createCompanyResp.Body.Close()) - assert.NotEmpty(t, createdCompany["content"]["companyID"]) - return createdCompany["content"]["companyID"] -} - -func UpdateCompany(t *testing.T, bearerToken string, companyID string, company *accountentities.Company) { - fmt.Println("Running test for UpdateCompany") - req, _ := http.NewRequest(http.MethodPatch, "http://localhost:8003/api/companies/"+companyID, bytes.NewReader(company.ToBytes())) - req.Header.Add("Authorization", bearerToken) - httpClient := http.Client{} - resp, err := httpClient.Do(req) - assert.NoError(t, err, "update company error send request") - assert.Equal(t, http.StatusOK, resp.StatusCode, "update company error check response") - var body map[string]interface{} - _ = json.NewDecoder(resp.Body).Decode(&body) - assert.NoError(t, resp.Body.Close()) - assert.NotEmpty(t, body["content"]) -} - -func ReadAllCompanies(t *testing.T, bearerToken string) interface{} { - fmt.Println("Running test for ReadAllCompanies") - req, _ := http.NewRequest(http.MethodGet, "http://localhost:8003/api/companies", nil) - req.Header.Add("Authorization", bearerToken) - httpClient := http.Client{} - resp, err := httpClient.Do(req) - assert.NoError(t, err, "read all companies error send request") - assert.Equal(t, http.StatusOK, resp.StatusCode, "read all companies error check response") - var body map[string]interface{} - _ = json.NewDecoder(resp.Body).Decode(&body) - assert.NoError(t, resp.Body.Close()) - assert.NotEmpty(t, body["content"]) - return body["content"] -} - -func DeleteCompany(t *testing.T, bearerToken, companyID string) { - fmt.Println("Running test for DeleteCompany") - req, _ := http.NewRequest(http.MethodDelete, "http://localhost:8003/api/companies/"+companyID, nil) - req.Header.Add("Authorization", bearerToken) - httpClient := http.Client{} - resp, err := httpClient.Do(req) - assert.NoError(t, err, "delete company error send request") - assert.Equal(t, http.StatusNoContent, resp.StatusCode, "delete company error check response") - var body map[string]interface{} - _ = json.NewDecoder(resp.Body).Decode(&body) - assert.NoError(t, resp.Body.Close()) -} - -func CreateRepository(t *testing.T, bearerToken, companyID string, repository *accountentities.Repository) string { - repositoryBytes, _ := json.Marshal(repository) - fmt.Println("Running test for CreateRepository") - req, _ := http.NewRequest(http.MethodPost, "http://localhost:8003/api/companies/"+companyID+"/repositories", bytes.NewReader(repositoryBytes)) - req.Header.Add("Authorization", bearerToken) - httpClient := http.Client{} - resp, err := httpClient.Do(req) - assert.NoError(t, err, "create repository error send request") - assert.Equal(t, http.StatusCreated, resp.StatusCode, "create repository error check response") - var body map[string]map[string]string - _ = json.NewDecoder(resp.Body).Decode(&body) - assert.NoError(t, resp.Body.Close()) - assert.NotEmpty(t, body["content"]["repositoryID"]) - return body["content"]["repositoryID"] -} - -func GenerateRepositoryToken(t *testing.T, bearerToken, companyID, repositoryID string, token api.Token) string { - fmt.Println("Running test for GenerateRepositoryToken") - req, _ := http.NewRequest( - http.MethodPost, - "http://localhost:8000/api/companies/"+companyID+"/repositories/"+repositoryID+"/tokens", - bytes.NewReader(token.ToBytes()), - ) - req.Header.Add("Authorization", bearerToken) - httpClient := http.Client{} - apiTokenResp, err := httpClient.Do(req) - assert.NoError(t, err, "API token error send response") - assert.Equal(t, http.StatusCreated, apiTokenResp.StatusCode, "API token error check response") - - var apiToken map[string]string - _ = json.NewDecoder(apiTokenResp.Body).Decode(&apiToken) - assert.NoError(t, apiTokenResp.Body.Close()) - assert.NotEmpty(t, apiToken["content"]) - return apiToken["content"] -} - -func InsertAnalysisWithRepositoryToken(t *testing.T, analysisData *api.AnalysisData, repositoryToken string) string { - fmt.Println("Running test for InsertAnalysisWithRepositoryToken") - req, _ := http.NewRequest( - http.MethodPost, - "http://localhost:8000/api/analysis", - bytes.NewReader(analysisData.ToBytes()), - ) - req.Header.Add("Authorization", repositoryToken) - httpClient := http.Client{} - resp, err := httpClient.Do(req) - assert.NoError(t, err, "InsertAnalysisWithRepositoryToken error send response") - assert.Equal(t, http.StatusCreated, resp.StatusCode, "InsertAnalysisWithRepositoryToken error check response") - - var body map[string]string - _ = json.NewDecoder(resp.Body).Decode(&body) - assert.NoError(t, resp.Body.Close()) - assert.NotEmpty(t, body["content"]) - return body["content"] -} - -func GetChartContent(t *testing.T, route, bearerToken, companyID, repositoryID string) []byte { - fmt.Println("Running test for GetChartContent in route: " + route) - fmt.Println("Running test for GetChartRESTContentAndReturnBody") - now := time.Now() - initialDateStr := now.Format("2006-01-02") + "T00:00:00Z" - finalDateStr := now.Format("2006-01-02") + "T23:59:59Z" - URL := fmt.Sprintf("http://localhost:8005/api/dashboard/companies/%s/%s?initialDate=%s&finalDate=%s", companyID, route, initialDateStr, finalDateStr) - if repositoryID != "" { - URL = fmt.Sprintf("http://localhost:8005/api/dashboard/companies/%s/repositories/%s/%s?initialDate=%s&finalDate=%s", companyID, repositoryID, route, initialDateStr, finalDateStr) - } - req, err := request.NewHTTPRequest().Request(http.MethodGet, URL, nil, map[string]string{"Authorization": bearerToken, "Content-type": "application/json"}) - assert.NoError(t, err) - res, err := client.NewHTTPClient(15).DoRequest(req, &tls.Config{}) - assert.NoError(t, err) - assert.Equal(t, http.StatusOK, res.GetStatusCode()) - body, err := res.GetBody() - assert.NoError(t, err) - return body -} - -func GetChartDetailsUsingGraphQLAndReturnBody(t *testing.T, bearerToken, companyID, repositoryID string) []byte { - fmt.Println("Running test for GetChartContent using graphql") - now := time.Now() - initialDateStr := now.Format("2006-01-02") + "T00:00:00Z" - finalDateStr := now.Format("2006-01-02") + "T23:59:59Z" - filterGraphQL := fmt.Sprintf("companyID: \"%s\"", companyID) - if repositoryID != "" { - filterGraphQL = fmt.Sprintf("repositoryID: \"%s\"", repositoryID) - } - filterTotalItemsAndAnalysis := fmt.Sprintf("(%s, initialDate: \"%s\", finalDate: \"%s\")", filterGraphQL, initialDateStr, finalDateStr) - queryGraphQL := "{" + - fmt.Sprintf("totalItems%s", filterTotalItemsAndAnalysis) + - fmt.Sprintf("analysis%s", filterTotalItemsAndAnalysis) + - `{ - repositoryName - companyName - vulnerability { - line - column - confidence - file - code - details - securityTool - language - severity - commitAuthor - commitEmail - commitHash - commitMessage - commitDate - } - } - }` - queryGraphQL = strings.ReplaceAll(queryGraphQL, "\n", "%20") - queryGraphQL = strings.ReplaceAll(queryGraphQL, "\t", "%20") - queryGraphQL = strings.ReplaceAll(queryGraphQL, " ", "%20") - URL := fmt.Sprintf("http://localhost:8005/api/dashboard/companies/%s/details?query=%s&page=1&size=1000", companyID, queryGraphQL) - if repositoryID != "" { - URL = fmt.Sprintf("http://localhost:8005/api/dashboard/companies/%s/repositories/%s/details?query=%s&page=1&size=1000", companyID, repositoryID, queryGraphQL) - } - req, err := request.NewHTTPRequest().Request(http.MethodGet, URL, nil, map[string]string{"Authorization": bearerToken, "Content-Type": "application/json"}) - assert.NoError(t, err) - res, err := client.NewHTTPClient(15).DoRequest(req, &tls.Config{}) - assert.NoError(t, err) - assert.Equal(t, http.StatusOK, res.GetStatusCode()) - body, err := res.GetBody() - assert.NoError(t, err) - return body -} diff --git a/e2e/server/shared_requests.go b/e2e/server/shared_requests.go new file mode 100644 index 000000000..964221eb2 --- /dev/null +++ b/e2e/server/shared_requests.go @@ -0,0 +1,160 @@ +// Requests save in this file are shared into all server e2e. +package server + +import ( + "bytes" + "crypto/tls" + "encoding/json" + "fmt" + accountentities "github.com/ZupIT/horusec/development-kit/pkg/entities/account" + "github.com/ZupIT/horusec/development-kit/pkg/entities/account/roles" + "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/client" + "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/request" + httpResponse "github.com/ZupIT/horusec/development-kit/pkg/utils/http-request/response" + "github.com/stretchr/testify/assert" + "net/http" + "testing" + "time" +) + +func CreateCompany(t *testing.T, bearerToken string, company *accountentities.Company) (CompanyID string) { + fmt.Println("Running test for CreateCompany") + req, _ := http.NewRequest(http.MethodPost, "http://127.0.0.1:8003/api/companies", bytes.NewReader(company.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + createCompanyResp, err := httpClient.Do(req) + assert.NoError(t, err, "create company error send request") + assert.Equal(t, http.StatusCreated, createCompanyResp.StatusCode, "create company error check response") + var createdCompany map[string]map[string]string + _ = json.NewDecoder(createCompanyResp.Body).Decode(&createdCompany) + assert.NoError(t, createCompanyResp.Body.Close()) + assert.NotEmpty(t, createdCompany["content"]["companyID"]) + return createdCompany["content"]["companyID"] +} + +func UpdateCompany(t *testing.T, bearerToken string, companyID string, company *accountentities.Company) { + fmt.Println("Running test for UpdateCompany") + req, _ := http.NewRequest(http.MethodPatch, "http://127.0.0.1:8003/api/companies/"+companyID, bytes.NewReader(company.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "update company error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "update company error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) +} + +func ReadAllCompanies(t *testing.T, bearerToken string, isCheckBodyEmpty bool) string { + fmt.Println("Running test for ReadAllCompanies") + req, _ := http.NewRequest(http.MethodGet, "http://127.0.0.1:8003/api/companies", nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read all companies error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read all companies error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + if isCheckBodyEmpty { + assert.NotEmpty(t, body["content"]) + } + content, _ := json.Marshal(body["content"]) + return string(content) +} + +func DeleteCompany(t *testing.T, bearerToken, companyID string) { + fmt.Println("Running test for DeleteCompany") + req, _ := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8003/api/companies/"+companyID, nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "delete company error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "delete company error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} + +func InviteUserToCompany(t *testing.T, bearerToken, companyID string, user *accountentities.InviteUser) { + fmt.Println("Running test for InviteUserToCompany") + req, _ := http.NewRequest( + http.MethodPost, + "http://127.0.0.1:8003/api/companies/"+companyID+"/roles", + bytes.NewReader(user.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "invite user error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "invite user error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} +func ReadAllUserInCompany(t *testing.T, bearerToken, companyID string) string { + fmt.Println("Running test for InviteUserToCompany") + req, _ := http.NewRequest( + http.MethodGet, + "http://127.0.0.1:8003/api/companies/"+companyID+"/roles", + nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "read all user in company error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "read all user in company error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + content, _ := json.Marshal(body["content"]) + return string(content) +} +func UpdateUserInCompany(t *testing.T, bearerToken, companyID, accountID string, account *roles.AccountCompany) string { + fmt.Println("Running test for UpdateUserInCompany") + req, _ := http.NewRequest( + http.MethodPatch, + "http://127.0.0.1:8003/api/companies/"+companyID+"/roles/"+accountID, + bytes.NewReader(account.ToBytes())) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "update user in company error send request") + assert.Equal(t, http.StatusOK, resp.StatusCode, "update user in company error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) + assert.NotEmpty(t, body["content"]) + content, _ := json.Marshal(body["content"]) + return string(content) +} +func RemoveUserInCompany(t *testing.T, bearerToken, companyID, accountID string) { + fmt.Println("Running test for RemoveUserInCompany") + req, _ := http.NewRequest( + http.MethodDelete, + "http://127.0.0.1:8003/api/companies/"+companyID+"/roles/"+accountID, + nil) + req.Header.Add("Authorization", bearerToken) + httpClient := http.Client{} + resp, err := httpClient.Do(req) + assert.NoError(t, err, "delete user in company error send request") + assert.Equal(t, http.StatusNoContent, resp.StatusCode, "delete user in company error check response") + var body map[string]interface{} + _ = json.NewDecoder(resp.Body).Decode(&body) + assert.NoError(t, resp.Body.Close()) +} +func GetChartContentWithoutTreatment(t *testing.T, route, bearerToken, companyID, repositoryID string) httpResponse.Interface { + fmt.Println("Running test for GetChartContentWithoutTreatment in route: " + route) + now := time.Now() + initialDateStr := now.Format("2006-01-02") + "T00:00:00Z" + finalDateStr := now.Format("2006-01-02") + "T23:59:59Z" + URL := fmt.Sprintf("http://127.0.0.1:8005/api/dashboard/companies/%s/%s?initialDate=%s&finalDate=%s", companyID, route, initialDateStr, finalDateStr) + if repositoryID != "" { + URL = fmt.Sprintf("http://127.0.0.1:8005/api/dashboard/companies/%s/repositories/%s/%s?initialDate=%s&finalDate=%s", companyID, repositoryID, route, initialDateStr, finalDateStr) + } + req, err := request.NewHTTPRequest().Request(http.MethodGet, URL, nil, map[string]string{"Authorization": bearerToken, "Content-type": "application/json"}) + assert.NoError(t, err) + res, err := client.NewHTTPClient(15).DoRequest(req, &tls.Config{}) + assert.NoError(t, err) + return res +} diff --git a/go.mod b/go.mod index 1e7fa25c3..b33cb7cd4 100644 --- a/go.mod +++ b/go.mod @@ -6,63 +6,32 @@ require ( github.com/Nerzal/gocloak/v7 v7.5.0 github.com/ZupIT/horusec-engine v0.2.7 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 - github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect - github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect - github.com/auth0/go-jwt-middleware v0.0.0-20200810150920-a32d7af194d1 - github.com/bmatcuk/doublestar v1.3.2 // indirect + github.com/auth0/go-jwt-middleware v0.0.0-20201030150249-d783b5c46b39 github.com/bmatcuk/doublestar/v2 v2.0.3 - github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect github.com/davecgh/go-spew v1.1.1 - github.com/denisenkom/go-mssqldb v0.0.0-20200910202707-1e08a3fab204 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible - github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 github.com/docker/docker v1.13.1 - github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/go-chi/chi v4.1.2+incompatible github.com/go-chi/cors v1.1.1 github.com/go-enry/go-enry/v2 v2.5.2 - github.com/go-openapi/spec v0.19.11 // indirect - github.com/go-openapi/swag v0.19.11 // indirect github.com/go-ozzo/ozzo-validation/v4 v4.3.0 github.com/golang-migrate/migrate/v4 v4.13.0 github.com/golang/protobuf v1.4.3 github.com/google/uuid v1.1.2 github.com/graphql-go/graphql v0.7.9 - github.com/hashicorp/errwrap v1.1.0 // indirect github.com/iancoleman/strcase v0.1.2 github.com/jinzhu/gorm v1.9.16 - github.com/labstack/echo v3.3.10+incompatible - github.com/labstack/gommon v0.3.0 // indirect - github.com/lib/pq v1.8.0 // indirect - github.com/lunixbochs/vtclean v1.0.0 // indirect github.com/magiconair/properties v1.8.4 - github.com/mailru/easyjson v0.7.6 // indirect github.com/manifoldco/promptui v0.8.0 - github.com/mattn/go-colorable v0.1.8 // indirect - github.com/mattn/go-sqlite3 v1.14.4 // indirect - github.com/mitchellh/mapstructure v1.3.3 // indirect - github.com/onsi/ginkgo v1.12.0 - github.com/onsi/gomega v1.9.0 - github.com/opencontainers/go-digest v1.0.0 // indirect github.com/otiai10/copy v1.2.0 - github.com/pelletier/go-toml v1.8.1 // indirect github.com/prometheus/client_golang v1.8.0 - github.com/prometheus/common v0.14.0 // indirect - github.com/prometheus/procfs v0.2.0 // indirect github.com/sirupsen/logrus v1.7.0 - github.com/spf13/afero v1.4.1 // indirect - github.com/spf13/cast v1.3.1 // indirect github.com/spf13/cobra v1.1.1 - github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.1 github.com/streadway/amqp v1.0.0 - github.com/stretchr/objx v0.3.0 // indirect github.com/stretchr/testify v1.6.1 github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba github.com/swaggo/swag v1.6.9 - github.com/valyala/fasttemplate v1.2.1 // indirect - github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 golang.org/x/net v0.0.0-20201029055024-942e2f445f3c golang.org/x/sys v0.0.0-20201029080932-201ba4db2418 // indirect @@ -72,6 +41,4 @@ require ( google.golang.org/protobuf v1.25.0 gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df - gopkg.in/ini.v1 v1.62.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect ) diff --git a/go.sum b/go.sum index b8472932f..81c1de88f 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,6 @@ cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6 cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.60.0/go.mod h1:yw2G51M9IfRboUH61Us8GqCeF1PzPblB823Mn2q2eAU= -cloud.google.com/go v0.61.0/go.mod h1:XukKJg4Y7QsUu0Hxg3qQKUWR4VuWivmyMK2+rUyxAqw= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.63.0/go.mod h1:GmezbQc7T2snqkEXWfZ0sy0VfkB/ivI2DdtJL2DEmlg= cloud.google.com/go v0.64.0/go.mod h1:xfORb36jGvE+6EexW71nMEtL025s3x6xvuYUKM4JLv4= @@ -29,7 +27,6 @@ cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2k cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/spanner v1.8.0/go.mod h1:mdAPDiFUbE9vCmhHHlxyDUtaPPsIK+pUdf5KmHaUfT8= cloud.google.com/go/spanner v1.9.0/go.mod h1:xvlEn0NZ5v1iJPYsBnUVRDNvccDxsBTEi16pJRKQVws= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= @@ -48,7 +45,6 @@ github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcy github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Nerzal/gocloak v1.0.0 h1:WllsbIu1dYvdvka1/BbY7khZBJSTjSkGwyDsHHLQmIw= -github.com/Nerzal/gocloak v1.0.0/go.mod h1:daDihnZuvvt0J5neHCn1e/5lu+vXMF/MUZsCWVj5V5s= github.com/Nerzal/gocloak/v7 v7.5.0 h1:C43CStKw14gZatPLBdjKIrz1a6UrjaxP7OQTXYQ+RHc= github.com/Nerzal/gocloak/v7 v7.5.0/go.mod h1:tJ0yV6jds2dm1a5eYW7km/bt+2F3mqlU0e8Xis+diDQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -61,8 +57,6 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/ZupIT/horusec-engine v0.2.5 h1:11FECfTpF8qd/UbusWd+WgKMylJ+TzSTyiLOOuwWerk= -github.com/ZupIT/horusec-engine v0.2.5/go.mod h1:pJ5IoEOdX6mT4pYG/ZM15XzapKA/KUQgs/ok0Un1Xhk= github.com/ZupIT/horusec-engine v0.2.7 h1:1LNxKhMYK4OJd//awCEjyBUVi1iDX5fnKUaI5ax5GXU= github.com/ZupIT/horusec-engine v0.2.7/go.mod h1:YUvzG1NJ5BXQ/vKJv2i4KbiwF2z5vHwcCVvjtf4fIkE= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -77,15 +71,13 @@ github.com/apache/arrow/go/arrow v0.0.0-20200601151325-b2287a20f230/go.mod h1:QN github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 h1:zV3ejI06GQ59hwDQAvmK1qxOQGB3WuVTRoY0okPTAv0= github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/auth0/go-jwt-middleware v0.0.0-20200810150920-a32d7af194d1 h1:lnVadil6o8krZE47ms2PCxhXcki/UwoqiB0axOIV3mk= -github.com/auth0/go-jwt-middleware v0.0.0-20200810150920-a32d7af194d1/go.mod h1:mF0ip7kTEFtnhBJbd/gJe62US3jykNN+dcZoZakJCCA= +github.com/auth0/go-jwt-middleware v0.0.0-20201030150249-d783b5c46b39 h1:FXGfTw25KQECao75qgpoCttPz8VTwKkQTi2L0iGh9Vk= +github.com/auth0/go-jwt-middleware v0.0.0-20201030150249-d783b5c46b39/go.mod h1:mF0ip7kTEFtnhBJbd/gJe62US3jykNN+dcZoZakJCCA= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -98,10 +90,7 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/bmatcuk/doublestar v1.3.2 h1:mzUncgFmpzNUhIITFqGdZ8nUU0O7JTJzRO8VdkeLCSo= -github.com/bmatcuk/doublestar v1.3.2/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= -github.com/bmatcuk/doublestar/v2 v2.0.1 h1:EFT91DmIMRcrUEcYUW7AqSAwKvNzP5+CoDmNVBbcQOU= -github.com/bmatcuk/doublestar/v2 v2.0.1/go.mod h1:QMmcs3H2AUQICWhfzLXz+IYln8lRQmTZRptLie8RgRw= +github.com/bmatcuk/doublestar v1.3.3 h1:pVP1d49CcQQaNOl+PI6sPybIrIOD/6sux31PFdmhTH0= github.com/bmatcuk/doublestar/v2 v2.0.3 h1:D6SI8MzWzXXBXZFS87cFL6s/n307lEU+thM2SUnge3g= github.com/bmatcuk/doublestar/v2 v2.0.3/go.mod h1:QMmcs3H2AUQICWhfzLXz+IYln8lRQmTZRptLie8RgRw= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= @@ -128,7 +117,6 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/containerd/containerd v1.3.3/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -141,21 +129,18 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM= -github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= -github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/denisenkom/go-mssqldb v0.0.0-20200620013148-b91950f658ec h1:NfhRXXFDPxcF5Cwo06DzeIaE7uuJtAUhsDwH3LNsjos= github.com/denisenkom/go-mssqldb v0.0.0-20200620013148-b91950f658ec/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= -github.com/denisenkom/go-mssqldb v0.0.0-20200910202707-1e08a3fab204 h1:tI48fqaIkxxYuIylVv1tdDfBp6836GKSfmmzgSyP1CY= -github.com/denisenkom/go-mssqldb v0.0.0-20200910202707-1e08a3fab204/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/dgrijalva/jwt-go v1.0.2 h1:KPldsxuKGsS2FPWsNeg9ZO18aCrGKujPoWXn2yo+KQM= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 h1:CaO/zOnF8VvUfEbhRatPcwKVWamvbYd8tQGRWacE9kU= github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1/go.mod h1:+hnT3ywWDTAFrW5aE+u2Sa/wT555ZqwoCS+pk3p6ry4= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dhui/dktest v0.3.2 h1:nZSDcnkpbotzT/nEHNsO+JCKY8i1Qoki1AYOpeLRb6M= github.com/dhui/dktest v0.3.2/go.mod h1:l1/ib23a/CmxAe7yixtrYPc8Iy90Zy2udyaHINM5p58= github.com/docker/distribution v2.7.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= @@ -183,9 +168,8 @@ github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsouza/fake-gcs-server v1.17.0/go.mod h1:D1rTE4YCyHFNa99oyJJ5HyclvN/0uQR+pM/VdlL83bw= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w= @@ -195,11 +179,13 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-chi/chi v1.0.0 h1:s/kv1cTXfivYjdKJdyUzNGyAWZ/2t7duW1gKn5ivu+c= github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-chi/cors v1.1.1 h1:eHuqxsIw89iXcWnWUN8R72JMibABJTN/4IOYI5WERvw= github.com/go-chi/cors v1.1.1/go.mod h1:K2Yje0VW/SJzxiyMYu6iPQYa7hMjQX2i/F491VChg1I= +github.com/go-enry/go-enry v1.7.3 h1:MbViVjoR80+AWFY8GmhEdtGY7WYAPxb0A74kLc8X5c0= github.com/go-enry/go-enry/v2 v2.5.2 h1:3f3PFAO6JitWkPi1GQ5/m6Xu4gNL1U5soJ8QaYqJ0YQ= github.com/go-enry/go-enry/v2 v2.5.2/go.mod h1:GVzIiAytiS5uT/QiuakK7TF1u4xDab87Y8V5EJRpsIQ= github.com/go-enry/go-oniguruma v1.2.1 h1:k8aAMuJfMrqm/56SG2lV9Cfti6tC4x8673aHCcBk+eo= @@ -215,34 +201,18 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= -github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/jsonreference v0.19.4 h1:3Vw+rh13uq2JFNxgnMTGE1rnoieU9FmyE1gvnyylsYg= github.com/go-openapi/jsonreference v0.19.4/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= github.com/go-openapi/spec v0.19.9 h1:9z9cbFuZJ7AcvOHKIY+f6Aevb4vObNDkTEyoMfO7rAc= github.com/go-openapi/spec v0.19.9/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28= -github.com/go-openapi/spec v0.19.10 h1:pcNevfYytLaOQuTju0wm6OqcqU/E/pRwuSGigrLTI28= -github.com/go-openapi/spec v0.19.10/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28= -github.com/go-openapi/spec v0.19.11 h1:ogU5q8dtp3MMPn59a9VRrPKVxvJHEs5P7yNMR5sNnis= -github.com/go-openapi/spec v0.19.11/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.9 h1:1IxuqvBUU3S2Bi4YC7tlP9SJF1gVpCvqN0T2Qof4azE= -github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= -github.com/go-openapi/swag v0.19.10 h1:A1SWXruroGP15P1sOiegIPbaKio+G9N5TwWTFaVPmAU= -github.com/go-openapi/swag v0.19.10/go.mod h1:Uc0gKkdR+ojzsEpjh39QChyu92vPgIr72POcgHMAgSY= -github.com/go-openapi/swag v0.19.11 h1:RFTu/dlFySpyVvJDfp/7674JY4SDglYWKztbiIGFpmc= -github.com/go-openapi/swag v0.19.11/go.mod h1:Uc0gKkdR+ojzsEpjh39QChyu92vPgIr72POcgHMAgSY= -github.com/go-ozzo/ozzo-validation/v4 v4.2.2 h1:5uhbQAuRK6taB9orHJXA5GtOCuQbsHktskg8aWciC68= -github.com/go-ozzo/ozzo-validation/v4 v4.2.2/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew= github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es= github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -263,8 +233,8 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/golang-migrate/migrate/v4 v4.12.2 h1:QI43Tlouiwpp2dK5Y767OouX0snJNRP/NubsVaArzDU= -github.com/golang-migrate/migrate/v4 v4.12.2/go.mod h1:HQ1DaC8uLHkg4afY8ZQ8D/P5SG+YW9X5INZBVvm+d2k= +github.com/golang-migrate/migrate v1.3.2 h1:QAlFV1QF9zdkzy/jujlBVkVu+L/+k18cg8tuY1/4JDY= +github.com/golang-migrate/migrate v3.5.4+incompatible h1:R7OzwvCJTCgwapPCiX6DyBiu2czIUMDCB118gFTKTUA= github.com/golang-migrate/migrate/v4 v4.13.0 h1:5S7HMjiq9u50X3+WXpzXPbUj1qUFuZRm8NCsX989Tn4= github.com/golang-migrate/migrate/v4 v4.13.0/go.mod h1:RUEXGkgYXTOdBY9Rbs9izc/SOalUK+dDi7YphFV/CUI= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= @@ -294,7 +264,6 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= @@ -322,7 +291,6 @@ github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200507031123-427632fa3b1c/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -339,7 +307,6 @@ github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graphql-go/graphql v0.7.9 h1:5Va/Rt4l5g3YjwDnid3vFfn43faaQBq7rMcIZ0VnV34= github.com/graphql-go/graphql v0.7.9/go.mod h1:k6yrAYQaSP59DC5UVxbgxESlmVyojThKdORUqGDGmrI= @@ -355,8 +322,6 @@ github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyN github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= @@ -378,7 +343,6 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/iancoleman/strcase v0.1.2 h1:gnomlvw9tnV3ITTAxzKSgTF+8kFWcU/f+TgttpXGz1U= @@ -419,8 +383,6 @@ github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -441,73 +403,49 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/labstack/echo v1.4.4 h1:1bEiBNeGSUKxcPDGfZ/7IgdhJJZx8wV/pICJh4W2NJI= -github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= -github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= -github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg= -github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a h1:weJVJJRzAJBFRlAiJQROKQs8oC9vOxvm4rZmBBk0ONw= github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= -github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8= -github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.3 h1:kJSsc6EXkBLgr3SphHk9w5mtjn0bjlR4JYEXKrJ45rQ= -github.com/magiconair/properties v1.8.3/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY= github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/manifoldco/promptui v0.7.0 h1:3l11YT8tm9MnwGFQ4kETwkzpAwY2Jt9lCrumCUW4+z4= -github.com/manifoldco/promptui v0.7.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ= github.com/manifoldco/promptui v0.8.0 h1:R95mMF+McvXZQ7j1g8ucVZE1gLP3Sv6j9vlF9kyRqQo= github.com/manifoldco/promptui v0.8.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ= github.com/markbates/pkger v0.15.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= -github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= -github.com/mattn/go-sqlite3 v1.14.3 h1:j7a/xn1U6TKA/PHHxqZuzh64CdtRc7rU9M+AvkOl5bA= -github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= -github.com/mattn/go-sqlite3 v1.14.4 h1:4rQjbDxdu9fSgI/r3KN72G3c2goxknAqHHgPWWs8UlI= -github.com/mattn/go-sqlite3 v1.14.4/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= @@ -518,10 +456,8 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.3.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= -github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -545,16 +481,13 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= -github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= -github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= @@ -573,10 +506,8 @@ github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= -github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= -github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -586,7 +517,6 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -595,7 +525,6 @@ github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= -github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.8.0 h1:zvJNkoCFAnYFNC24FV8nW4JdRJ3GIFcLbg65lL/JDcw= github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= @@ -612,8 +541,6 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.13.0 h1:vJlpe9wPgDRM1Z+7Wj3zUUjY1nr6/1jNKyl7llliccg= -github.com/prometheus/common v0.13.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.14.0 h1:RHRyE8UocrbjU+6UvRzwi6HjiDfxrrBU91TtbKzkGp4= github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -621,7 +548,6 @@ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULUx4= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= @@ -645,7 +571,6 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= @@ -657,28 +582,19 @@ github.com/snowflakedb/gosnowflake v1.3.5/go.mod h1:13Ky+lxzIm3VqNDZJdyvu9MCGy+W github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.4.0 h1:jsLTaI1zwYO3vjrzHalkVcIHXTNmdQFepW4OI8H3+x8= -github.com/spf13/afero v1.4.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/afero v1.4.1 h1:asw9sl74539yqavKaglDM5hFpdJVK0Y5Dr/JOgQ89nQ= -github.com/spf13/afero v1.4.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= -github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= @@ -689,9 +605,8 @@ github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1Sd github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As= -github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -708,10 +623,6 @@ github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba h1:lUPlXKqgbqT github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba/go.mod h1:O1lAbCgAAX/KZ80LM/OXwtWFI/5TvZlwxSg8Cq08PV0= github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= github.com/swaggo/swag v1.6.3/go.mod h1:wcc83tB4Mb2aNiL/HP4MFeQdpHUrca+Rp/DRNgWAUio= -github.com/swaggo/swag v1.6.7 h1:e8GC2xDllJZr3omJkm9YfmK0Y56+rMO3cg0JBKNz09s= -github.com/swaggo/swag v1.6.7/go.mod h1:xDhTyuFIujYiN3DKWC/H/83xcfHp+UE/IzWWampG7Zc= -github.com/swaggo/swag v1.6.8 h1:z3ZNcpJs/NLMpZcKqXUsBELmmY2Ocy09JXKx5gu3L4M= -github.com/swaggo/swag v1.6.8/go.mod h1:a0IpNeMfGidNOcm2TsqODUh9JHdHu3kxDA0UlGbBKjI= github.com/swaggo/swag v1.6.9 h1:BukKRwZjnEcUxQt7Xgfrt9fpav0hiWw9YimdNO9wssw= github.com/swaggo/swag v1.6.9/go.mod h1:a0IpNeMfGidNOcm2TsqODUh9JHdHu3kxDA0UlGbBKjI= github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= @@ -725,22 +636,12 @@ github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2t github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= -github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/wiliansilvazup/horus-example-vulnerabilities v0.0.0-20200924170348-ca39bbfe5b7f h1:+G40R/nojlZ5KE1Vaj+lGmJndbzLj/7KRTuw5umAluA= -github.com/wiliansilvazup/semver-cli v0.0.3 h1:12jDuS3LfB0ZG8nZXo5LOpQVyiK1Tl4pRElAE6jNA3o= -github.com/wiliansilvazup/semver-cli v0.0.3/go.mod h1:r7j6VgVpCVJvaX2xYMsLqdExK72PdPSUkZxCudbMB9s= github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -774,7 +675,6 @@ golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -782,7 +682,6 @@ golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -821,7 +720,6 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -835,7 +733,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -859,19 +756,11 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA= -golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200923182212-328152dc79b1 h1:Iu68XRPd67wN4aRGGWwwq6bZo/25jR6uu52l/j2KkUE= -golang.org/x/net v0.0.0-20200923182212-328152dc79b1/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200925080053-05aa5d4ee321 h1:lleNcKRbcaC8MqgLwghIkzZ2JBQAb7QQ9MiwRt1BisA= -golang.org/x/net v0.0.0-20200925080053-05aa5d4ee321/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200927032502-5d4f70055728 h1:5wtQIAulKU5AbLQOkjxl32UufnIOqgBX72pS0AV14H0= -golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0 h1:5kGOVHlq0euqwzgTC9Vu15p6fV1Wi0ArVi8da2urnVg= -golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201029055024-942e2f445f3c h1:rpcgRPA7OvNEOdprt2Wx8/Re2cBTd8NPo/lvo3AyMqk= golang.org/x/net v0.0.0-20201029055024-942e2f445f3c/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 h1:42cLlJJdEh+ySyeUUbEQ5bsTiq8voBeTuweGVkY6Puw= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -906,13 +795,11 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -931,24 +818,14 @@ golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200817155316-9781c653f443/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200922070232-aee5d888a860 h1:YEu4SMq7D0cmT7CBbXfcH0NZeuChAXwsHe/9XueUO6o= -golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d h1:L/IKR6COd7ubZrs2oTnTi73IhgqJ71c9s80WsQnh0Es= -golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200926100807-9d91bd62050c h1:38q6VNPWR010vN82/SB121GujZNIfAUb4YttE2rhGuc= -golang.org/x/sys v0.0.0-20200926100807-9d91bd62050c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88= golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13 h1:5jaG59Zhd+8ZXe8C+lgiAGqkOaZBruqrWclLkgAww34= -golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201029080932-201ba4db2418 h1:HlFl4V6pEMziuLXyRkm5BIYq1y1GAbb02pRlWvI54OM= golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -981,7 +858,6 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -1015,27 +891,14 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200725200936-102e7d357031/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200806022845-90696ccdc692/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200814230902-9882f1d1823d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200817023811-d00afeaade8f/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200818005847-188abfa75333/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200820010801-b793a1359eac h1:DugppSxw0LSF8lcjaODPJZoDzq0ElTGskTst3ZaBkHI= golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200922173257-82fe25c37531 h1:FS7ZiladzQ5yC5TWXke5sO9bHgSg37DItOho2WWf43U= -golang.org/x/tools v0.0.0-20200922173257-82fe25c37531/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= -golang.org/x/tools v0.0.0-20200923182640-463111b69878 h1:VUw1+Jf6KJPf82mbTQMia6HCnNMv2BbAipkEZ4KTcqQ= -golang.org/x/tools v0.0.0-20200923182640-463111b69878/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= -golang.org/x/tools v0.0.0-20200924224222-8d73f17870ce h1:XRr763sMfaUSNR4EsxbddvVEqYFa9picrx6ks9pJkKw= -golang.org/x/tools v0.0.0-20200924224222-8d73f17870ce/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= -golang.org/x/tools v0.0.0-20200928182047-19e03678916f h1:VwGa2Wf+rHGIxvsssCkUNIyFv8jQY0VCBCNWtikoWq0= -golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= -golang.org/x/tools v0.0.0-20201017001424-6003fad69a88 h1:ZB1XYzdDo7c/O48jzjMkvIjnC120Z9/CwgDWhePjQdQ= -golang.org/x/tools v0.0.0-20201017001424-6003fad69a88/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201029182919-e7a17c4c1366 h1:a6x10n1HsMdTywBbnrJhO8r8pa7rnbl8TvRfCUd16Jw= golang.org/x/tools v0.0.0-20201029182919-e7a17c4c1366/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1043,7 +906,6 @@ golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= @@ -1097,10 +959,6 @@ google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200626011028-ee7919e894b5/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200720141249-1244ee217b7e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200726014623-da3ae01ef02d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -1143,7 +1001,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= @@ -1152,16 +1009,9 @@ gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AW gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.61.0 h1:LBCdW4FmFYL4s/vDZD1RQYX7oAR6IjujCYgMdbHBR10= -gopkg.in/ini.v1 v1.61.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.10.3/go.mod h1:nrgQYbPhkRfn2BfT32NNTLfq3K9NuHRB0MsAcA9weWY= -gopkg.in/resty.v1 v1.12.0 h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= diff --git a/horusec-account/internal/controller/companies/companies.go b/horusec-account/internal/controller/companies/companies.go index 3692cfa69..f89ea84da 100644 --- a/horusec-account/internal/controller/companies/companies.go +++ b/horusec-account/internal/controller/companies/companies.go @@ -78,14 +78,12 @@ func (c *Controller) Create(accountID uuid.UUID, data *accountEntities.Company) if err != nil { return nil, err } - if err = c.repoAccountCompany.CreateAccountCompany( newCompany.CompanyID, accountID, accountEnums.Admin, tx); err != nil { - return nil, tx.RollbackTransaction().GetError() + _ = tx.RollbackTransaction() + return nil, err } - - tx.CommitTransaction() - + _ = tx.CommitTransaction() return newCompany, nil } diff --git a/horusec-config.json b/horusec-config.json index 5d10c6dfc..d1060a362 100644 --- a/horusec-config.json +++ b/horusec-config.json @@ -7,7 +7,7 @@ "horusecCliPrintOutputType": "text", "horusecCliJsonOutputFilepath": "", "horusecCliTypesOfVulnerabilitiesToIgnore": "", - "horusecCliFilesOrPathsToIgnore": "**/e2e/**, **/examples/**, **/*.toml, **/*_test.go, **/*_mock.go, **/*README.md, **/development-kit/pkg/enums/engine/advisories/**, **/horusec-lp/.cache/**, **/horusec-lp/public/**, **/deployments/docker-compose*", + "horusecCliFilesOrPathsToIgnore": "**/e2e/**, **/examples/**, **/*.toml, **/*_test.go, **/*_mock.go, **/*README.md, **/development-kit/pkg/enums/engine/advisories/**, **/horusec-lp/.cache/**, **/horusec-lp/public/**, **/deployments/docker-compose*, **/horusec-cli/cmd/horusec/start/analysis/*", "horusecCliReturnErrorIfFoundVulnerability": false, "horusecCliProjectPath": "./", "horusecCliFalsePositiveHashes": "e2eaa19612eed0124b1fec396f8d41381c618c677c2025fc07c1cd0ccbe92b3c, 2b156198552b17c44bab579d68b8cb4204789859ef69a37a7a11e65667cbc66f, 2ce87bddc40e085562618f441750eeefe3cffc79d0b05b2e07a98f644c55b2c5",