Skip to content

Create Mock Http tests for Slack Tokens#524

Merged
eddynaka merged 7 commits into
mainfrom
users/bpendragon/SlackTokenFixes
Aug 4, 2021
Merged

Create Mock Http tests for Slack Tokens#524
eddynaka merged 7 commits into
mainfrom
users/bpendragon/SlackTokenFixes

Conversation

@Bpendragon

Copy link
Copy Markdown
Contributor
  • Converts SlackTokenValidator from using WebClient to HttpClient
  • Adds Mock Http calls to SlackTokenValidatorTests to properly test all code paths.

Comment thread Src/Plugins/Security/SEC101_005.SlackTokenValidator.cs Outdated
new
{
Title = "Testing Unknown Slack Error",
HttpStatusCode = HttpStatusCode.OK,

@eddynaka eddynaka Aug 3, 2021

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpStatusCode.OK

let's add badrequest -> httpcontent = null -> and save as unexpectedstatuscode #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Slack almost always returns a 200 to any request, even if malformed. This catches if the response is not that.
{
case "token_revoked":
case "account_inactive": { return ValidationState.Expired; }
case "invalid_auth": { return ReturnUnauthorizedAccess(ref message, fingerprint.Secret); }

@eddynaka eddynaka Aug 3, 2021

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReturnUnauthorizedAccess

dont do this. use validationState.unauthorized. If you do this, you are going to save the secret in the message. #Closed

@eddynaka eddynaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@eddynaka eddynaka enabled auto-merge (squash) August 4, 2021 00:29
@eddynaka eddynaka merged commit 4ca1e08 into main Aug 4, 2021
@eddynaka eddynaka deleted the users/bpendragon/SlackTokenFixes branch August 4, 2021 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants