Skip to content

Commit

Permalink
Add main to newish ci files (#22380)
Browse files Browse the repository at this point in the history
* Investigate crypto provider issue.

* Dump security policy.

* Try different path for policy.

* Dump JRE folder.

* Fix up verify agent OS usage.

* Switch to DevOps hosted pool to see if the problem still exists there.

* Remove dump JRE folder.

* Re-enable test.

* Revert "Changed KV cryptography tests to avoid using a hardcoded security provider. (#21703)"

This reverts commit aa472e0.

* Disable secp256k1 curve.

* List contents of JDK bin.

* List bin folder.

* Add code to dump providers.

* Fix indentation.

* Move test app to after checkout.

* Disable sparse checkout.

* remove more sparse checkout.

* Try a different name for the crypto provider.

* Add main to newish CI files.
  • Loading branch information
mitchdenny authored Jun 18, 2021
1 parent 7c329fa commit 3f31d68
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 77 deletions.
12 changes: 12 additions & 0 deletions eng/pipelines/templates/jobs/ci.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ jobs:

- template: ../steps/install-reporting-tools.yml

- task: Maven@3
displayName: 'Print security providers'
inputs:
mavenPomFile: 'java-security/demo/pom.xml'
goals: 'compile exec:java'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '11'
jdkArchitectureOption: 'x64'
options: '-Dexec.mainClass="com.example.App"'
publishJUnitResults: false


- ${{ parameters.PreTestSteps }}

- task: PythonScript@0
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/templates/stages/platform-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
},
"matrix": {
"Agent": {
"ubuntu-18.04": { "OSVmImage": "MMSUbuntu18.04", "Pool": "azsdk-pool-mms-ubuntu-1804-general" },
"windows-2019": { "OSVmImage": "MMS2019", "Pool": "azsdk-pool-mms-win-2019-general" },
"ubuntu-18.04": { "OSVmImage": "ubuntu-18.04", "Pool": "Azure Pipelines" },
"windows-2019": { "OSVmImage": "windows-2019", "Pool": "Azure Pipelines" },
"macOS-10.15": { "OSVmImage": "macOS-10.15", "Pool": "Azure Pipelines" }
},
"JavaTestVersion": [ "1.8", "1.11" ],
Expand Down
37 changes: 19 additions & 18 deletions eng/pipelines/templates/steps/initialize-test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ parameters:
default: client

steps:
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
Paths:
- '**/*.xml'
- 'sdk/${{ parameters.ServiceDirectory }}'
- ${{ if not(parameters.CheckoutRecordings) }}:
- '!sdk/**/test-recordings'
- '!sdk/**/session-records'
- checkout: self
# - template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
# parameters:
# Paths:
# - '**/*.xml'
# - 'sdk/${{ parameters.ServiceDirectory }}'
# - ${{ if not(parameters.CheckoutRecordings) }}:
# - '!sdk/**/test-recordings'
# - '!sdk/**/session-records'

- task: UsePythonVersion@0
displayName: 'Use Python 3.6'
Expand Down Expand Up @@ -55,14 +56,14 @@ steps:
SDKType: ${{ parameters.SDKType }}
ServiceDirectory: ${{ parameters.ServiceDirectory }}

- task: PythonScript@0
displayName: 'Generate directories variable for sparse checkout'
inputs:
scriptPath: 'eng/scripts/generate_from_source_pom.py'
arguments: '--set-pipeline-variable CheckoutDirectories --project-list $(ProjectList)'
workingDirectory: '$(System.DefaultWorkingDirectory)'
# - task: PythonScript@0
# displayName: 'Generate directories variable for sparse checkout'
# inputs:
# scriptPath: 'eng/scripts/generate_from_source_pom.py'
# arguments: '--set-pipeline-variable CheckoutDirectories --project-list $(ProjectList)'
# workingDirectory: '$(System.DefaultWorkingDirectory)'

- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
SkipDefaultCheckout: true
Paths: $(CheckoutDirectories)
# - template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
# parameters:
# SkipDefaultCheckout: true
# Paths: $(CheckoutDirectories)
75 changes: 75 additions & 0 deletions java-security/demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>1.0-SNAPSHOT</version>

<name>demo</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
27 changes: 27 additions & 0 deletions java-security/demo/src/main/java/com/example/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example;

import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
import java.util.Arrays;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args ) throws NoSuchAlgorithmException
{
System.out.println(Arrays.toString(Security.getProviders()));

Provider provider = Security.getProvider("SunEC");

System.out.println(provider);

KeyPairGenerator generator = KeyPairGenerator.getInstance("EC", provider);

System.out.println(generator);
}
}
20 changes: 20 additions & 0 deletions java-security/demo/src/test/java/com/example/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
2 changes: 2 additions & 0 deletions sdk/deviceupdate/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ trigger:
branches:
include:
- master
- main
- hotfix/*
- release/*
paths:
Expand All @@ -15,6 +16,7 @@ pr:
branches:
include:
- master
- main
- feature/*
- hotfix/*
- release/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,29 @@
import com.azure.security.keyvault.keys.cryptography.models.KeyWrapAlgorithm;
import com.azure.security.keyvault.keys.cryptography.models.SignatureAlgorithm;
import com.azure.security.keyvault.keys.models.JsonWebKey;
//import com.azure.security.keyvault.keys.models.KeyCurveName;
import com.azure.security.keyvault.keys.models.KeyCurveName;
import com.azure.security.keyvault.keys.models.KeyOperation;
import com.azure.security.keyvault.keys.models.KeyVaultKey;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.security.InvalidAlgorithmParameterException;
//import java.security.KeyPair;
//import java.security.KeyPairGenerator;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
//import java.security.Provider;
//import java.security.Security;
//import java.security.spec.ECGenParameterSpec;
import java.security.Provider;
import java.security.Security;
import java.security.spec.ECGenParameterSpec;
import java.util.Arrays;
//import java.util.HashMap;
import java.util.HashMap;
import java.util.List;
//import java.util.Map;
import java.util.Map;
import java.util.Random;

import static com.azure.security.keyvault.keys.cryptography.TestHelper.DISPLAY_NAME_WITH_ARGUMENTS;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
//import static org.junit.jupiter.api.Assertions.fail;

public class CryptographyClientTest extends CryptographyClientTestBase {
private KeyClient client;
Expand Down Expand Up @@ -202,8 +201,7 @@ public void signVerifyRsa(HttpClient httpClient, CryptographyServiceVersion serv
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.security.keyvault.keys.cryptography.TestHelper#getTestParameters")
public void signVerifyEc(HttpClient httpClient, CryptographyServiceVersion serviceVersion) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
// TODO: Uncomment after fixing https://github.com/Azure/azure-sdk-for-java/issues/21677
/*initializeKeyClient(httpClient);
initializeKeyClient(httpClient);
Map<KeyCurveName, SignatureAlgorithm> curveToSignature = new HashMap<>();
curveToSignature.put(KeyCurveName.P_256, SignatureAlgorithm.ES256);
curveToSignature.put(KeyCurveName.P_384, SignatureAlgorithm.ES384);
Expand All @@ -217,28 +215,9 @@ public void signVerifyEc(HttpClient httpClient, CryptographyServiceVersion servi
curveToSpec.put(KeyCurveName.P_256K, "secp256k1");

List<KeyCurveName> curveList = Arrays.asList(KeyCurveName.P_256, KeyCurveName.P_384, KeyCurveName.P_521, KeyCurveName.P_256K);
String algorithmName = "EC";
Provider[] providers = Security.getProviders();
Provider provider = null;
for (Provider currentProvider: providers) {
if (currentProvider.containsValue(algorithmName)) {
provider = currentProvider;
break;
}
}
if (provider == null) {
for (Provider currentProvider : providers) {
System.out.println(currentProvider.getName());
}
fail(String.format("No suitable security provider for algorithm %s was found.", algorithmName));
}
Provider provider = Security.getProvider("SunEC version 11");
for (KeyCurveName crv : curveList) {
final KeyPairGenerator generator = KeyPairGenerator.getInstance(algorithmName, provider);
final KeyPairGenerator generator = KeyPairGenerator.getInstance("EC", provider);
ECGenParameterSpec gps = new ECGenParameterSpec(curveToSpec.get(crv));
generator.initialize(gps);
KeyPair keyPair = generator.generateKeyPair();
Expand All @@ -262,13 +241,12 @@ public void signVerifyEc(HttpClient httpClient, CryptographyServiceVersion servi
if (!interceptorManager.isPlaybackMode()) {
assertTrue(verifyStatus);
}
}*/
}
}

