from aws_lambda_powertools.utilities.typing import LambdaContext

import events.email_receiving as app

event = {
    'Records': [
        {
            'eventSource': 'aws:ses',
            'eventVersion': '1.0',
            'ses': {
                'mail': {
                    'timestamp': '2025-05-29T15:50:41.604Z',
                    'source': 'sergio@somosbeta.com.br',
                    'messageId': '2994higq3tr7efijr3lj65etntffapgg1q7hea81',
                    'destination': [
                        'org+15608435000190@users.noreply.saladeaula.digital'
                    ],
                    'headersTruncated': False,
                    'headers': [
                        {'name': 'Return-Path', 'value': '<sergio@somosbeta.com.br>'},
                        {
                            'name': 'Received',
                            'value': 'from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by inbound-smtp.sa-east-1.amazonaws.com with SMTP id 2994higq3tr7efijr3lj65etntffapgg1q7hea81 for org+35980592000130@users.noreply.saladeaula.digital; Thu, 29 May 2025 15:50:41 +0000 (UTC)',
                        },
                        {'name': 'X-SES-Spam-Verdict', 'value': 'PASS'},
                        {'name': 'X-SES-Virus-Verdict', 'value': 'PASS'},
                        {
                            'name': 'Received-SPF',
                            'value': 'pass (spfCheck: domain of somosbeta.com.br designates 209.85.167.54 as permitted sender) client-ip=209.85.167.54; envelope-from=sergio@somosbeta.com.br; helo=mail-lf1-f54.google.com;',
                        },
                        {
                            'name': 'Authentication-Results',
                            'value': 'amazonses.com; spf=pass (spfCheck: domain of somosbeta.com.br designates 209.85.167.54 as permitted sender) client-ip=209.85.167.54; envelope-from=sergio@somosbeta.com.br; helo=mail-lf1-f54.google.com; dkim=pass header.i=@somosbeta.com.br; dmarc=none header.from=somosbeta.com.br;',
                        },
                        {
                            'name': 'X-SES-RECEIPT',
                            'value': 'AEFBQUFBQUFBQUFHVWpuODdPY2tGUlordE5YWkVEUlZNWWZFYkpDMU5MUURyaHNVSldnTGhEVWhCQzd5UGpzWHI4LzJoS1VaN0lOU0FkMzJFU0h6MjVuUzk2c09KUXlzbUJQdHd6T0d0Y2ptZXhRVk1KY3RkOXpRamZMb3hwSGJIVlFla2tBcmZvRmYwQS9WU3hBVlBqcUpDYm00eTdiRnRqNW45ek9ld0ZyTGJKV3k2TXRpc0J6aGhBdmFvZDFDQ000Zm9QTng3VHljNXArM0hjT2ZsYkhtM3RCZnpRV1NOczU2RDdmL0RKclJOcDNvY2ZxV1hmajNYMkczVHpsWEZCMm40Z2pQM29udkMyb01vN3JwU0p2TUI1WGorN2JPd2RPYW5lUDN3T3RMRlhsdEpGbGNCa3c9PQ==',
                        },
                        {
                            'name': 'X-SES-DKIM-SIGNATURE',
                            'value': 'a=rsa-sha256; q=dns/txt; b=KPtFiBwsOTBl1YVLRTSfaZ+X6h7uSSOu/i1Cw6Pd+wvMBHRWy9EYcWUjyDjsLG/uYHShLW4+LHsSg9HiqrAP2jVJSAawrIwZr1wPQo7ovQvWuZfHQN/StgXIgBU+L7Bp6GSR26LRufxjj7q9YBmEeirjJ3d0G8E/rF2QqeITlpo=; c=relaxed/simple; s=bm3ypaoivbtdzmy3b6w37fzb5voa2uru; d=amazonses.com; t=1748533842; v=1; bh=kTUCV1DQAazu4FsUi1MrelD2QvSfHGArZ/c6A79t3/E=; h=From:To:Cc:Bcc:Subject:Date:Message-ID:MIME-Version:Content-Type:X-SES-RECEIPT;',
                        },
                        {
                            'name': 'Received',
                            'value': 'by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-54b0d638e86so1570269e87.1 for <org+35980592000130@users.noreply.saladeaula.digital>; Thu, 29 May 2025 08:50:40 -0700 (PDT)',
                        },
                        {
                            'name': 'DKIM-Signature',
                            'value': 'v=1; a=rsa-sha256; c=relaxed/relaxed; d=somosbeta.com.br; s=google; t=1748533838; x=1749138638; darn=users.noreply.saladeaula.digital; h=to:subject:message-id:date:from:in-reply-to:references:mime-version:from:to:cc:subject:date:message-id:reply-to; bh=kTUCV1DQAazu4FsUi1MrelD2QvSfHGArZ/c6A79t3/E=; b=Qi8gk/kTpwXCLDM7FPS7ULTy+9gO/4WsGL9zY1xEDw0Rp38f4rVR8L95hIhwK2daA27mq3pv9TdrK3XKQQIuSvRVvaM0b/evkZD8QhaT9tCmL0eKEBB4czGB0OSS3Q4qP34GFWMmXIaxoKIo1td76JnXbto9ZQvjUTBr3GGlF3Lm/MPTaAHs1b3dalv2diTvyj1tzoeb4wGePKsqLh5LKGOxbbWsxPeHEJ8sLM4LyJjxoqSOO0wgKdH5S/ZNpHWcJtXBntjiDUZNeQ5ucEn8ZLbADCObZZV/gH9i/cB1BmlSvJP3D07uJTAEBqyepd+W9fIW2mox/+fmOb3OEHRthQ==',
                        },
                        {
                            'name': 'X-Google-DKIM-Signature',
                            'value': 'v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748533838; x=1749138638; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kTUCV1DQAazu4FsUi1MrelD2QvSfHGArZ/c6A79t3/E=; b=UnL/uRXRahnH5uStZ276LH4kqpHigngw4iql9GHKmFaIKxJ8hLGn/wu7ie4ljnw8m/ I4CvhDKH4TVtIWPS81fm06PMgeqQYRX3jLhHvIltROCNVX6ZFzbAXgiAlk0NS1npvDYJ evVgSaPPco4D/8pMWZX4fUjU+8me32ChKxHsklEAts/LiD+MvTuHCHZovSEj1aXAz91b yGZe1bx2+phuqzUZyIOeheKjl4TNjEBx83omOzf9HtClKhjzCwHjfZ8uk2lhJ10ogKZ0 GNQ5OlnPkgdAg0/+HsifvGR6xfkFsiunIDyinBWoOhMU1o0+DiicxOIjY8QEayF3MLUt REoA==',
                        },
                        {
                            'name': 'X-Gm-Message-State',
                            'value': 'AOJu0Yxw0icQkFV090vn5hx/hKp0ePH78Wr0iqi4V3x4mpVXrRX8te2o 30aBYeZRPwn8SRSrq/kbn4bLcs5mPDB+iRP9IGFxS7KLSQi+KG4PQeDHyW3R/AgOPHACUUXUUyz Vcwny029WGY5PVhxlikAYdDfhNdO8GM2DKMV1+Oxy/a+qmt5LZeuy',
                        },
                        {
                            'name': 'X-Gm-Gg',
                            'value': 'ASbGncslCMPPU/pax0+RNy/cQR/Y/wUroSJMvI2DCCMq6Qld+Ih1jG4+HnhQPqn3nTK EEW6/99tqazq+SKy+31AB77ajVczvJQTElRSW/+bhd42l7by2hicTKElcR3GWivlrqd1TywUZOB DkB9J/vupSV0PDCJfZVi+7Tb9Pb61nnxaU+SQ=',
                        },
                        {
                            'name': 'X-Google-Smtp-Source',
                            'value': 'AGHT+IFYi41KmJjGcfQmUvWJDdTAzGIv2JlL9XAwBpAb53mMOOm3tttzkhbvfuiKh/DI9NjITHuO3xuEPqnPI9lpum8=',
                        },
                        {
                            'name': 'X-Received',
                            'value': 'by 2002:a05:6512:1392:b0:553:2f61:58f1 with SMTP id 2adb3069b0e04-5532f615a8dmr2268707e87.53.1748533837647; Thu, 29 May 2025 08:50:37 -0700 (PDT)',
                        },
                        {'name': 'MIME-Version', 'value': '1.0'},
                        {
                            'name': 'References',
                            'value': '<CAMThe4mV9=1-BLiOi9MU3fAS=C6uYE9+3hKUjibrwxxngYNn2Q@mail.gmail.com>',
                        },
                        {
                            'name': 'In-Reply-To',
                            'value': '<CAMThe4mV9=1-BLiOi9MU3fAS=C6uYE9+3hKUjibrwxxngYNn2Q@mail.gmail.com>',
                        },
                        {
                            'name': 'From',
                            'value': 'Sérgio Rafael Siqueira <sergio@somosbeta.com.br>',
                        },
                        {'name': 'Date', 'value': 'Thu, 29 May 2025 12:50:26 -0300'},
                        {
                            'name': 'X-Gm-Features',
                            'value': 'AX0GCFvofROqzf21KTgiIJq_AULCNljEuNFUJBk2xQGwVKmPjim_4slYIOP0WRw',
                        },
                        {
                            'name': 'Message-ID',
                            'value': '<CAMThe4=yMRJg4YOcACYAR509N1RyWyQgAghyVmr=NuSJnbondg@mail.gmail.com>',
                        },
                        {'name': 'Subject', 'value': 'Re: test'},
                        {
                            'name': 'To',
                            'value': 'org+15608435000190@users.noreply.saladeaula.digital',
                        },
                        {
                            'name': 'Content-Type',
                            'value': 'multipart/alternative; boundary="00000000000045b8c206364842b3"',
                        },
                    ],
                    'commonHeaders': {
                        'returnPath': 'sergio@somosbeta.com.br',
                        'from': ['"Sérgio Rafael Siqueira" <sergio@somosbeta.com.br>'],
                        'date': 'Thu, 29 May 2025 12:50:26 -0300',
                        'to': ['org+15608435000190@users.noreply.saladeaula.digital'],
                        'messageId': '<CAMThe4=yMRJg4YOcACYAR509N1RyWyQgAghyVmr=NuSJnbondg@mail.gmail.com>',
                        'subject': 'Re: test',
                    },
                },
                'receipt': {
                    'timestamp': '2025-05-29T15:50:41.604Z',
                    'processingTimeMillis': 1105,
                    'recipients': [
                        'org+15608435000190@users.noreply.saladeaula.digital'
                    ],
                    'spamVerdict': {'status': 'PASS'},
                    'virusVerdict': {'status': 'PASS'},
                    'spfVerdict': {'status': 'PASS'},
                    'dkimVerdict': {'status': 'PASS'},
                    'dmarcVerdict': {'status': 'GRAY'},
                    'action': {
                        'type': 'Lambda',
                        'functionArn': 'arn:aws:lambda:sa-east-1:336641857101:function:saladeaula-user-managemen-EventEmailReceivingFunct-LmnnEfi9tL2O',
                        'invocationType': 'Event',
                    },
                },
            },
        }
    ]
}


def test_email_receiving(dynamodb_seeds, lambda_context: LambdaContext):
    assert app.lambda_handler(event, lambda_context) == {'disposition': 'CONTINUE'}
