<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
! or http://forgerock.org/license/CDDLv1.0.html.
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at legal-notices/CDDLv1_0.txt.
! If applicable, add the following below this CDDL HEADER, with the
! fields enclosed by brackets "[]" replaced with your own identifying
! information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
! Copyright 2008-2010 Sun Microsystems, Inc.
! Portions Copyright 2013 ForgeRock AS
! -->
<stax>
<defaultcall function="privileges_import_task"/>
<function name="privileges_import_task">
<sequence>
<block name="'privileges-import-task'">
<try>
<sequence>
<script>
if not CurrentTestPath.has_key('group'):
CurrentTestPath['group']='privileges'
CurrentTestPath['suite']=STAXCurrentBlock
</script>
<call function="'testSuite_Preamble'"/>
<!---
Place suite-specific test information here.
#@TestSuiteName Privileges Import Tasks Tests
#@TestSuitePurpose Test the basic Privileges Support in regrad to basic users.
#@TestSuiteGroup Basic Privileges Import Tasks Tests
#@TestScript privileges_import_task.xml
-->
<call function="'common_setup'">
{
'quickStart' : False ,
'startServer' : True ,
'loadData' : True ,
'ldifFile' : '%s/privileges/privileges_startup.ldif' % remote.data ,
'stopServer' : False
}
</call>
<import machine="STAF_LOCAL_HOSTNAME"
file="'%s/testcases/privileges/privileges_acis.xml' % (TESTS_DIR)"/>
<call function="'privileges_acis'"/>
<!---
Place test-specific test information here.
The tag, TestMarker, must be the same as the tag, TestSuiteName.
#@TestMarker Privileges Import Tasks Tests
#@TestName ldif-import
#@TestIssue none
#@TestPurpose Privileges for regular users to add import tasks
#@TestPreamble none
#@TestStep User adding import task.
#@TestStep Admin adding privilege.
#@TestStep User adding import task.
#@TestStep Admin adding global ACI.
#@TestStep User adding import task.
#@TestStep Admin deleting global ACI.
#@TestStep Admin searching an entry that was imported.
#@TestPostamble none
#@TestResult Success if OpenDS returns 50
for steps 1 and 3, and 0
for all other ldap operations.
Proper entries returned for searches.
-->
<testcase name="getTestCaseName('import-ldif')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'Privileges: Import Tasks: import-ldif, user adding import task'
</message>
<call function="'ImportLdifWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : 'uid=auser,o=Privileges Tests,dc=example,dc=com' ,
'dsInstancePswd' : 'ACIRules',
'ldifFile' : '%s/privileges/privileges_import_task/import_task.ldif' \
% remote.data,
'expectedRC' : 1
}
</call>
<script>
resultString = STAXResult[0][1]
msg1 = 'The server rejected the task for the following reason:'
msg2 = 'cannot be added due%sto insufficient access rights' % newLine
</script>
<call function="'searchString'">
{ 'expectedString' : msg1 ,
'returnString' : resultString
}
</call>
<call function="'searchString'">
{ 'expectedString' : msg2 ,
'returnString' : resultString
}
</call>
<message>
'Privileges: Import Tasks: import-ldif, Admin adding privilege'
</message>
<call function="'modifyAnAttribute'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'DNToModify' : 'uid=auser,o=Privileges Tests,dc=example,dc=com' ,
'attributeName' : 'ds-privilege-name' ,
'newAttributeValue' : 'ldif-import' ,
'changetype' : 'add' }
</call>
<message>
'Privileges: Import Tasks: import-ldif, user adding import task'
</message>
<call function="'ImportLdifWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : "uid=auser,o=Privileges Tests,dc=example,dc=com" ,
'dsInstancePswd' : 'ACIRules',
'ldifFile' : '%s/privileges/privileges_import_task/import_task.ldif' \
% remote.data,
'expectedRC' : 1
}
</call>
<message>
'Privileges: Import Tasks: import-ldif, Admin adding ACI'
</message>
<script>
aci="(target=\"ldap:///cn=Scheduled Tasks,cn=Tasks\")(targetattr=\"ds-task-class-name || ds-task-import-backend-id || ds-task-import-ldif-file\")(version 3.0; acl \"Allows writes for tasks\"; allow (write,add,delete) userdn=\"ldap:///anyone\";)"
</script>
<call function="'modifyAnAttribute'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'DNToModify' : 'cn=Access Control Handler,cn=config' ,
'attributeName' : 'ds-cfg-global-aci' ,
'newAttributeValue' : aci ,
'changetype' : 'add' }
</call>
<message>
'Privileges: Import Tasks: import-ldif, user adding import task'
</message>
<call function="'ImportLdifWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : 'uid=auser,o=Privileges Tests,dc=example,dc=com' ,
'dsInstancePswd' : 'ACIRules' ,
'ldifFile' : '%s/privileges/privileges_import_task/import_task.ldif' % remote.data
}
</call>
<message>
'Privileges: Import Tasks: import-ldif, Admin deleting global ACI'
</message>
<call function="'modifyAnAttribute'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'DNToModify' : 'cn=Access Control Handler,cn=config' ,
'attributeName' : 'ds-cfg-global-aci' ,
'newAttributeValue' : aci ,
'changetype' : 'delete' }
</call>
<message>
'Privileges: Import Tasks: bypass-acl, Admin searching entry'
</message>
<call function="'SearchObject'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsBaseDN' : 'uid=rhunt, ou=People, ou=import task, o=Privileges Tests,dc=example,dc=com' ,
'dsFilter' : 'objectclass=*' ,
'attributes' : 'cn sn uid'}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{ 'returnString' : returnString ,
'expectedString' : 'dn: uid=rhunt,ou=People,ou=import task,o=Privileges Tests' }
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!---
Place test-specific test information here.
The tag, TestMarker, must be the same as the tag, TestSuiteName.
#@TestMarker Privileges Import Tasks Tests
#@TestName ldif-import, Directory Manager
#@TestIssue none
#@TestPurpose Privileges for Directory Manager to add import tasks
#@TestPreamble none
#@TestStep Alternative root user removing privilege from Directory Manager.
#@TestStep Directory Manager adding import task.
#@TestStep Alternative root user putting back privilege to Directory Manager.
#@TestStep Directory Manager adding import task.
#@TestStep Alternative root user searching an entry that was imported.
#@TestPostamble none
#@TestResult Success if OpenDS returns 50
for step 2, and 0
for all other ldap operations.
Proper entries returned for searches.
-->
<testcase name="getTestCaseName('import-ldif Directory Manager')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'Privileges: Import Tasks: import-ldif, Directory Manager, alternative root user removing privilege'
</message>
<call function="'modifyAnAttribute'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : 'cn=Aroot' ,
'dsInstancePswd' : 'PrivsRule' ,
'DNToModify' : 'cn=Directory Manager,cn=Root DNs,cn=config' ,
'attributeName' : 'ds-privilege-name' ,
'newAttributeValue' : '-ldif-import' ,
'changetype' : 'add' }
</call>
<message>
'Privileges: Import Tasks: import-ldif, Directory Manager, DM adding import task'
</message>
<call function="'ImportLdifWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'ldifFile' : '%s/privileges/privileges_import_task/import_task.ldif' \
% remote.data,
'expectedRC' : 1
}
</call>
<script>
resultString = STAXResult[0][1]
msg1 = 'The server rejected the task for the following reason:'
msg2 = 'You do not have%ssufficient privileges to initiate an LDIF import' % newLine
</script>
<call function="'searchString'">
{ 'expectedString' : msg1 ,
'returnString' : resultString
}
</call>
<call function="'searchString'">
{ 'expectedString' : msg2 ,
'returnString' : resultString
}
</call>
<message>
'Privileges: Import Tasks: import-ldif, Directory Manager, alternative root user putting back privilege'
</message>
<call function="'modifyAnAttribute'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : 'cn=Aroot' ,
'dsInstancePswd' : 'PrivsRule' ,
'DNToModify' : 'cn=Directory Manager,cn=Root DNs,cn=config' ,
'attributeName' : 'ds-privilege-name' ,
'newAttributeValue' : '-ldif-import' ,
'changetype' : 'delete' }
</call>
<message>
'Privileges: Import Tasks: import-ldif, Directory Manager, DM adding import task'
</message>
<call function="'ImportLdifWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'ldifFile' : '%s/privileges/privileges_import_task/import_task.ldif' \
% remote.data
}
</call>
<message>
'Privileges: Import Tasks: import-ldif, Directory Manager, alternative root user searching entry'
</message>
<call function="'SearchObject'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : 'cn=Aroot' ,
'dsInstancePswd' : 'PrivsRule' ,
'dsBaseDN' : 'uid=rhunt, ou=People, ou=import task, o=Privileges Tests,dc=example,dc=com' ,
'dsFilter' : 'objectclass=*' ,
'attributes' : 'cn sn uid'}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{ 'returnString' : returnString ,
'expectedString' : 'dn: uid=rhunt,ou=People,ou=import task,o=Privileges Tests' }
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!---
Place test-specific test information here.
The tag, TestMarker, must be the same as the tag, TestSuiteName.
#@TestMarker Privileges Import Task Tests
#@TestName ldif-import, New Root User
#@TestIssue none
#@TestPurpose Privileges for new root user to add import tasks
#@TestPreamble Admin adds new root user.
#@TestStep Alternative root user removing privilege from new root user.
#@TestStep New root user adding import task.
#@TestStep Alternative root user putting back privilege to new root user.
#@TestStep New root user adding import task.
#@TestStep Alternative root user searching an entry that was imported.
#@TestPostamble none
#@TestResult Success if OpenDS returns 50
for step 2, and 0
for all other ldap operations.
Proper entries returned for searches.
-->
<testcase name="getTestCaseName('import-ldif New Root User')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'Privileges: Import Tasks: import-ldif, New Root User, preamble, Admin adding new root user'
</message>
<call function="'addEntry'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'entryToBeAdded' : '%s/privileges/add_new_root_user.ldif' % remote.data }
</call>
<message>
'Privileges: Import Tasks: import-ldif, New Root User, alternative root user removing privilege'
</message>
<call function="'modifyAnAttribute'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : 'cn=Aroot' ,
'dsInstancePswd' : 'PrivsRule' ,
'DNToModify' : 'cn=Zroot Manager,cn=Root DNs,cn=config' ,
'attributeName' : 'ds-privilege-name' ,
'newAttributeValue' : '-ldif-import' ,
'changetype' : 'add' }
</call>
<message>
'Privileges: Import Tasks: import-ldif, New Root User, new root user adding import task'
</message>
<call function="'ImportLdifWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : 'cn=Zroot' ,
'dsInstancePswd' : 'PrivsRule' ,
'ldifFile' : '%s/privileges/privileges_import_task/import_task.ldif' \
% remote.data,
'expectedRC' : 1
}
</call>
<script>
resultString = STAXResult[0][1]
msg1 = 'The server rejected the task for the following reason:'
msg2 = 'You do not have%ssufficient privileges to initiate an LDIF import' % newLine
</script>
<call function="'searchString'">
{ 'expectedString' : msg1 ,
'returnString' : resultString
}
</call>
<call function="'searchString'">
{ 'expectedString' : msg2 ,
'returnString' : resultString
}
</call>
<message>
'Privileges: Import Tasks: import-ldif, New Root User, alternative root user putting back privilege'
</message>
<call function="'modifyAnAttribute'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : 'cn=Aroot' ,
'dsInstancePswd' : 'PrivsRule' ,
'DNToModify' : 'cn=Zroot Manager,cn=Root DNs,cn=config' ,
'attributeName' : 'ds-privilege-name' ,
'newAttributeValue' : '-ldif-import' ,
'changetype' : 'delete' }
</call>
<message>
'Privileges: Import Tasks: import-ldif, New Root User, new root user adding import task'
</message>
<call function="'ImportLdifWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : 'cn=Zroot' ,
'dsInstancePswd' : 'PrivsRule' ,
'ldifFile' : '%s/privileges/privileges_import_task/import_task.ldif' \
% remote.data
}
</call>
<message>
'Privileges: Import Tasks: import-ldif, New Root User, alternative root user searching entry'
</message>
<call function="'SearchObject'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : 'cn=Zroot' ,
'dsInstancePswd' : 'PrivsRule' ,
'dsBaseDN' : 'uid=rhunt, ou=People, ou=import task, o=Privileges Tests,dc=example,dc=com' ,
'dsFilter' : 'objectclass=*' ,
'attributes' : 'cn sn uid'}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{ 'returnString' : returnString ,
'expectedString' : 'dn: uid=rhunt,ou=People,ou=import task,o=Privileges Tests' }
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
</sequence>
<finally>
<sequence>
<!-- Test Suite Cleanup -->
<message>'Finally: Global Privileges Import Task Cleanup.'</message>
<try>
<call function="'common_cleanup'" />
<catch exception="'STAFException'">
<sequence>
<message log="1" level="'fatal'">'Cleanup of test suite failed.'</message>
</sequence>
</catch>
<finally>
<call function="'testSuite_Postamble'"/>
</finally>
</try>
</sequence>
</finally>
</try>
</block>
</sequence>
</function>
</stax>