def test_valid_signature(self):
        headers1 = SlashCommandHeaders(
            slack_request_timestamp=1531420618,
            slack_signature=
            'v0=a2114d57b48eac39b9ad189dd8316235a7b4a8d21a10bd27519666489c69b503'
        )
        body1 = 'token=xyzz0WbapA4vBCDEFasx0q6G&team_id=T1DC2JH3J&team_domain=testteamnow&channel_id=G8PSS9T3V' \
                '&channel_name=foobar&user_id=U2CERLKJA&user_name=roadrunner&command=%2Fwebhook-collect&text' \
                '=&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT1DC2JH3J%2F397700885554' \
                '%2F96rGlfmibIGlgcZRskXaIFfN&trigger_id=398738663015.47445629121.803a0bc887a14d10d2c447fce8b6703c'

        actual1 = FileControllerHelper.valid_signature(
            headers1, body1, '8f742231b10e8888abcd99yyyzzz85a5')
        self.assertTrue(actual1)

        headers2 = SlashCommandHeaders(slack_request_timestamp=1531420618,
                                       slack_signature='v0=wrong')
        body2 = 'token=xyzz0WbapA4vBCDEFasx0q6G&team_id=T1DC2JH3J&team_domain=testteamnow&channel_id=G8PSS9T3V' \
                '&channel_name=foobar&user_id=U2CERLKJA&user_name=roadrunner&command=%2Fwebhook-collect&text' \
                '=&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT1DC2JH3J%2F397700885554' \
                '%2F96rGlfmibIGlgcZRskXaIFfN&trigger_id=398738663015.47445629121.803a0bc887a14d10d2c447fce8b6703c'
        actual2 = FileControllerHelper.valid_signature(
            headers2, body2, '8f742231b10e8888abcd99yyyzzz85a5')
        self.assertFalse(actual2)
    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)