@Test
public void signVerifyEcLocal() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
// TODO: Uncomment after fixing https://github.com/Azure/azure-sdk-for-java/issues/21677
/*Map<KeyCurveName, SignatureAlgorithm> curveToSignature = new HashMap<>();
Map<KeyCurveName, SignatureAlgorithm> curveToSignature = new HashMap<>();
curveToSignature.put(KeyCurveName.P_256, SignatureAlgorithm.ES256);
curveToSignature.put(KeyCurveName.P_384, SignatureAlgorithm.ES384);
curveToSignature.put(KeyCurveName.P_521, SignatureAlgorithm.ES512);
Expand All @@ -281,28 +259,9 @@ public void signVerifyEcLocal() throws NoSuchAlgorithmException, InvalidAlgorith
curveToSpec.put(KeyCurveName.P_256K, "secp256k1");

List<KeyCurveName> curveList = Arrays.asList(KeyCurveName.P_256, KeyCurveName.P_384, KeyCurveName.P_521, KeyCurveName.P_256K);
String algorithmName = "EC";
Provider[] providers = Security.getProviders();
Provider provider = null;
for (Provider currentProvider: providers) {
if (currentProvider.containsValue(algorithmName)) {
provider = currentProvider;
break;
}
}
if (provider == null) {
for (Provider currentProvider : providers) {
System.out.println(currentProvider.getName());
}
fail(String.format("No suitable security provider for algorithm %s was found.", algorithmName));
}
Provider provider = Security.getProvider("SunEC");
for (KeyCurveName crv : curveList) {
final KeyPairGenerator generator = KeyPairGenerator.getInstance(algorithmName, provider);
final KeyPairGenerator generator = KeyPairGenerator.getInstance("EC", provider);
ECGenParameterSpec gps = new ECGenParameterSpec(curveToSpec.get(crv));
generator.initialize(gps);
KeyPair keyPair = generator.generateKeyPair();
Expand All @@ -317,7 +276,7 @@ public void signVerifyEcLocal() throws NoSuchAlgorithmException, InvalidAlgorith

Boolean verifyStatus = cryptoClient.verifyData(curveToSignature.get(crv), plainText, signature).isValid();
assertTrue(verifyStatus);
}*/
}
}

@Test
Expand Down
2 changes: 2 additions & 0 deletions sdk/redisenterprise/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ trigger:
branches:
include:
- master
- main
- hotfix/*
- release/*
paths:
Expand All @@ -14,6 +15,7 @@ pr:
branches:
include:
- master
- main
- feature/*
- hotfix/*
- release/*
Expand Down
2 changes: 2 additions & 0 deletions sdk/storagecache/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ trigger:
branches:
include:
- master
- main
- hotfix/*
- release/*
paths:
Expand All @@ -14,6 +15,7 @@ pr:
branches:
include:
- master
- main
- feature/*
- hotfix/*
- release/*
Expand Down

0 comments on commit 3f31d68

Please sign in to comment.