From 5e41fd01dbbec359bb47db00e753c85573627983 Mon Sep 17 00:00:00 2001 From: Victor Toupitzen Specian Date: Sun, 19 May 2024 19:39:14 -0700 Subject: [PATCH 1/3] Update README.md --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index beaa372..ca712b6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,39 @@ # fiap-tech-challenge-api -### Tech Challenge 3 e 4: +### Tech Challenge 4: +### Passos para homologação dos professores da Fiap + +1. Faça o login na plataforma da AWS; +2. Crie um repositório privado no ECR da AWS chamado fiap-tech-challenge-api; +3. Acesse IAM->Usuários e crie um novo usuário chamado Github; +4. Com esse usuário criado, vá até a listagem de usuários e acesse os detalhes do mesmo; +5. No menu Permissões que irá aparecer na tela de detalhes, clique no botão "Adicionar permissões" que aparece no canto direito; +6. Na tela que irá aparecer, selecione a opção "Anexar políticas diretamente"; +7. Pesquise pela permissão "AmazonEC2ContainerRegistryPowerUser" e adicione ela; +8. Após isso, de volta a tela de detalhes do usuário, clique na aba "Credenciais de Segurança", e no bloco "Chaves de acesso", clique em "Criar chave de acesso"; +9. Na tela que irá se abrir, selecione a opção "Command Line Interface (CLI)" e clique em próximo; +10. No valor da etiqueta, coloque o valor "github actions" ou qualquer um que prefira para identificar posteriormente; +11. Copie os valores dos campos "Chave de acesso" e "Chave de acesso secreta"; +12. Na plataforma do Github, acesse o menu "Settings" do projeto, na tela que se abrir, clique no menu Security->Secrets and variables->Actions; +13. Adicione uma "repository secret" chamada AWS_ACCESS_KEY_ID com o valor copiado de "Chave de acesso", e crie outra "repository secret" chamada AWS_SECRET_ACCESS_KEY com o valor copiado de "Chave de acesso secreta"; +14. Vincule este projeto no Sonar Cloud: +``` +https://sonarcloud.io/ +``` +15. Acesse seu projeto no Sonar Cloud e vá até o menu Administration->Analisys Method e desmarque a opção "Automatic Analysis"; +16. Depois vá até o menu Administration->Update Key e copie o valor de Project Key; +17. No menu Account que está no canto superior direito com a foto de seu usuário, acesse o menu My Organizations e copie o valor da Organization Key; +18. Depois novamente no menu Account, acesse My Account->Security e crie um novo token e copie o seu valor; +19. Retorne até o menu Settings do seu projeto do Github e cadastre novas "repository secret" conforme explicado abaixo: +``` +SONAR_PROJECT_KEY=Valor copiado no passo 16 +SONAR_ORGANIZATION=Valor copiado no passo 17 +SONAR_TOKEN=Valor copiado no passo 18 +``` +20. Após isso qualquer commit neste repositório que for para a branch "main", irá subir uma imagem desta api no ECR da AWS; + + +### Tech Challenge 3: ### Passos para homologação dos professores da Fiap 1. Faça o login na plataforma da AWS; From 9665d1acda3403bf6b9cc6455b571f41aee8d5a9 Mon Sep 17 00:00:00 2001 From: Victor Toupitzen Specian Date: Sun, 19 May 2024 19:40:41 -0700 Subject: [PATCH 2/3] Update pipeline.yml --- .github/workflows/pipeline.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 3691fac..4a11095 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -5,8 +5,34 @@ on: branches: [ "main" ] jobs: + unit-test: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Unit Tests + run: go clean -testcache && go test -v ./... + + code-analisys: + needs: unit-test + name: Code Analisys with SonarCloud + runs-on: ubuntu-latest + steps: + - name: Clone Repository + uses: actions/checkout@v3 + - name: Analyze with SonarCloud + uses: sonarsource/sonarcloud-github-action@master + with: + projectBaseDir: internal/core/usecase + args: > + -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} + -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} build: + needs: code-analisys runs-on: ubuntu-latest From 15ba0404680cdd7d41384489b3e52cea09bcce3c Mon Sep 17 00:00:00 2001 From: Victor Toupitzen Specian Date: Mon, 20 May 2024 04:45:11 -0300 Subject: [PATCH 3/3] Create insomnia_collection_tech_challenge_4.json --- docs/insomnia_collection_tech_challenge_4.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/insomnia_collection_tech_challenge_4.json diff --git a/docs/insomnia_collection_tech_challenge_4.json b/docs/insomnia_collection_tech_challenge_4.json new file mode 100644 index 0000000..ed2f1bf --- /dev/null +++ b/docs/insomnia_collection_tech_challenge_4.json @@ -0,0 +1 @@ +{"_type":"export","__export_format":4,"__export_date":"2024-05-20T07:44:51.588Z","__export_source":"insomnia.desktop.app:v8.3.0","resources":[{"_id":"req_978cfd1bbc634f6dbf764fd2b5286154","parentId":"wrk_8481d2f882ae41f4930912932111267a","modified":1706564743861,"created":1698511563171,"url":"{{ _.url_base }}/liveness","name":"health","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1698511563172,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_8481d2f882ae41f4930912932111267a","parentId":null,"modified":1716190143623,"created":1716190143623,"name":"tech-challenge","description":"","scope":"collection","_type":"workspace"},{"_id":"req_cadde36367684964a6404492dce0ddf6","parentId":"fld_4565d46e6096493e97c5acd0a64a8647","modified":1710846471956,"created":1706534534816,"url":"{{ _.url_base }}/pagamento/4","name":"pesquisa por pedido id","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1706534534816,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_4565d46e6096493e97c5acd0a64a8647","parentId":"wrk_8481d2f882ae41f4930912932111267a","modified":1698374960723,"created":1698374960723,"name":"pagamento","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1698374960724,"_type":"request_group"},{"_id":"req_d38322967b2e4d49aa01ee8fc02cc775","parentId":"fld_4565d46e6096493e97c5acd0a64a8647","modified":1710846465201,"created":1698374962819,"url":"{{ _.url_base }}/pedido/checkout/4","name":"checkout aprovado","description":"","method":"PATCH","body":{"mimeType":"application/json","text":"{\n\t\"status\":\"aprovado\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"}],"authentication":{},"metaSortKey":-1698374962819,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_8c845cd07dbb45d1ae3790350f13f12d","parentId":"fld_4565d46e6096493e97c5acd0a64a8647","modified":1706564762719,"created":1706493424405,"url":"{{ _.url_base }}/pedido/checkout/2","name":"checkout recusado","description":"","method":"PATCH","body":{"mimeType":"application/json","text":"{\n\t\"status\":\"recusado\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"}],"authentication":{},"metaSortKey":-1698350447246,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_a9c8aa9953bb449c8bbb220633244f0e","parentId":"fld_1dbe745786d64ab7a5298b6c1c164143","modified":1710887554289,"created":1698325931673,"url":"{{ _.url_base }}/pedido","name":"cadastra","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"cliente_id\": 1,\n\t\"produtos\": [\n\t\t1\n\t],\n\t\"observacao\":\"sem gelo\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_f59824cd79914aceb44d27d9d38861b7"}],"authentication":{"type":"bearer","token":"{{ _.token }}","disabled":false},"metaSortKey":-1698325931673,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_1dbe745786d64ab7a5298b6c1c164143","parentId":"wrk_8481d2f882ae41f4930912932111267a","modified":1698374887663,"created":1698374887663,"name":"pedido","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1698374887663,"_type":"request_group"},{"_id":"req_93b1b9667e304aaba96a11f927871c5f","parentId":"fld_1dbe745786d64ab7a5298b6c1c164143","modified":1710846445079,"created":1698382118206,"url":"{{ _.url_base }}/pedido/4","name":"atualiza status","description":"","method":"PATCH","body":{"mimeType":"application/json","text":"{\n\t\"status\": \"pronto\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"}],"authentication":{},"metaSortKey":-1698319448907.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_8ae03330a1da4ad491b7a1cd95cbfc95","parentId":"fld_1dbe745786d64ab7a5298b6c1c164143","modified":1710846381207,"created":1698374903450,"url":"{{ _.url_base }}/pedidos/aguardando_pagamento","name":"lista por status","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1698312966142.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_837c86d5d1a54206b03512a1e43b5e66","parentId":"fld_1dbe745786d64ab7a5298b6c1c164143","modified":1710846369965,"created":1698381768368,"url":"{{ _.url_base }}/pedido/detail/4","name":"detalhe do pedido","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{"type":"bearer","token":"{{ _.token }}"},"metaSortKey":-1698306483377.25,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_bd0210eac694459e8d8756244892a5fa","parentId":"fld_cf279015735e45829fb596bb4db7d80a","modified":1710846337095,"created":1698300000612,"url":"{{ _.url_base }}/produto/2","name":"atualiza","description":"","method":"PUT","body":{"mimeType":"application/json","text":"{\n\t\"descricao\": \"coca copo 500ml\",\n\t\"categoria\": \"bebida\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"}],"authentication":{},"metaSortKey":-1698300000612,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_cf279015735e45829fb596bb4db7d80a","parentId":"wrk_8481d2f882ae41f4930912932111267a","modified":1698293736640,"created":1698293736640,"name":"produto","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1698293736640,"_type":"request_group"},{"_id":"req_6c7af19c9e124044ab43e94e5acfc7a4","parentId":"fld_cf279015735e45829fb596bb4db7d80a","modified":1710846332670,"created":1698296649946,"url":"{{ _.url_base }}/produto/2","name":"delete","description":"","method":"DELETE","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1698296649946,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_cb2c4136b5fa4c1b8fc13ca955348ed7","parentId":"fld_cf279015735e45829fb596bb4db7d80a","modified":1706565020377,"created":1698294366673,"url":"{{ _.url_base }}/produto","name":"cadastra","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"descricao\": \"coca copo 600ml\",\n\t\"categoria\": \"bebida\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"}],"authentication":{},"metaSortKey":-1698294366673,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_145bd57fd1ec4b89b16189c2bd79ec12","parentId":"fld_cf279015735e45829fb596bb4db7d80a","modified":1706564797662,"created":1698293739470,"url":"{{ _.url_base }}/produtos/bebida","name":"lista por categoria","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1698293739470,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_d67d1080373d4fef909873b215b76dd4","parentId":"fld_a8766185ca06450280740980135f078c","modified":1716190915811,"created":1710846003402,"url":"{{ _.lambda_url_base }}/login","name":"Login Lambda","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"cpf\": \"44773439068\",\n\t\"api_url\": \"http://ae9cc1af00cdb488ea524a1da64bf434-730275616.us-east-2.elb.amazonaws.com:3000\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/8.3.0"}],"authentication":{},"metaSortKey":-1710846003402,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_a8766185ca06450280740980135f078c","parentId":"wrk_8481d2f882ae41f4930912932111267a","modified":1698206794413,"created":1698206794413,"name":"cliente","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1698206794413,"_type":"request_group"},{"_id":"req_2e1157d7d85f457794a9678c582d5c2f","parentId":"fld_a8766185ca06450280740980135f078c","modified":1710846302207,"created":1698206799032,"url":"{{ _.url_base }}/clientes/90973502045","name":"pesquisa por cpf","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{"type":"bearer","token":"{{ _.token }}"},"metaSortKey":-1698206799032,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_c94841ed670245178a91dec0cd14ba9b","parentId":"fld_a8766185ca06450280740980135f078c","modified":1710887477899,"created":1698206808023,"url":"{{ _.url_base }}/cliente","name":"cadastra","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"cpf\":\"44773439068\",\n\t\"dataAniversario\": \"\",\n\t\"email\": \"teste@gmail.com\",\n\t\"nome\": \"Teste da silva\",\n\t\"telefone\": \"81988776655\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"}],"authentication":{},"metaSortKey":-1698206798982,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_9b3f48ea4d154b98813e0636c712afc8","parentId":"wrk_8481d2f882ae41f4930912932111267a","modified":1716190738381,"created":1698206786244,"name":"Base Environment","data":{"url_base":"http://acda3f5f77ba8462791b8388ccfca252-696104606.us-east-2.elb.amazonaws.com:3000","url_pagamentos":"http://a944acb4bed704d70a89dd1954ab4f2a-1358234581.us-east-2.elb.amazonaws.com:3000","url_pedidos":"http://a1add9dc3ca4947d2a77eb4e30732fc8-105748139.us-east-2.elb.amazonaws.com:3000","url_producao":"http://a98e5e4bb80e143868a3a02806dbc204-119303974.us-east-2.elb.amazonaws.com:3000","lambda_url_base":"https://9rm0y2audl.execute-api.us-east-2.amazonaws.com/Prod","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcGYiOiI5MDk3MzUwMjA0NSIsIklzQWRtaW4iOnRydWUsImV4cCI6MTcxMDg0OTY1NX0.Yb7drGh4EbD0Nzu6yhTUS9z2GUqGuDdkXmQthkKtVyc"},"dataPropertyOrder":{"&":["url_base","url_pagamentos","url_pedidos","url_producao","lambda_url_base","token"]},"color":null,"isPrivate":false,"metaSortKey":1698206786244,"_type":"environment"},{"_id":"jar_5b8460dd8d8d4f89b808a18ef6971834","parentId":"wrk_8481d2f882ae41f4930912932111267a","modified":1698206786245,"created":1698206786245,"name":"Default Jar","cookies":[],"_type":"cookie_jar"}]}