[fix] Do not allow applying more than 1 templates of same VPN server #832#1020
Conversation
| Validates if there are duplicate templates for the same VPN server. | ||
| Raises a ValidationError if duplicates are found. | ||
| """ | ||
| if action != 'pre_add': |
There was a problem hiding this comment.
This check makes the following test fail - when users switches the template of the device and both the templates belongs to the same VPN.
It happens because pre_add action is sent before pre_clear, thus the db still has old template assigned to the config and this logic raises an error.
openwisp-controller/openwisp_controller/config/tests/test_admin.py
Lines 2056 to 2163 in ccf380c
f6b1a44 to
a130437
Compare
a946356 to
dc499d2
Compare
There was a problem hiding this comment.
I tried replicating #832 on the current master and I couldn't do so, I get an uncaught exception instead:
Are you sure all the new logic is 100% needed? It seems recent changes already half-handled this.
Trying the same operation on this branch gives me the following result which is a lot better and matches your testing:
I have other observations below.
The ValidationError you saw is raised by openwisp-controller/openwisp_controller/config/base/config.py Lines 333 to 346 in dc499d2 But, this is called in This PR performs validation of VPN Client templates and ensures the error is caught before |
ee6a49e to
5b8f9df
Compare
5b8f9df to
2e24377
Compare



Checklist
Reference to Existing Issue
Fixes #832
Screenshot