Skip to content

Reject Layer2 Address Changes if email notifications enabled but email is invalid - #1120

Merged
barryo merged 5 commits into
mainfrom
l2-email-error
Oct 9, 2026
Merged

barryo merged 5 commits into
mainfrom
l2-email-error

Conversation

@afk11

@afk11 afk11 commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

If notifications are enabled but there's no recipient, entering an email lead to a confusing 'AJAX Request failed' error, but when you refresh, the MAC was actually saved.

Edit: following comment from Barry, approached this a little differently

With this PR, if we are configured to email on superuser/customer changes, and the email is not valid, we disallow the change from taking place.

Making these changes highlighted an quirk in the Listener.. If configured to send email regarding superuser changes (disabled for customers), then modifications by a customer would still trigger an email. This isn't documented, and the two separate configuration values suggest they're independent controls.

I had tests covering the listener, but I'd misconfigured the test case and missed it. So I've rewritten the tests to make it clearer how the config interacts with things.

config()->set('ixp_fe.layer2-addresses.email_on_change_dest', 'notifications@ixp.local');
config()->set('ixp_fe.layer2-addresses.email_on_superuser_change', true);
config()->set('ixp_fe.layer2-addresses.email_on_customer_change', false);
$event = new Deleted("42:42:42:42:42:42", $vlanInterface, $user);
new Changed()->handle($event);
Mail::assertSent(ChangedMail::class, function (ChangedMail $mail) use ($event) {
return $mail->hasTo( 'notifications@ixp.local' ) &&
$mail->event === $event
;
});

@barryo

barryo commented Oct 6, 2026

Copy link
Copy Markdown
Member

Nice catch @afk11 - I think in the current implementation, you shouldn't be allowed to change the MAC unless there is some form of notification/handling. Right now, it's email or bust - so perhaps just don't allow it in this case rather than not sending the email.

…ethod, under same config, so it's easier to reason through tests. an old test relied on a quirt in the ChangeTest, so fixes that
@afk11 afk11 changed the title Don't attempt to send an Layer2 address change email if theres no recipient configured Reject Layer2 Address Changes if email notifications enabled but email is invalid Oct 9, 2026
@barryo
barryo merged commit bc80cc3 into main Oct 9, 2026
3 checks passed
@barryo
barryo deleted the l2-email-error branch October 9, 2026 13:54
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