def list(self, event: Dict) -> Dict[str, Union[int, Dict[str, str], str]]:
        try:
            is_local = self.__env_vars.stage == 'local'

            valid_timestamp = True
            valid_signature = True
            if not is_local:
                headers: SlashCommandHeaders = FileControllerHelper.get_command_header(event)

                raw_body = FileControllerHelper.get_raw_body(event)
                valid_signature = FileControllerHelper.valid_signature(
                    headers,
                    raw_body,
                    self.__env_vars.slack_signing_secret)
                valid_timestamp = FileControllerHelper.valid_timestamp(headers.slack_request_timestamp)
            if not valid_timestamp:
                raise InvalidTimestampException(event['headers'])
            if not valid_signature:
                raise InvalidSignatureException(event['headers'])

            body: SlashCommandBody = FileControllerHelper.get_command_body(event)
            FileControllerHelper.validate_body(body)
            parsed_text: ParsedText = FileControllerHelper.parse_text(body.text)

            input_data: FileListInput = FileListInput(
                token=self.__env_vars.token,
                date_from=parsed_text.date_from,
                date_to=parsed_text.date_to,
                channel=body.channel_id if parsed_text.all_channels else None,
                user=body.user_id if parsed_text.all_users else None,
            )

            output: FileListOutput = self.__usecase.handle(input_data)
            return self.__presenter.complete(output, None)
        except Exception as ex:
            return self.__presenter.complete(FileListOutput([]), ex)
    def test_validate_body__ok(self):
        body1 = SlashCommandBody(
            token='token1',
            user_id='user_id1',
            channel_id='channel_id1',
            command='command1',
            text='to=2020/01/01 from=2020/11/11',
        )
        FileControllerHelper.validate_body(body1)

        body2 = SlashCommandBody(
            token='token2',
            user_id='user_id2',
            channel_id='channel_id2',
            command='command2',
            text=' to=2020/01/01   from=2020/11/11',
        )
        FileControllerHelper.validate_body(body2)

        body3 = SlashCommandBody(
            token='token3',
            user_id='user_id3',
            channel_id='channel_id3',
            command='command3',
            text=' to=2020/01/01 from=2020/11/11 -ac -au',
        )
        FileControllerHelper.validate_body(body3)

        body4 = SlashCommandBody(
            token='token4',
            user_id='user_id4',
            channel_id='channel_id4',
            command='command4',
            text=' to=2020/01/01 from=2020/11/11 --all-channels --all-users',
        )
        FileControllerHelper.validate_body(body4)

        body5 = SlashCommandBody(
            token='token5',
            user_id='user_id5',
            channel_id='channel_id5',
            command='command5',
            text=' to=2020/01/01 from=2020/11/11 -ac',
        )
        FileControllerHelper.validate_body(body5)

        body6 = SlashCommandBody(
            token='token6',
            user_id='user_id6',
            channel_id='channel_id6',
            command='command6',
            text=' to=2020/01/01 from=2020/11/11 -au',
        )
        FileControllerHelper.validate_body(body6)

        body7 = SlashCommandBody(
            token='token7',
            user_id='user_id7',
            channel_id='channel_id7',
            command='command7',
            text=' to=2020/01/01 from=2020/11/11 --all-users',
        )
        FileControllerHelper.validate_body(body7)

        body8 = SlashCommandBody(
            token='token8',
            user_id='user_id8',
            channel_id='channel_id8',
            command='command8',
            text=' to=2020/01/01 from=2020/11/11 --all-channels',
        )
        FileControllerHelper.validate_body(body8)
    def test_validate_body__raise(self):
        body1 = SlashCommandBody(
            token='',
            user_id='user_id1',
            channel_id='channel_id1',
            command='command1',
            text='to=2020/01/01 from=2020/11/11',
        )
        with self.assertRaises(ValidationException):
            FileControllerHelper.validate_body(body1)

        body2 = SlashCommandBody(
            token='token2',
            user_id='',
            channel_id='channel_id2',
            command='command2',
            text='to=2020/01/01 from=2020/11/11',
        )
        with self.assertRaises(ValidationException):
            FileControllerHelper.validate_body(body2)

        body3 = SlashCommandBody(
            token='token3',
            user_id='user_id3',
            channel_id='',
            command='command3',
            text='to=2020/01/01 from=2020/11/11',
        )
        with self.assertRaises(ValidationException):
            FileControllerHelper.validate_body(body3)

        body4 = SlashCommandBody(
            token='token4',
            user_id='user_id4',
            channel_id='channel_id4',
            command='',
            text='to=2020/01/01 from=2020/11/11',
        )
        with self.assertRaises(ValidationException):
            FileControllerHelper.validate_body(body4)

        body5 = SlashCommandBody(
            token='token5',
            user_id='user_id5',
            channel_id='channel_id5',
            command='command5',
            text='',
        )
        with self.assertRaises(ValidationException):
            FileControllerHelper.validate_body(body5)

        body6 = SlashCommandBody(
            token='token6',
            user_id='user_id6',
            channel_id='channel_id6',
            command='command6',
            text='to=2020/01/01 from=xxxx/xx/xx',
        )
        with self.assertRaises(ValidationException):
            FileControllerHelper.validate_body(body6)

        body7 = SlashCommandBody(
            token='token7',
            user_id='user_id7',
            channel_id='channel_id7',
            command='command7',
            text='to=xxxx/xx/xx from=2020/10/10',
        )
        with self.assertRaises(ValidationException):
            FileControllerHelper.validate_body(body7)