mirror of
				https://salsa.debian.org/freeipa-team/freeipa.git
				synced 2025-02-25 18:55:28 -06:00 
			
		
		
		
	Implement nested netgroups and include summaries for the commands.
Replace the existing netgroup test cases with Declarative tests. This triples the number of tests we were doing. ticket 209
This commit is contained in:
		
				
					committed by
					
						 Adam Young
						Adam Young
					
				
			
			
				
	
			
			
			
						parent
						
							6df16f3a10
						
					
				
				
					commit
					03de1b89ca
				
			| @@ -199,14 +199,17 @@ class LDAPObject(Object): | ||||
|         return parent_dn | ||||
|  | ||||
|     def get_primary_key_from_dn(self, dn): | ||||
|         if self.rdn_attribute: | ||||
|             (dn, entry_attrs) = self.backend.get_entry( | ||||
|                 dn, [self.primary_key.name] | ||||
|             ) | ||||
|             try: | ||||
|                 return entry_attrs[pkey][0] | ||||
|             except (KeyError, IndexError): | ||||
|                 return '' | ||||
|         try: | ||||
|             if self.rdn_attribute: | ||||
|                 (dn, entry_attrs) = self.backend.get_entry( | ||||
|                     dn, [self.primary_key.name] | ||||
|                 ) | ||||
|                 try: | ||||
|                     return entry_attrs[self.primary_key.name][0] | ||||
|                 except (KeyError, IndexError): | ||||
|                     return '' | ||||
|         except errors.NotFound: | ||||
|             pass | ||||
|         return dn[len(self.primary_key.name) + 1:dn.find(',')] | ||||
|  | ||||
|     def get_ancestor_primary_keys(self): | ||||
|   | ||||
| @@ -46,6 +46,21 @@ from ipalib.plugins.baseldap import * | ||||
| from ipalib import _, ngettext | ||||
|  | ||||
|  | ||||
| output_params = ( | ||||
|         Str('memberuser_user?', | ||||
|             label='Member User', | ||||
|         ), | ||||
|         Str('memberuser_group?', | ||||
|             label='Member Group', | ||||
|         ), | ||||
|         Str('memberhost_host?', | ||||
|             label=_('Member Host'), | ||||
|         ), | ||||
|         Str('memberhost_hostgroup?', | ||||
|             label='Member Hostgroup', | ||||
|         ), | ||||
|     ) | ||||
|  | ||||
| class netgroup(LDAPObject): | ||||
|     """ | ||||
|     Netgroup object. | ||||
| @@ -56,7 +71,7 @@ class netgroup(LDAPObject): | ||||
|     object_class = ['ipaobject', 'ipaassociation', 'ipanisnetgroup'] | ||||
|     default_attributes = [ | ||||
|         'cn', 'description', 'memberof', 'externalhost', 'nisdomainname', | ||||
|         'memberuser', 'memberhost','member', 'memberindirect', | ||||
|         'memberuser', 'memberhost', 'member', 'memberindirect', | ||||
|     ] | ||||
|     uuid_attribute = 'ipauniqueid' | ||||
|     rdn_attribute = 'ipauniqueid' | ||||
| @@ -101,6 +116,8 @@ class netgroup_add(LDAPCreate): | ||||
|     """ | ||||
|     Add a new netgroup. | ||||
|     """ | ||||
|     has_output_params = LDAPCreate.has_output_params + output_params | ||||
|     msg_summary = _('Added netgroup "%(value)s"') | ||||
|     def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): | ||||
|         entry_attrs.setdefault('nisdomainname', self.api.env.domain) | ||||
|         return dn | ||||
| @@ -121,6 +138,8 @@ class netgroup_mod(LDAPUpdate): | ||||
|     """ | ||||
|     Modify a netgroup. | ||||
|     """ | ||||
|     has_output_params = LDAPUpdate.has_output_params + output_params | ||||
|     msg_summary = _('Modified netgroup "%(value)s"') | ||||
|  | ||||
| api.register(netgroup_mod) | ||||
|  | ||||
| @@ -129,6 +148,10 @@ class netgroup_find(LDAPSearch): | ||||
|     """ | ||||
|     Search for a netgroup. | ||||
|     """ | ||||
|     has_output_params = LDAPSearch.has_output_params + output_params | ||||
|     msg_summary = ngettext( | ||||
|         '%(count)d netgroup matched', '%(count)d netgroups matched' | ||||
|     ) | ||||
|  | ||||
| api.register(netgroup_find) | ||||
|  | ||||
| @@ -146,6 +169,7 @@ class netgroup_add_member(LDAPAddMember): | ||||
|     Add members to a netgroup. | ||||
|     """ | ||||
|     member_attributes = ['memberuser', 'memberhost', 'member'] | ||||
|     has_output_params = LDAPAddMember.has_output_params + output_params | ||||
|     def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): | ||||
|         completed_external = 0 | ||||
|         # Sift through the host failures. We assume that these are all | ||||
| @@ -180,7 +204,8 @@ class netgroup_remove_member(LDAPRemoveMember): | ||||
|     """ | ||||
|     Remove members from a netgroup. | ||||
|     """ | ||||
|     member_attributes = ['memberuser', 'memberhost'] | ||||
|     member_attributes = ['memberuser', 'memberhost', 'member'] | ||||
|     has_output_params = LDAPRemoveMember.has_output_params + output_params | ||||
|     def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options): | ||||
|         # Run through the host failures and gracefully remove any defined as | ||||
|         # as an externalhost. | ||||
|   | ||||
| @@ -90,7 +90,6 @@ hbacsvc = [ | ||||
| hbacsvcgroup = [ | ||||
|     u'ipaobject', | ||||
|     u'ipahbacservicegroup', | ||||
|     u'nestedGroup', | ||||
|     u'groupOfNames', | ||||
|     u'top', | ||||
| ] | ||||
| @@ -106,3 +105,9 @@ sudocmdgroup = [ | ||||
|     u'groupOfNames', | ||||
|     u'top', | ||||
| ] | ||||
|  | ||||
| netgroup = [ | ||||
|     u'ipaobject', | ||||
|     u'ipaassociation', | ||||
|     u'ipanisnetgroup', | ||||
| ] | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -39,6 +39,10 @@ fuzzy_uuid = Fuzzy( | ||||
|     '^[0-9a-f]{8}-[0-9a-f]{8}-[0-9a-f]{8}-[0-9a-f]{8}$' | ||||
| ) | ||||
|  | ||||
| # Matches netgroup dn | ||||
| fuzzy_netgroupdn = Fuzzy( | ||||
|     'ipauniqueid=[0-9a-f]{8}-[0-9a-f]{8}-[0-9a-f]{8}-[0-9a-f]{8},cn=ng,cn=alt,%s' % api.env.basedn | ||||
| ) | ||||
|  | ||||
| try: | ||||
|     if not api.Backend.xmlclient.isconnected(): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user