Skip to content
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

Fixes #32363 - Add test button #57

Merged
merged 1 commit into from Jun 19, 2023

Conversation

ofedoren
Copy link
Member

@ofedoren ofedoren commented Mar 27, 2023

Here is a quick demo with proxy being down/up in case the webhook is configured to use shellhooks:
Peek 2023-03-27 13-13

Although now I think it's better to enable the test button even if a webhook is disabled...

UPD: Needs theforeman/foreman#9666. Otherwise it's spamming
ScreenShot-1679911317681
in browser's console :/

UPD2: It would be awesome to make test fire use the actually attached template, but it's not possible until #38 is re-implemented. We could try to re-open that approach or create a different. I though about registering object type for event, but it would probably require rewriting the way we register event names :/ Or we could add this alongside, but I'm afraid we would duplicate registration process a bit. The new registration would allow us to register object type for event as well as a custom label for the event instead of automatically generated, which can be quite verbose in case of Action based events.

@ofedoren
Copy link
Member Author

@ares, @evgeni, I guess you both are interested in this feature :)

@evgeni
Copy link
Member

evgeni commented Mar 27, 2023

I like! (but didn't review the code)

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

I can't really speak to the js parts, but it works well. Two ideas inline

param :id, :identifier, required: true
param :payload, String
def test
result = @webhook.test(payload: params[:payload])
Copy link
Contributor

Choose a reason for hiding this comment

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

What tripped me up when I was testing this with curl was that the payload has to be a string. Would it make sense to try dumping it to json in case it is not a string?

def action_permission
case params[:action]
when 'test'
'view'
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably tighten things a bit and tie this to edit permission to make it a little bit harder to misuse.

@ofedoren
Copy link
Member Author

Thanks, @adamruzicka, incorporated.

@ares
Copy link
Member

ares commented Jun 7, 2023

I find this a great improvement already even without linking the template.

@ofedoren
Copy link
Member Author

Thanks, @ares!

@adamruzicka, could you please take a final look? I think we can leave this PR's scope to be able to test a webhook integration with other system, thus a custom payload will do. To test if assigned template can be rendered we will go with Preview button on the template's page, but that will be dealt with in another PR.

@adamruzicka
Copy link
Contributor

Could we make the modal stick around even on success?

Apart from this I don't really have anything to add

@ofedoren
Copy link
Member Author

Could we make the modal stick around even on success?

Done.

What do you think about allowing to test disabled webhooks? Currently the test button is gray-out if the webhook is disabled.

@adamruzicka
Copy link
Contributor

What do you think about allowing to test disabled webhooks?

It would probably make sense to allow that. I can see myself creating a webhook and keeping it disabled to prevent it from firing on its own until I'm sure I configured everything properly

@ofedoren
Copy link
Member Author

ofedoren commented Jun 14, 2023

Thanks, @adamruzicka, now it's possible to fire a test even for disabled webhooks.

UPD: Forgot to run JS linter, fixed now.

@ofedoren ofedoren merged commit 0bab5b6 into theforeman:master Jun 19, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants