Skip to content

API Test Configuration

Robert Polak edited this page Jul 30, 2019 · 19 revisions

Home / Configuration / API Test

1. Content of test\API.Test\packages.config file.

The Server API Test Solution need contain libraries references listed as below:

test\API.Test\packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EnyimMemcached" version="2.16.0" targetFramework="net472" />
  <package id="FluentValidation" version="8.4.0" targetFramework="net472" />
  <package id="HtmlAgilityPack" version="1.11.7" targetFramework="net472" />
  <package id="log4net" version="2.0.8" targetFramework="net472" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net472" />
  <package id="Microsoft.Net.Compilers" version="2.10.0" targetFramework="net472" developmentDependency="true" />
  <package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net472" />
  <package id="System.ComponentModel.Annotations" version="4.5.0" targetFramework="net472" />
  <package id="System.ComponentModel.Primitives" version="4.3.0" targetFramework="net472" />
  <package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>

2. Solution web.config - Configuration

Each Deployment environment have specific test\API.Test\Web.config file:

  • test\API.Test\Web.config - Development environment (Debug)
  • test\API.Test\Web.Live.config - Production environment (Live)
  • test\API.Test\Web.Test.config - Test environment (Test)
  • test\API.Test\Web.UATconfig - UAT environment (UAT)

test\API.Test\Web.config entries listed as below:

  • IIS - Compilation & Worker limit

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.7.2" />
    <!-- executionTimeout (Seconds), maxRequestLength (KB) = APP_PX_MAX_SIZE_BYTE + 1MB  -->
    <httpRuntime executionTimeout="3600" maxRequestLength="11264" targetFramework="4.7.2" />
  </system.web>
  ...
</configuration>
  • IIS - Request limit and handlers

<configuration>
  ...
  <system.webServer>

  <security>
      <requestFiltering>
        <!-- maxAllowedContentLength (B) APP_PX_MAX_SIZE_BYTE + 1MB -->
        <requestLimits maxAllowedContentLength="11534336" />
      </requestFiltering>
    </security>

    <handlers>
      <!-- Add the handler to instruct IIS to serve the JSON RPC webservice requests -->
      <add verb="POST,GET" path="api.jsonrpc" name="API" type="API.JSONRPC" />
    </handlers>
  ...
  </system.webServer>
  ...
</configuration>
  • CORS - Cross-Origin Resource Sharing

<configuration>
  ...
  <system.webServer>
  <httpProtocol>
      <customHeaders>
        <!-- Local CORS -->
        <add name="Access-Control-Allow-Origin" value="http://localhost" />
        <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
        <add name="Access-Control-Allow-Credentials" value="true" />
      </customHeaders>
    </httpProtocol>

    <rewrite>
      <outboundRules>
        <!-- Private CORS - Default -->
        <rule name="Access-Control-Allow-Origin" enabled="true" patternSyntax="Wildcard">
          <match serverVariable="RESPONSE_Access-Control-Allow-Origin" pattern="*" />
          <conditions trackAllCaptures="false"></conditions>
          <action type="Rewrite" value="{HTTP_ORIGIN}" />
        </rule>
        <!-- Private CORS - DNS filter -->
        <!--
				<rule name="WWW-Authenticate" enabled="true" patternSyntax="Wildcard">
					<match serverVariable="RESPONSE_WWW-Authenticate" pattern="*" />
					<conditions>
						<add input="{HTTP_ORIGIN}" pattern="https://domain" negate="true" />
					</conditions>
					<action type="Rewrite" value="Anonymous" />
				</rule>
				-->
        <!-- Private CORS - IP filter -->
        <!--
				<rule name="WWW-Authenticate" enabled="true" patternSyntax="Wildcard">
					<match serverVariable="RESPONSE_WWW-Authenticate" pattern="*" />
					<conditions>
						<add input="{REMOTE_ADDR}" pattern="x.y.z.j" negate="true" />
					</conditions>
					<action type="Rewrite" value="Anonymous" />
				</rule>
				-->
      </outboundRules>
    </rewrite>
  </system.webServer>
  ...
</configuration>
  • API - JSONRPC

More details about API Library JSONRPC at API Library JSONRPC

<configuration>
   ...
   <appSettings>
    <!-- JSONRPC - Success response (case sensitive) -->
    <add key="API_JSONRPC_SUCCESS" value="success" />
    <!-- JSONRPC - Windows Authentication [ANONYMOUS, WINDOWS, ANY] -->
    <add key="API_JSONRPC_AUTHENTICATION_TYPE" value="ANY" />

   </appSettings>
  ...
</configuration>
  • API - Active Directory

More details about API Library Active Directory at API Library Active Directory

