Return-Path: X-Original-To: apmail-directory-users-archive@www.apache.org Delivered-To: apmail-directory-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E80A7D05A for ; Tue, 18 Dec 2012 07:33:06 +0000 (UTC) Received: (qmail 7731 invoked by uid 500); 18 Dec 2012 07:33:06 -0000 Delivered-To: apmail-directory-users-archive@directory.apache.org Received: (qmail 7709 invoked by uid 500); 18 Dec 2012 07:33:05 -0000 Mailing-List: contact users-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@directory.apache.org Delivered-To: mailing list users@directory.apache.org Received: (qmail 7620 invoked by uid 99); 18 Dec 2012 07:33:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Dec 2012 07:33:02 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ayyagarikiran@gmail.com designates 209.85.223.172 as permitted sender) Received: from [209.85.223.172] (HELO mail-ie0-f172.google.com) (209.85.223.172) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Dec 2012 07:32:55 +0000 Received: by mail-ie0-f172.google.com with SMTP id c13so382428ieb.3 for ; Mon, 17 Dec 2012 23:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=ZKg9GSjcUvbTPgU90sOSBmnPo0kXPrDcUKFYWOYPZvo=; b=fQqCkaUCcBYXC7QM+ejd+186uZFP0OsZsgny4u75sHWM83Wv8dlAds/NxaxFjy2zQQ wBjKSZmGgnMv5FMCdEKqnzS1LR8ZUSYvXWrvznx15ydkPj2JjfzTnQ4XlFXOWTCQIe10 wB444DMooDsx0IzUNq/E8w/ZQRrUofR2E2vsSZf022bra2p1Sw1svZHlld/BssEajNCM 3qMYsjY7G6b4NnVNEaM2Rjkwi3TD9uXl71d0Tq/LUSTVXbbSR8S7nU9V/6guQbYFy6t6 LHlRlKoAL6N/3g12ez4MIR46LRzvaPDekhNsjuw+thkvNyTaZPBaN11uqlSQhzsU0p3w HeVw== MIME-Version: 1.0 Received: by 10.50.53.230 with SMTP id e6mr1155047igp.46.1355815954832; Mon, 17 Dec 2012 23:32:34 -0800 (PST) Sender: ayyagarikiran@gmail.com Received: by 10.231.31.3 with HTTP; Mon, 17 Dec 2012 23:32:34 -0800 (PST) In-Reply-To: References: <50CFA197.1000803@gmail.com> Date: Tue, 18 Dec 2012 13:02:34 +0530 X-Google-Sender-Auth: hUD1UAv8Q2c7_Mo_-z1Ajb-_DnU Message-ID: Subject: Re: embedding ApacheDS for tests uisng NIS schema From: Kiran Ayyagari To: users@directory.apache.org Content-Type: multipart/alternative; boundary=f46d043bdc285e5d8b04d11b80b3 X-Virus-Checked: Checked by ClamAV on apache.org --f46d043bdc285e5d8b04d11b80b3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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=3Dgroups,dc=3Dmycompany,dc=3Dcom", "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 =3D new DefaultEntry( "cn=3Doperators,ou=3Dgroups,dc=3Dmycompany,dc=3Dcom", "objectClass: posixGroup", "cn: operators", "gidNumber: 5000", "description: Operators Group", "objectClass: posixGroup", "cn: operators", "gidNumber: 5000", "description: Operators Group"); LdapConnection connection =3D 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=3Doperators entry when present in ApplyLdifs On Tue, Dec 18, 2012 at 10:24 AM, Anthony Dahanne 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 > > > org.apache.directory.server > apacheds-server-integ > ${apacheds-server.version} > test > > > org.apache.directory.server > apacheds-core-integ > ${apacheds-server.version} > test > > > org.apache.directory.server > apacheds-jdbm > 2.0.0-M3 > test > > > to compile the snippet you gave me : > > // The shared LDAP connection > private static LdapConnection connection; > > @Before > public void enableNis() throws Exception > { > > connection =3D IntegrationUtils.getAdminConnection( > getService()); > > Entry nisEntry =3D connection.lookup( "cn=3Dnis,ou=3Dschema" ); > > boolean isNisDisabled =3D nisEntry.contains( "m-disabled", "TRUE" ); > > // if nis is disabled then enable it > if ( isNisDisabled ) > { > connection.modify( "cn=3Dnis,ou=3Dschema", 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 =3D connection.lookup( "cn=3Dnis,ou=3Dschema" ); > > boolean isNisDisabled =3D 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=3Doperators,ou=3Dgroups,dc=3Dmycompany,dc=3Dcom", > "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 wit= h > gidNumber, it fails... > > Thanks again for your help, > Regards, > Anthony > > > > On Mon, Dec 17, 2012 at 5:49 PM, Emmanuel L=E9charny >wrote: > > > @ApplyLdifs( { > > // the users organizationalUnit > > "dn: ou=3Dusers,dc=3Dmycompany,dc=3Dcom", > > "objectClass: organizationalUnit", > > "objectClass: top", > > "ou: users", > > "description: Users", > > > > // the groups organizationalUnit > > "dn: ou=3Dgroups,dc=3Dmycompany,dc=3Dcom", > > "objectClass: organizationalUnit", > > "objectClass: top", > > "ou: groups", > > "description: Groups" }) > --=20 Kiran Ayyagari http://keydap.com --f46d043bdc285e5d8b04d11b80b3--