<commit_before>/*
 *   Licensed to the Apache Software Foundation (ASF) under one
 *   or more contributor license agreements.  See the NOTICE file
 *   distributed with this work for additional information
 *   regarding copyright ownership.  The ASF licenses this file
 *   to you under the Apache License, Version 2.0 (the
 *   "License"); you may not use this file except in compliance
 *   with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing,
 *   software distributed under the License is distributed on an
 *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *   KIND, either express or implied.  See the License for the
 *   specific language governing permissions and limitations
 *   under the License.
 *
 */

package org.apache.directory.shared.client.api.operations;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.ApacheDSTestExtension;
import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;


/**
 * A class to test the GetRootDse operation with a returningAttributes parameter
 *
 * @author <a href="mailto:<EMAIL>">Apache Directory Project</a>
 */
@ExtendWith( { ApacheDSTestExtension.class } )
@CreateLdapServer(transports =
    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
public class GetRootDseTest extends AbstractLdapTestUnit
{
    private LdapNetworkConnection connection;


    @BeforeEach
    public void setup() throws Exception
    {
        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
    }


    @AfterEach
    public void shutdown() throws Exception
    {
        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer() );
    }


    /**
     * Test a lookup requesting all the attributes (* and +)
     *
     * @throws Exception
     */
    @Test
    public void testGetRootDse() throws Exception
    {
        Entry rootDse = connection.getRootDse();

        assertNotNull( rootDse );

        assertEquals( 1, rootDse.size() );
        assertTrue( rootDse.containsAttribute( "objectClass" ) );
    }


    /**
     * Test a                     if ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS )
    lookup requesting all the user attributes (*)
     *
     * @throws Exception
     */
    @Test<commit_msg>Adjust test to changed getRootDse() implementation<commit_after>/*
 *   Licensed to the Apache Software Foundation (ASF) under one
 *   or more contributor license agreements.  See the NOTICE file
 *   distributed with this work for additional information
 *   regarding copyright ownership.  The ASF licenses this file
 *   to you under the Apache License, Version 2.0 (the
 *   "License"); you may not use this file except in compliance
 *   with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing,
 *   software distributed under the License is distributed on an
 *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *   KIND, either express or implied.  See the License for the
 *   specific language governing permissions and limitations
 *   under the License.
 *
 */

package org.apache.directory.shared.client.api.operations;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.ApacheDSTestExtension;
import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;


/**
 * A class to test the GetRootDse operation with a returningAttributes parameter
 *
 * @author <a href="mailto:<EMAIL>">Apache Directory Project</a>
 */
@ExtendWith( { ApacheDSTestExtension.class } )
@CreateLdapServer(transports =
    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
public class GetRootDseTest extends AbstractLdapTestUnit
{
    private LdapNetworkConnection connection;


    @BeforeEach
    public void setup() throws Exception
    {
        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
    }


    @AfterEach
    public void shutdown() throws Exception
    {
        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer() );
    }


    /**
     * Test a lookup requesting all the attributes (* and +)
     *
     * @throws Exception
     */
    @Test
    public void testGetRootDse() throws Exception
    {
        Entry rootDse = connection.getRootDse();

        assertNotNull( rootDse );

        assertEquals( 11, rootDse.size() );
        assertTrue( rootDse.containsAttribute( "objectClass" ) );
        assertTrue( rootDse.containsAttribute( "entryUUID" ) );
        assertTrue( rootDse.containsAttribute( "namingContexts" ) );
        assertTrue( rootDse.containsAttribute( "subschemaSubentry" ) );
        assertTrue( rootDse.containsAttribute( "supportedControl" ) );
        assertTrue( rootDse.containsAttribute( "supportedExtension" ) );
        assertTrue( rootDse.containsAttribute( "supportedFeatures" ) );
        assertTrue( rootDse.containsAttribute( "supportedLDAPVersion" ) );
        assertTrue( rootDse.containsAttribute( "supportedSASLMechanisms" ) );
        assertTrue( rootDse.containsAttribute( "vendorName" ) );
        assertTrue( rootDse.containsAttribute( "vendorVersion" ) );
    }


    /**
     * Test a lookup requesting all the user attributes (*)
     *
     * @throws Exception
     */
    @Test
{'fraction_non_alphanumeric': 0.09238969499555819, 'fraction_numerical': 0.0016286644951140066, 'mean_word_length': 3.757042253521127, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7156033', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1862, 'n_words': 503}