<configuration>
   ...
   <appSettings>
     <!-- Active Directory - Domain -->
    <add key="API_AD_DOMAIN" value="CSOCORK" />
    <!-- Active Directory - Path -->
    <add key="API_AD_PATH" value="" />
    <!-- Active Directory - Username -->
    <add key="API_AD_USERNAME" value="" />
    <!-- Active Directory - Password -->
    <add key="API_AD_PASSWORD" value="" />
    <!-- Active Directory - Attribute for Username -->
    <add key="API_AD_ATTRIBUTE_USERNAME" value="cn" />
    <!-- Active Directory - Attribute for Email -->
    <add key="API_AD_ATTRIBUTE_EMAIL" value="mail" />
    <!-- Active Directory - Attribute for First Name -->
    <add key="API_AD_ATTRIBUTE_FIRSTNAME" value="givenName" />
    <!-- Active Directory - Attribute for Last Name -->
    <add key="API_AD_ATTRIBUTE_LASTNAME" value="sn" />
   </appSettings>
  ...
</configuration>
  • API - ReCAPTCHA

More details about API Library ReCAPTCHA at API Library ReCAPTCHA

<configuration>
   ...
   <appSettings>
    <!-- ReCAPTCHA - Switch on [TRUE] or off [FALSE] the ReCaptcha -->
    <add key="API_RECAPTCHA_ENABLED" value="FALSE" />
    <!-- ReCAPTCHA - URL -->
    <add key="API_RECAPTCHA_URL" value="https://www.google.com/recaptcha/api/siteverify?secret={0}&amp;response={1}" />
    <!-- ReCAPTCHA - Private Key -->
    <add key="API_RECAPTCHA_PRIVATE_KEY" value="" />

   </appSettings>
  ...
</configuration>
  • API - eMail

More details about API Library eMail at API Library eMail

<configuration>
   ...
   <appSettings>
    <!-- EMAIL - MAIL - Sender (it covers From and ReplyTo as well) -->
    <add key="API_EMAIL_MAIL_SENDER" value="" />
    <!-- EMAIL - SMTP - Server IP address -->
    <add key="API_EMAIL_SMTP_SERVER" value="" />
    <!-- EMAIL - SMTP - Port number -->
    <add key="API_EMAIL_SMTP_PORT" value="" />
    <!-- EMAIL - SMTP - Switch on [TRUE] or off [FALSE] the authentication -->
    <add key="API_EMAIL_SMTP_AUTHENTICATION" value="FALSE" />
    <!-- EMAIL - SMTP - Set the Username if authentication is required -->
    <add key="API_EMAIL_SMTP_USERNAME" value="" />
    <!-- EMAIL - SMTP - Set the Password if authentication is required -->
    <add key="API_EMAIL_SMTP_PASSWORD" value="" />
    <!-- EMAIL - SMTP - Switch on [TRUE] or off [FALSE] the SSL -->
    <add key="API_EMAIL_SMTP_SSL" value="FALSE" />
    <!-- EMAIL - TEMPLATE - Title -->
    <add key="API_EMAIL_TEMPLATE_TITLE" value="PxStat" />
    <!-- EMAIL - TEMPLATE - Sub Title -->
    <add key="API_EMAIL_TEMPLATE_SUBTITLE" value="localhost/data.cso.ie" />
    <!-- EMAIL - TEMPLATE - Website Name -->
    <add key="API_EMAIL_TEMPLATE_WEBSITE_NAME" value="CSO.ie" />
    <!-- EMAIL - TEMPLATE - Website URL -->
    <add key="API_EMAIL_TEMPLATE_WEBSITE_URL" value="https://www.cso.ie" />

   </appSettings>
  ...
</configuration>
  • API - ADO

More details about API Library ADO at API Library ADO

<configuration>
   ...
   <appSettings>
    <!-- ADO - Default Connection Name -->
    <add key="API_ADO_DEFAULT_CONNECTION" value="defaultConnection" />
    <!-- ADO - Execution timeout in seconds -->
    <add key="API_ADO_EXECUTION_TIMEOUT" value="600" />
    <!-- ADO - Bulk Copy timeout in seconds -->
    <add key="API_ADO_BULKCOPY_TIMEOUT" value="600" />
    <!-- ADO - Bulk Copy BatchSize in number of rows (below 5000) -->
    <add key="API_ADO_BULKCOPY_BATCHSIZE" value="4999" />

   </appSettings>
  ...
</configuration>
  • API - MemCacheD

More details about API Library MemCacheD at API Library MemCacheD

