mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

smaguin
02.43.2007 1ee8fd256f7fce9c30c556f735b73485dd376be8
add a robust wrapper on dsconfig
1 files modified
148 ■■■■■ changed files
opends/tests/functional-tests/shared/functions/dsconfig.xml 148 ●●●●● patch | view | raw | blame | history
opends/tests/functional-tests/shared/functions/dsconfig.xml
@@ -207,6 +207,154 @@
    
  </function>
  <!-- generic wrapper on dsconfig -->
  <!-- can be used to list, get or set a list of attribues -->
  <function name="dsconfig">
    <function-prolog>
      This function lists, get or set a list of attributes using dsconfig
    </function-prolog>
    <function-map-args>
      <function-arg-def name="location" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <function-arg-description>
          Location of target host
        </function-arg-description>
        <function-arg-property name="type" value="hostname"/>
      </function-arg-def>
      <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
        <function-arg-description>
          Pathname to installation root
        </function-arg-description>
        <function-arg-property name="type" value="filepath"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceHost" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <function-arg-description>
          Directory server hostname or IP address
        </function-arg-description>
        <function-arg-property name="type" value="hostname"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePort" type="required">
        <function-arg-description>
          Directory server port number
        </function-arg-description>
        <function-arg-property name="type" value="Port number"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceDn" type="required">
        <function-arg-description>
          Bind DN
        </function-arg-description>
        <function-arg-property name="type" value="DN"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePswd" type="required">
        <function-arg-description>
          Bind password
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="subcommand" type="required">
        <function-arg-description>
          dsconfig subcommand to execute
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="propertyName" type="optional">
        <function-arg-description>
          Property type to modify, e.g. backend-name
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="propertyValue" type="optional">
        <function-arg-description>
          Property to modify, e.g. enabled
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="optionsString" type="optional">
        <function-arg-description>
          String containing  the dsconfig options.  e.g. --set enabled:true --set key-store-pin:servercert
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="expectedRC" type="optional" default="0">
      <function-arg-description>
        Expected return code value. Default value is 0
      </function-arg-description>
      <function-arg-property name="type" value="string"/>
    </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Local variables -->
      <script>
        mylocation=location
        STAFCmdParams=''
        STAFCmd=''
        if dsPath:
          dsBinPath='%s/%s' % (dsPath,fileFolder)
          STAFCmd='%s/%s%s' % (dsBinPath,DSCONFIG,fileExt)
        STAFCmdParamsList=[]
        STAFCmdParamsList.append('%s' % (subcommand))
        if propertyName:
          STAFCmdParamsList.append('--%s "%s" ' % (propertyName,propertyValue))
        if optionsString:
          STAFCmdParamsList.append(' %s' % (optionsString))
      </script>
      <call function="'_dsconfigCommonArgs'"/>
      <script>
        STAFCmdParams=' '.join(STAFCmdParamsList)
      </script>
      <message>
        '%s %s' % (STAFCmd, STAFCmdParams)
      </message>
      <process name="'execute dsconfig subcommand'">
        <location>'%s' % location</location>
        <command>'%s' % STAFCmd</command>
        <parms>'%s' % STAFCmdParams</parms>
        <workdir>'%s' % dsBinPath</workdir>
        <envs>
          ['PATH=/bin:/usr/bin:%s' % dsBinPath]
        </envs>
        <console use="'same'"/>
        <stderr mode="'stdout'"/>
        <returnstdout/>
      </process>
      <script>
        STAXCode=RC
        STAXReason=STAXResult
      </script>
      <call function="'checktestRC'">
        { 'returncode' : STAXCode ,
          'result'     : STAXReason,
          'expected'   : expectedRC }
      </call>
      <return>
        STAXReason
      </return>
    </sequence>
  </function>
  <!-- Modify password policy using dsconfig -->
  <function name="modifyPwdPolicy">
    <function-prolog>