@@ -1494,3 +1494,57 @@ def test_admin_menu_groups(self):
14941494 with self .subTest ("test radius group is registered" ):
14951495 html = '<div class="mg-dropdown-label">RADIUS </div>'
14961496 self .assertContains (response , html , html = True )
1497+
1498+
1499+ class TestRadiusGroupAdmin (BaseTestCase ):
1500+ def setUp (self ):
1501+ self .organization = self ._create_org ()
1502+ self .admin = self ._create_admin ()
1503+ self .organization .add_user (self .admin , is_admin = True )
1504+ self .client .force_login (self .admin )
1505+
1506+ def test_add_radiusgroup_with_inline_check_succeeds (self ):
1507+ add_url = reverse ("admin:openwisp_radius_radiusgroup_add" )
1508+
1509+ post_data = {
1510+ # Main RadiusGroup form
1511+ "organization" : self .organization .pk ,
1512+ "name" : "test-group-with-inline" ,
1513+ "description" : "A test group created with an inline check" ,
1514+ # Inline RadiusGroupCheck formset
1515+ "radiusgroupcheck_set-TOTAL_FORMS" : "1" ,
1516+ "radiusgroupcheck_set-INITIAL_FORMS" : "0" ,
1517+ "radiusgroupcheck_set-0-attribute" : "Max-Daily-Session" ,
1518+ "radiusgroupcheck_set-0-op" : ":=" ,
1519+ "radiusgroupcheck_set-0-value" : "3600" ,
1520+ # Inline RadiusGroupReply formset
1521+ "radiusgroupreply_set-TOTAL_FORMS" : "1" ,
1522+ "radiusgroupreply_set-INITIAL_FORMS" : "0" ,
1523+ "radiusgroupreply_set-0-attribute" : "Session-Timeout" ,
1524+ "radiusgroupreply_set-0-op" : "=" ,
1525+ "radiusgroupreply_set-0-value" : "1800" ,
1526+ }
1527+
1528+ response = self .client .post (add_url , data = post_data , follow = True )
1529+
1530+ self .assertEqual (response .status_code , 200 )
1531+ final_group_name = f"{ self .organization .slug } -test-group-with-inline"
1532+
1533+ self .assertContains (response , "The group" )
1534+ self .assertContains (response , f"{ final_group_name } </a>" )
1535+ self .assertContains (response , "was added successfully." )
1536+
1537+ self .assertTrue (RadiusGroup .objects .filter (name = final_group_name ).exists ())
1538+ group = RadiusGroup .objects .get (name = final_group_name )
1539+
1540+ self .assertEqual (group .radiusgroupcheck_set .count (), 1 )
1541+ check = group .radiusgroupcheck_set .first ()
1542+ self .assertEqual (check .attribute , "Max-Daily-Session" )
1543+ self .assertEqual (check .value , "3600" )
1544+ self .assertEqual (check .groupname , group .name )
1545+
1546+ self .assertEqual (group .radiusgroupreply_set .count (), 1 )
1547+ reply = group .radiusgroupreply_set .first ()
1548+ self .assertEqual (reply .attribute , "Session-Timeout" )
1549+ self .assertEqual (reply .value , "1800" )
1550+ self .assertEqual (reply .groupname , group .name )
0 commit comments