From cfa8a019414af5061b360850656856337e4ff456 Mon Sep 17 00:00:00 2001 From: Rahul Kotecha Date: Wed, 10 Feb 2016 16:53:14 +0530 Subject: [PATCH 1/3] KDC setup script Initial KDC setup script (tested on ubuntu) --- .../tests/Scripts/setup-kdc.sh | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/System.Net.Security/tests/Scripts/setup-kdc.sh diff --git a/src/System.Net.Security/tests/Scripts/setup-kdc.sh b/src/System.Net.Security/tests/Scripts/setup-kdc.sh new file mode 100644 index 000000000000..24dba21340cd --- /dev/null +++ b/src/System.Net.Security/tests/Scripts/setup-kdc.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +OS=`cat /etc/os-release | grep "PRETTY_NAME" | sed 's/PRETTY_NAME=//g' | sed 's/["]//g' | awk '{print $1}'` + +realm="TEST.COREFX.NET" + +principal1="HOST/host.test.corefx.net" +principal2="HTTP" +krb_user="krb_user" +password="password" + +kadmin="kadmin.local" +krb5kdc="krb5kdc" +kdb5_util="kdb5_util" +add_principal_cmd="add_principal -pw ${password}" + +krb_conf="krb5.conf" +kdc_conf="kdc.conf" +keytabfile="/etc/krb5.keytab" + +# TODO: These locations varies for different distros, Set the values conditianally +krb_conf_location="/etc/" +kdc_conf_location="/etc/krb5kdc/" +database_file="/var/lib/krb5kdc/principal*" + +kdc_setup() +{ + #Create/copy krb5.conf in /etc/ and kdc.conf in /etc/krb5kdc/ + echo "Copying krb5.conf and kdc.conf.." + /bin/cp ${krb_conf} ${krb_conf_location} + /bin/cp ${kdc_conf} ${kdc_conf_location} + + echo "Creating KDC database for realm ${realm}.." + ${kdb5_util} create -r ${realm} -P ${password} -s + + echo "Adding principal ${principal1}.." + ${kadmin} -q "${add_principal_cmd} ${principal1}@${realm}" + + echo "Adding principal ${principal2}.." + ${kadmin} -q "${add_principal_cmd} ${principal2}@${realm}" + + echo "Adding user ${krb_user}.." + ${kadmin} -q "${add_principal_cmd} ${krb_user}@${realm}" + + echo "Exporting keytab for ${principal1}" + ${kadmin} -q "ktadd ${principal1}@${realm}" + + echo "Exporting keytab for ${principal2}" + ${kadmin} -q "ktadd ${principal2}@${realm}" + + echo "Exporting keytab for ${krb_user}" + ${kadmin} -q "ktadd ${krb_user}@${realm}" +} + +echo "Removing existing database" +rm -rf ${database_file} + +case ${OS} in + "Ubuntu") + dpkg -s krb5-kdc >/dev/null 2>&1 + if [ $? -ne 0 ] + then + echo "Installing krb5-kdc.." + sudo DEBIAN_FRONTEND=noninteractive apt-get -y install krb5-kdc krb5-admin-server + else + echo "krb5-kdc already installed.." + fi + + echo "Stopping KDC.." + if pgrep krb5kdc 2> /dev/null; then killall krb5kdc ; fi + if pgrep kadmind 2> /dev/null; then killall kadmind ; fi + + kdc_setup + + echo "Starting KDC.." + ${krb5kdc} + + ;; + + "Debian") + echo "This is a Debian system" + ;; + + "CentOS") + echo "This is a CentOS system" + ;; + + "Red Hat") + echo "This is a RedHat system" + ;; + + *) + echo "This is an Unknown system" + ;; +esac + +chmod +r ${keytabfile} From 1ec6ed93c2ea8abff876f303b8ab3b3f2f5a660d Mon Sep 17 00:00:00 2001 From: Rahul Kotecha Date: Wed, 10 Feb 2016 17:48:04 +0530 Subject: [PATCH 2/3] KDC Setup script Configuration files for the KDC setup (tested on ubuntu) --- src/System.Net.Security/tests/Scripts/kdc.conf | 16 ++++++++++++++++ src/System.Net.Security/tests/Scripts/krb5.conf | 12 ++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/System.Net.Security/tests/Scripts/kdc.conf create mode 100644 src/System.Net.Security/tests/Scripts/krb5.conf diff --git a/src/System.Net.Security/tests/Scripts/kdc.conf b/src/System.Net.Security/tests/Scripts/kdc.conf new file mode 100644 index 000000000000..635da7ddd1b8 --- /dev/null +++ b/src/System.Net.Security/tests/Scripts/kdc.conf @@ -0,0 +1,16 @@ +[kdcdefaults] + kdc_ports = 750,88 + +[realms] + TEST.COREFX.NET = { + database_name = /var/lib/krb5kdc/principal + admin_keytab = FILE:/etc/krb5kdc/kadm5.keytab + acl_file = /etc/krb5kdc/kadm5.acl + key_stash_file = /etc/krb5kdc/stash + kdc_ports = 750,88 + max_life = 10h 0m 0s + max_renewable_life = 7d 0h 0m 0s + master_key_type = des3-hmac-sha1 + supported_enctypes = aes256-cts:normal arcfour-hmac:normal des3-hmac-sha1:normal des-cbc-crc:normal des:normal des:v4 des:norealm des:onlyrealm des:afs3 + default_principal_flags = +preauth + } diff --git a/src/System.Net.Security/tests/Scripts/krb5.conf b/src/System.Net.Security/tests/Scripts/krb5.conf new file mode 100644 index 000000000000..338810a5f13d --- /dev/null +++ b/src/System.Net.Security/tests/Scripts/krb5.conf @@ -0,0 +1,12 @@ +[libdefaults] + default_realm = TEST.COREFX.NET + +[realms] + TEST.COREFX.NET = { + kdc = localhost + admin_server = localhost + default_domain = test.corefx.net + } + +[domain_realm] + .test.corefx.net = TEST.COREFX.NET From 2e62dde156284df63d7cf049cbffa241de118355 Mon Sep 17 00:00:00 2001 From: Lakshmi Priya Sekar Date: Wed, 10 Feb 2016 17:02:31 -0800 Subject: [PATCH 3/3] Modify Outerloop job to run on Ubuntu. Execute kdc script has a test class initialization step. Conflicts: src/System.Net.Security/tests/FunctionalTests/unix/project.json --- netci.groovy | 34 ++++++++++--------- .../System.Net.Security.Tests.csproj | 24 ++++++------- .../tests/Scripts/setup-kdc.sh | 24 ++++++------- 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/netci.groovy b/netci.groovy index 4c46841a372f..5323a7f35a4a 100644 --- a/netci.groovy +++ b/netci.groovy @@ -6,6 +6,8 @@ def project = GithubProject // Globals +// List of all CI OS +def allOSs = ['Ubuntu', 'Debian8.2', 'OSX', 'FreeBSD', 'CentOS7.1', 'OpenSUSE13.2', 'Windows 10', 'Windows 7', 'Windows_NT'] // Map of os -> osGroup. def osGroupMap = ['Ubuntu':'Linux', 'Ubuntu15.10':'Linux', @@ -102,36 +104,36 @@ branchList.each { branchName -> } // ************************** -// Define outerloop windows testing. Run locally on each machine. +// Define outerloop windows/ubuntu testing. Run locally on each machine. // ************************** -def osShortName = ['Windows 10': 'win10', 'Windows 7' : 'win7', 'Windows_NT' : 'windows_nt', 'Ubuntu' : 'ubuntu', 'OSX' : 'osx'] +def osShortName = ['Windows 10': 'win10', 'Windows 7' : 'win7', 'Windows_NT' : 'windows_nt', 'Ubuntu14.04' : 'ubuntu14.04'] +def outerloopOSs = ['Windows 10', 'Windows 7', 'Windows_NT', 'Ubuntu14.04'] branchList.each { branchName -> - ['Windows 10', 'Windows 7', 'Windows_NT', 'Ubuntu', 'OSX'].each { os -> + outerloopOSs.each { os -> ['Debug', 'Release'].each { configurationGroup -> def isPR = (branchName == 'pr') def newJobName = "outerloop_${osShortName[os]}_${configurationGroup.toLowerCase()}" - def newJob - if (os != 'Ubuntu' && os != 'OSX') { - newJob = job(getJobName(Utilities.getFullJobName(project, newJobName, isPR), branchName)) { - steps { - batchFile("call \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\" x86 && Build.cmd /p:ConfigurationGroup=${configurationGroup} /p:WithCategories=\"InnerLoop;OuterLoop\" /p:TestWithLocalLibraries=true") + def newJob = job(getJobName(Utilities.getFullJobName(project, newJobName, isPR), branchName)) { + steps { + if (os == 'Ubuntu14.04') { + shell("sudo HOME=\$WORKSPACE/tempHome ./build.sh x64 ${configurationGroup.toLowerCase()} /p:WithCategories=\\\"Innerloop;OuterLoop\\\" /p:TestWithLocalLibraries=true") } - } - } else { - newJob = job(getJobName(Utilities.getFullJobName(project, newJobName, isPR), branchName)) { - // Jobs run as a service in unix, which means that HOME variable is not set, and it is required for restoring packages - // so we set it first, and then call build.sh - steps { - shell("HOME=\$WORKSPACE/tempHome ./build.sh /p:ConfigurationGroup=${configurationGroup} /p:WithCategories=\"\\\"InnerLoop;OuterLoop\\\"\" /p:TestWithLocalLibraries=true") + else { + batchFile("call \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\" x86 && Build.cmd /p:ConfigurationGroup=${configurationGroup} /p:WithCategories=\"InnerLoop;OuterLoop\" /p:TestWithLocalLibraries=true") } } } // Set the affinity. OS name matches the machine affinity. - Utilities.setMachineAffinity(newJob, os) + if (os == 'Ubuntu14.04') { + Utilities.setMachineAffinity(newJob, os, '201626test') + } + else { + Utilities.setMachineAffinity(newJob, os) + } // Set up standard options. Utilities.standardJobSetup(newJob, project, isPR, getFullBranchName(branchName)) // Add the unit test results diff --git a/src/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj b/src/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj index 453b2afb52ec..73a1434d1bd5 100644 --- a/src/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj +++ b/src/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj @@ -1,4 +1,4 @@ - + Windows_Debug @@ -10,7 +10,6 @@ {A55A2B9A-830F-4330-A0E7-02A9FB30ABD2} Library - win/project.json win/project.lock.json @@ -19,7 +18,6 @@ unix/project.json unix/project.lock.json - @@ -27,11 +25,9 @@ - - @@ -47,10 +43,8 @@ - - Common\System\Net\HttpTestServers.cs @@ -83,27 +77,29 @@ Common\System\Threading\Tasks\TaskTimeoutExtensions.cs - - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + - {89F37791-6254-4D60-AB96-ACD3CCA0E771} System.Net.Security - - - - diff --git a/src/System.Net.Security/tests/Scripts/setup-kdc.sh b/src/System.Net.Security/tests/Scripts/setup-kdc.sh index 24dba21340cd..c2ed09eeaa2a 100644 --- a/src/System.Net.Security/tests/Scripts/setup-kdc.sh +++ b/src/System.Net.Security/tests/Scripts/setup-kdc.sh @@ -27,33 +27,33 @@ kdc_setup() { #Create/copy krb5.conf in /etc/ and kdc.conf in /etc/krb5kdc/ echo "Copying krb5.conf and kdc.conf.." - /bin/cp ${krb_conf} ${krb_conf_location} - /bin/cp ${kdc_conf} ${kdc_conf_location} + sudo /bin/cp ${krb_conf} ${krb_conf_location} + sudo /bin/cp ${kdc_conf} ${kdc_conf_location} echo "Creating KDC database for realm ${realm}.." - ${kdb5_util} create -r ${realm} -P ${password} -s + sudo ${kdb5_util} create -r ${realm} -P ${password} -s echo "Adding principal ${principal1}.." - ${kadmin} -q "${add_principal_cmd} ${principal1}@${realm}" + sudo ${kadmin} -q "${add_principal_cmd} ${principal1}@${realm}" echo "Adding principal ${principal2}.." - ${kadmin} -q "${add_principal_cmd} ${principal2}@${realm}" + sudo ${kadmin} -q "${add_principal_cmd} ${principal2}@${realm}" echo "Adding user ${krb_user}.." - ${kadmin} -q "${add_principal_cmd} ${krb_user}@${realm}" + sudo ${kadmin} -q "${add_principal_cmd} ${krb_user}@${realm}" echo "Exporting keytab for ${principal1}" - ${kadmin} -q "ktadd ${principal1}@${realm}" + sudo ${kadmin} -q "ktadd ${principal1}@${realm}" echo "Exporting keytab for ${principal2}" - ${kadmin} -q "ktadd ${principal2}@${realm}" + sudo ${kadmin} -q "ktadd ${principal2}@${realm}" echo "Exporting keytab for ${krb_user}" - ${kadmin} -q "ktadd ${krb_user}@${realm}" + sudo ${kadmin} -q "ktadd ${krb_user}@${realm}" } echo "Removing existing database" -rm -rf ${database_file} +sudo rm -rf ${database_file} case ${OS} in "Ubuntu") @@ -73,7 +73,7 @@ case ${OS} in kdc_setup echo "Starting KDC.." - ${krb5kdc} + sudo ${krb5kdc} ;; @@ -94,4 +94,4 @@ case ${OS} in ;; esac -chmod +r ${keytabfile} +sudo chmod +r ${keytabfile}