-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup CustomButton
backend code + add ngrok
/express
outgoing webhook e2e test
#2544
Conversation
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically closed because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
'passed_last_time': None, | ||
'escalation_counter': 0, | ||
'last_notified_user': None, | ||
'custom_button_trigger': None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than just remove the custom_button_trigger
field here from the docstring, I don't think we should be documenting large types like this in the docstring (this is what type hints are for 🙂)
def test_create_invalid_ical_schedule(schedule_internal_api_setup, make_user_auth_headers): | ||
user, token, _, _, _, _ = schedule_internal_api_setup | ||
client = APIClient() | ||
url = reverse("api-internal:custom_button-list") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this was intentional? 🤔
…fana/oncall into jorlando/cleanup-custom-button-stuff
const app = express(); | ||
app.use(express.json()); | ||
app.post('/', (req, res) => { | ||
resolveRequest(req.body); // Resolve the promise with the request body | ||
res.send('ok'); | ||
}); | ||
app.listen(PORT); | ||
|
||
/** | ||
* TODO: this might need to be parametrized to be read from an env var | ||
* rather than hardcoding the hostname to be host.docker.internal | ||
*/ | ||
const webhookUrl = `http://host.docker.internal:${PORT}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried using ngrok
here.. this worked locally, but it seems like there was some issues on CI, with the API being able to communicate with the express
server's public internet URL assigned by ngrok
(see test failure here).
Refactored in 3f66b87 to use host.docker.internal
instead.
See this Slack conversation for more context
@@ -52,34 +50,6 @@ def __repr__(self): | |||
return "%s()" % self.__class__.__name__ | |||
|
|||
|
|||
class URLValidatorWithoutTLD(URLValidator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember I added this because some OSS users wanted to make requests to docker containers, which default url validator didn't permit. Do we have url validation for webhooks url? if so, should we use something like that there:
if live_settings.DANGEROUS_WEBHOOKS_ENABLED:
URLValidatorWithoutTLD()(webhook)
else:
URLValidator()(webhook)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 I believe that's how apps.webhooks.utils.parse_url
works.
fwiw the URLValidatorWithoutTLD
class was only referenced within the CustomButton
model, so to me it made sense to remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct DANGEROUS_WEBHOOKS_ENABLED settings is handled there. Validation happens later in the process now since URLs can be templates
# What this PR does See [this conversation](https://raintank-corp.slack.com/archives/C025VMT6SPK/p1711991400490289) for more context. Also removes the `EscalationPolicy.custom_button_trigger` field which was previously marked as deprecated in #2544 and migrated [here](https://github.com/grafana/oncall/blob/dev/engine/apps/webhooks/migrations/0008_auto_20230712_1613.py#L39-L45) ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated (N/A) - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes.
What this PR does
ngrok
/express
webhook handler receives the call as expected + payload is as expected (related to Add suite of e2e tests for new webhook functionality #2691) - skipped for now, the test passes locally but fails on GitHub Actions CI, seems to be networking relatedChecklist
pr:no public docs
PR label added if not required)