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 A6903D7BD for ; Mon, 17 Dec 2012 22:50:33 +0000 (UTC) Received: (qmail 8643 invoked by uid 500); 17 Dec 2012 22:50:31 -0000 Delivered-To: apmail-directory-users-archive@directory.apache.org Received: (qmail 8511 invoked by uid 500); 17 Dec 2012 22:50:31 -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 8421 invoked by uid 99); 17 Dec 2012 22:50:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Dec 2012 22:50:27 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of elecharny@gmail.com designates 209.85.215.178 as permitted sender) Received: from [209.85.215.178] (HELO mail-ea0-f178.google.com) (209.85.215.178) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Dec 2012 22:50:20 +0000 Received: by mail-ea0-f178.google.com with SMTP id k11so2838351eaa.37 for ; Mon, 17 Dec 2012 14:49:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=1JPBDm/6ycFfV4D+PfCfYjyhbHSqFgxG5fFV2dryT0w=; b=PudQWU5cI5Mpq8myP8vPjpiB8pp9qPqrYSUYkQ27zAPQlUZJVX+OCSd35v4OHPACH4 ylloANv3ut3I3P1KXbbsF4BXbjFFZYqJ14qfspEbpPoGFevBBUJVEaipUSPKv6BuO3dS wT7nI618GIYflOxds7i5hfC3tbbskxZmI0cBBNpxlOBBjrUn1yN9HcIobgHF26HzgPDO 0s/NQK4SC9hwK7uWOlDFgxmqms5qOBFAsCRe4lIPCSTJMm67fDZpNn3h7cMZYGg8l53A 6+oZk6hjW/+aSIA0zvBUnoSfTcu65WM3+l+7QKhU3IX8hLssGgwK1qCnTc6f6QOjNvjh WBow== Received: by 10.14.216.70 with SMTP id f46mr44807061eep.12.1355784599362; Mon, 17 Dec 2012 14:49:59 -0800 (PST) Received: from Emmanuels-MacBook-Pro.local (ran75-1-78-192-106-184.fbxo.proxad.net. [78.192.106.184]) by mx.google.com with ESMTPS id e2sm31535823eeo.8.2012.12.17.14.49.58 (version=SSLv3 cipher=OTHER); Mon, 17 Dec 2012 14:49:58 -0800 (PST) Message-ID: <50CFA197.1000803@gmail.com> Date: Mon, 17 Dec 2012 23:49:59 +0100 From: =?UTF-8?B?RW1tYW51ZWwgTMOpY2hhcm55?= Reply-To: elecharny@apache.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: users@directory.apache.org Subject: Re: embedding ApacheDS for tests uisng NIS schema References: In-Reply-To: X-Enigmail-Version: 1.4.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Le 12/17/12 11:18 PM, Anthony Dahanne a écrit : > Hello all, > Using ApacheDS for tests, I would like to simulate a scenario where the > user of our software authenticates/authorizes against a directory using the > NIS schema. > I'm using Apache DS 1.5.7 annotations, such as : > > @RunWith(value = FrameworkRunner.class) > @CreateDS( allowAnonAccess=true, name="AddIT-class", > partitions = > { > @CreatePartition( > name = "mycompany", > suffix = "dc=mycompany,dc=com", > contextEntry = @ContextEntry( > entryLdif = > "dn: dc=mycompany,dc=com\n" + > "dc: mycompany\n" + > "objectClass: top\n" + > "objectClass: domain\n\n" ), > indexes = > { > @CreateIndex( attribute = "objectClass" ), > @CreateIndex( attribute = "dc" ), > @CreateIndex( attribute = "ou" ) > } ) > }) > @CreateLdapServer( > transports = > { > @CreateTransport( protocol = "LDAP" ) > }) > @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", > > > // operators group > "dn: cn=operators,ou=groups,dc=mycompany,dc=com", > "objectClass: groupOfNames", > "objectClass: top", > "cn: operators", > "gidNumber: 43", > "description: Operators Group", > > > // admins group > "dn: cn=admins,ou=groups,dc=mycompany,dc=com", > "objectClass: groupOfNames", > "objectClass: top", > "cn: admins", > "gidNumber: 42", > "description: Operators Group", > etc.... > > > See those latest groups, with gidNumber:xxx ? > well , apache ds refuses to create them with the error : > > org.apache.directory.shared.ldap.exception.LdapSchemaViolationException: > ERR_279 Required attributes [2.5.4.31] not found within entry > cn=operators,ou=groups,dc=mycompany,dc=com > > which is normal because by default the NIS schema is not loaded > I know that I need to set “m-disabled” attribute of the NIS schema to > FALSE; I already did using Apache Directory Studio once. > But how can I , using the annotations configuration, set this property to > false ? Sadly, you can't. But you are not necessarily in a dead end here. You can still inject the @ApplyLdif on a method, instead of inject it at the class level. That let you enable the NS partition in a @BeforeClass method. Something like : @RunWith(value = FrameworkRunner.class) @CreateDS( allowAnonAccess=true, name="AddIT-class", partitions = { @CreatePartition( name = "mycompany", suffix = "dc=mycompany,dc=com", contextEntry = @ContextEntry( entryLdif = "dn: dc=mycompany,dc=com\n" + "dc: mycompany\n" + "objectClass: top\n" + "objectClass: domain\n\n" ), indexes = { @CreateIndex( attribute = "objectClass" ), @CreateIndex( attribute = "dc" ), @CreateIndex( attribute = "ou" ) } ) }) @CreateLdapServer( transports = { @CreateTransport( protocol = "LDAP" ) }) public class MyTest { @BeforeClass static 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" ) ); } } @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" }) @Test public void myTest() { blah... That should work. -- Regards, Cordialement, Emmanuel Lécharny www.iktek.com