Skip to content

Commit

Permalink
Merge pull request #7 from postech-5soat-grupo-25/alanmmolina/hackath…
Browse files Browse the repository at this point in the history
…on/alterando-email-remetente

atualizando remetente e corrigindo erro na lambda
  • Loading branch information
alanmmolina authored Sep 27, 2024
2 parents c632bd9 + 8d2a252 commit ec0416f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/lambda/auth/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def lambda_handler(event, context):
except client.exceptions.NotAuthorizedException:
return {
"statusCode": 401,
"body": json.dumps({"message": "Credenciais inválidas", "response": str(response)}),
"body": json.dumps({"message": "Credenciais inválidas"}),
}
except Exception as error:
return {
"statusCode": 400,
"body": json.dumps({"message": str(error), "response": str(response)}),
"body": json.dumps({"message": str(error)}),
}
18 changes: 18 additions & 0 deletions tests/email.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

API_GATEWAY_ID="..."
SES_REGION="us-east-1"
FROM_EMAIL="..."
TO_EMAIL="..." # E-mail do médico a ser enviado
NOME_MEDICO="Dr. João" # Nome do médico
NOME_PACIENTE="Alan" # Nome do paciente
DATA="2024-09-30" # Data da consulta
HORARIO="14:00" # Horário da consulta

# Chamando o endpoint /email
echo "Enviando o e-mail de confirmação..."
response=$(curl -X POST https://$API_GATEWAY_ID.execute-api.us-east-1.amazonaws.com/prod/email \
-H "Content-Type: application/json" \
-d "{\"email_medico\": \"$TO_EMAIL\", \"nome_medico\": \"$NOME_MEDICO\", \"nome_paciente\": \"$NOME_PACIENTE\", \"data\": \"$DATA\", \"horario\": \"$HORARIO\"}")

echo "Resposta da API: $response"
31 changes: 31 additions & 0 deletions tests/login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

API_GATEWAY_ID="..."
USER_POOL_ID="..."
USERNAME="..."
PASSWORD="..."

# Cria o usuário com uma senha temporária
echo "Criando o usuário..."
aws cognito-idp admin-create-user \
--user-pool-id $USER_POOL_ID \
--username $USERNAME \
--user-attributes Name=email,Value=$USERNAME \
--temporary-password $PASSWORD \
--message-action SUPPRESS > /dev/null 2>&1

# Altera a senha para uma permanente
echo "Alterando a senha para uma permanente..."
aws cognito-idp admin-set-user-password \
--user-pool-id $USER_POOL_ID \
--username $USERNAME \
--password $PASSWORD \
--permanent > /dev/null 2>&1

echo "Usuário criado e senha alterada com sucesso!"

# Faz login usando o API Gateway
echo "Realizando o login..."
curl -X POST https://$API_GATEWAY_ID.execute-api.us-east-1.amazonaws.com/prod/login \
-H "Content-Type: application/json" \
-d "{\"email\": \"$USERNAME\", \"password\": \"$PASSWORD\"}"

0 comments on commit ec0416f

Please sign in to comment.