<configuration>
   ...
   <appSettings>
    <!-- MemCacheD - Switch on [TRUE] or off [FALSE] the MemCacheD -->
    <add key="API_MEMCACHED_ENABLED" value="TRUE" />
    <!-- MemCacheD - Maximum validity in number of seconds that MemCacheD can handle (30 days = 2592000) -->
    <add key="API_MEMCACHED_MAX_VALIDITY" value="2592000" />
    <!-- MemCacheD - Salsa code to isolate the cache records form other applications or environments -->
    <add key="API_MEMCACHED_SALSA" value="test-incubator.cso.ie/ws.cso.ie/td10" />


   </appSettings>
  ...
</configuration>
  • DB - Connection Strings

<configuration>
   ...
   <connectionStrings>
    <add name="defaultConnection" connectionString="Server=X.X.X.XX;Initial Catalog=pxstat.XX;User ID=XXX;Password=XXX;Persist Security Info=False;Column Encryption Setting=enabled;" />
    <add name="msdbConnection" connectionString="Server=X.X.X.XX;Initial Catalog=msdb;User ID=XXX;Password=XXX;Persist Security Info=False;Column Encryption Setting=enabled;" />
  </connectionStrings>

  ...
</configuration>
  • CACHE - MemCacheD - enyim

More details about API Library MemCacheD at API Library MemCacheD

<configuration>
   ...  
    <enyim.com>
    <memcached protocol="Binary">
      <servers>
        <!-- N.B. Make sure you use the same ordering of nodes in every configuration you have -->
        <add address="X.X.X.XX" port="XXXXX" />
      </servers>
      <socketPool minPoolSize="10" maxPoolSize="20" connectionTimeout="00:00:10" deadTimeout="00:00:10" />
    </memcached>
  </enyim.com>
   
  ...
</configuration>
  • LOGGING - Log4Net

More details about API Library MemCacheD at [API Library Logging]https://github.com/CSOIreland/Server-API-Library/wiki/API-Library-Log)

<configuration>
   ...  
   <log4net>
    <root>
      <!-- Set the level to ERROR for Live/UAT and ALL for TD-->
      <level value="ALL"/>

      <appender-ref ref="FileAppender"/>
      <appender-ref ref="SmtpAppender"/>
      <appender-ref ref="AdoNetAppender"/>
    </root>

    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <!-- Set threshold to ERROR for Live/UAT and ALL for TD-->
      <threshold value="ALL"/>
      <file type="log4net.Util.PatternString" value="Logs\Log4Net.[%processid].log"/>
      <appendToFile value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %level %class.%method:%line - %message%newline"/>
      </layout>
      <lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />
    </appender>

    <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
      <!-- Set threshold to ERROR for Live/UAT and OFF for TD-->
      <threshold value="OFF" />
      <!-- List of coma separated emails for the recipients -->
      <to value="" />
      <!-- Email of the sender -->
      <from value="" />
      <!-- Email's subject -->
      <subject type="log4net.Util.PatternString" value="Domain [Environment] - Error log" />
      <!-- SMTP IP address -->
      <smtpHost value="" />
      <!-- SMTP IP port -->
      <port value="25" />
      <authentication value="Basic" />
      <bufferSize value="1" />
      <lossy value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %level %class.%method:%line - %message%newline"/>
      </layout>
    </appender>

    <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
      <!-- Set threshold to ERROR for Live/UAT and ALL for TD-->
      <threshold value="ALL" />
      <bufferSize value="1" />
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="Server=3.9.2.54;Initial Catalog=pxstat.td12;User ID=pxstat;Password=pxstat;Persist Security Info=False;Column Encryption Setting=enabled;" />
      <commandText value="INSERT INTO TD_LOGGING ([LGG_DATETIME],[LGG_THREAD],[LGG_LEVEL],[LGG_CLASS],[LGG_METHOD],[LGG_LINE],[LGG_MESSAGE],[LGG_EXCEPTION]) VALUES (@Datetime,@Thread,@Level,@Class,@Method,@Line,@Message,@Exception)" />
      <parameter>
        <parameterName value="@Datetime" />
        <dbType value="DateTime" />
        <layout type="log4net.Layout.RawTimeStampLayout" />
      </parameter>
      <parameter>
        <parameterName value="@Thread" />
        <dbType value="String" />
        <size value="8" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%thread" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Level" />
        <dbType value="String" />
        <size value="8" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%level" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Class" />
        <dbType value="String" />
        <size value="256" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%class" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Method" />
        <dbType value="String" />
        <size value="256" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%method" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Line" />
        <dbType value="String" />
        <size value="8" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%line" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Message" />
        <dbType value="String" />
        <size value="-1" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%message" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Exception" />
        <dbType value="String" />
        <size value="-1" />
        <layout type="log4net.Layout.ExceptionLayout" />
      </parameter>
    </appender>
  </log4net>
   
  ...
</configuration>
Clone this wiki locally