directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Ayyagari <kayyag...@apache.org>
Subject Re: embedding ApacheDS for tests uisng NIS schema
Date Tue, 18 Dec 2012 07:32:34 GMT
try it this way

  @Before
 // simplest way to enable a schema in embedded mode
  public void enableNis() throws Exception  {
      if(!service.getSchemaManager().isEnabled( "nis" ))
      {
          service.getSchemaManager().enable( "nis" );
      }
  }

  //that will work just fine
  @Test
  @ApplyLdifs( {
          "dn: ou=groups,dc=mycompany,dc=com",
          "objectClass: organizationalUnit",
          "ou: groups",
          "description: Groups"
  }
  )
  public void authenticateAndAuthorizeFromDynamicGroup() throws Exception {
      // operators group
     // this needs to be added manually instead of adding using ApplyLdifs
     Entry entry = new DefaultEntry(
"cn=operators,ou=groups,dc=mycompany,dc=com",
      "objectClass: posixGroup",
      "cn: operators",
      "gidNumber: 5000",
      "description: Operators Group",
      "objectClass: posixGroup",
      "cn: operators",
      "gidNumber: 5000",
      "description: Operators Group");

     LdapConnection connection = IntegrationUtils.getAdminConnection(
service );
     connection.add( entry );

     assertTrue(connection.exists( entry.getDn() ));
  }

for some reason not yet clear to me FrameworkRunner is failing while adding
the cn=operators entry  when present in ApplyLdifs

On Tue, Dec 18, 2012 at 10:24 AM, Anthony Dahanne <anthony.dahanne@gmail.com
> wrote:

> Hello Emmanuel,
> Thanks a lot for your answer !
> Unfortunately, I now encounter new issues...
>
> I had to switch to Apache DS 2.0.0-M8 to compile AND I had to add
> apacheds-jdbm 2.0.0-M3 for runtime
>
>     <dependency>
>       <groupId>org.apache.directory.server</groupId>
>       <artifactId>apacheds-server-integ</artifactId>
>       <version>${apacheds-server.version}</version>
>       <scope>test</scope>
>     </dependency>
>     <dependency>
>       <groupId>org.apache.directory.server</groupId>
>       <artifactId>apacheds-core-integ</artifactId>
>       <version>${apacheds-server.version}</version>
>       <scope>test</scope>
>     </dependency>
>     <dependency>
>         <groupId>org.apache.directory.server</groupId>
>         <artifactId>apacheds-jdbm</artifactId>
>         <version>2.0.0-M3</version>
>         <scope>test</scope>
>     </dependency>
>
> to compile the snippet you gave me :
>
>   // The shared LDAP connection
>   private static LdapConnection connection;
>
>  @Before
>   public void enableNis() throws Exception
>   {
>
>     connection = IntegrationUtils.getAdminConnection(
>             getService());
>
>     Entry nisEntry = connection.lookup( "cn=nis,ou=schema" );
>
>     boolean isNisDisabled = nisEntry.contains( "m-disabled", "TRUE" );
>
>     // if nis is disabled then enable it
>     if ( isNisDisabled )
>     {
>       connection.modify( "cn=nis,ou=schema", new
>               DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
>               "m-disabled", "TRUE" ) );
>     }
>   }
>
> and I had to change the @BeforeClass into a @Before (non static method),
> otherwise the getService() would always return null.
>
> Then, I could verify in the log the NIS schema was enabled :
> @Test
> public void authenticateAndAuthorizeFromDynamicGroup() throws Exception {
>
>
>     Entry nisEntry = connection.lookup( "cn=nis,ou=schema" );
>
>     boolean isNisDisabled = nisEntry.contains( "m-disabled", "TRUE" );
>
>     System.out.println("Nis is disabled : "+isNisDisabled);
> etc...
>
> would print false (and true if I remove the snippet)
>
> but...
> I now have this error
>
> Caused by: org.apache.directory.shared.ldap.model.exception.LdapException:
> ERR_04269 ATTRIBUTE_TYPE for OID gidnumber does not exist!
>
>
> , whenever I add this ldif  (in the applyldif annotation) :
>
>           "dn: cn=operators,ou=groups,dc=mycompany,dc=com",
>           "objectClass: posixGroup",
>           "cn: operators",
>           "gidNumber: 5000",
>           "description: Operators Group",
>
> I have copied my test in a pastebin :
> http://pastebin.com/BXNP8muU
>
> I have tried several combinations, but whenever I try to load an ldif with
> gidNumber, it fails...
>
> Thanks again for your help,
> Regards,
> Anthony
>
>
>
> On Mon, Dec 17, 2012 at 5:49 PM, Emmanuel L├ęcharny <elecharny@gmail.com
> >wrote:
>
> > @ApplyLdifs( {
> >             // the users organizationalUnit
> >             "dn: ou=users,dc=mycompany,dc=com",
> >             "objectClass: organizationalUnit",
> >             "objectClass: top",
> >             "ou: users",
> >             "description: Users",
> >
> >             // the groups organizationalUnit
> >             "dn: ou=groups,dc=mycompany,dc=com",
> >             "objectClass: organizationalUnit",
> >             "objectClass: top",
> >             "ou: groups",
> >             "description: Groups" })
>



-- 
Kiran Ayyagari
http://keydap.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message