|
| 1 | +# This workflow performs tests in .NET. |
| 2 | +name: Library net tests |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + dafny: |
| 8 | + description: 'The Dafny version to run' |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + |
| 12 | +env: |
| 13 | + # Used in examples |
| 14 | + AWS_ENCRYPTION_SDK_EXAMPLE_KMS_KEY_ID: arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f |
| 15 | + AWS_ENCRYPTION_SDK_EXAMPLE_KMS_KEY_ID_2: arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 |
| 16 | + AWS_ENCRYPTION_SDK_EXAMPLE_KMS_MRK_KEY_ID: arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 |
| 17 | + AWS_ENCRYPTION_SDK_EXAMPLE_KMS_MRK_KEY_ID_2: arn:aws:kms:eu-west-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 |
| 18 | + AWS_ENCRYPTION_SDK_EXAMPLE_LIMITED_ROLE_ARN_US_EAST_1: arn:aws:iam::370957321024:role/GitHub-CI-ESDK-Dafny-Role-us-west-2 |
| 19 | + AWS_ENCRYPTION_SDK_EXAMPLE_LIMITED_ROLE_ARN_EU_WEST_1: arn:aws:iam::370957321024:role/GitHub-CI-ESDK-Dafny-Role-us-west-2 |
| 20 | + # Used for Test Vectors |
| 21 | + VECTORS_URL: https://github.com/awslabs/aws-encryption-sdk-test-vectors/raw/master/vectors/awses-decrypt/python-2.3.0.zip |
| 22 | + |
| 23 | +jobs: |
| 24 | + decrypt_python_vectors: |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + os: [ |
| 28 | + windows-latest, |
| 29 | + ubuntu-latest, |
| 30 | + macos-latest, |
| 31 | + ] |
| 32 | + runs-on: ${{ matrix.os }} |
| 33 | + permissions: |
| 34 | + id-token: write |
| 35 | + contents: read |
| 36 | + env: |
| 37 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 |
| 38 | + DOTNET_NOLOGO: 1 |
| 39 | + steps: |
| 40 | + - name: Support longpaths on Git checkout |
| 41 | + run: | |
| 42 | + git config --global core.longpaths true |
| 43 | + - uses: actions/checkout@v2 |
| 44 | + - name: Init Submodules |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + git submodule update --init libraries |
| 48 | + git submodule update --init --recursive mpl |
| 49 | + |
| 50 | + - name: Configure AWS Credentials |
| 51 | + uses: aws-actions/configure-aws-credentials@v4 |
| 52 | + with: |
| 53 | + aws-region: us-west-2 |
| 54 | + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2 |
| 55 | + role-session-name: NetTests |
| 56 | + |
| 57 | + - name: Setup .NET Core SDK 6 |
| 58 | + uses: actions/setup-dotnet@v3 |
| 59 | + with: |
| 60 | + dotnet-version: '6.0.x' |
| 61 | + |
| 62 | + - name: Setup Dafny |
| 63 | + uses: dafny-lang/[email protected] |
| 64 | + with: |
| 65 | + dafny-version: ${{ inputs.dafny }} |
| 66 | + |
| 67 | + - name: Download Dependencies |
| 68 | + working-directory: ./AwsEncryptionSDK |
| 69 | + run: make setup_net |
| 70 | + |
| 71 | + - name: Compile AwsEncryptionSDK implementation |
| 72 | + shell: bash |
| 73 | + working-directory: ./AwsEncryptionSDK |
| 74 | + run: | |
| 75 | + # This works because `node` is installed by default on GHA runners |
| 76 | + CORES=$(node -e 'console.log(os.cpus().length)') |
| 77 | + make transpile_net CORES=$CORES |
| 78 | + |
| 79 | + - name: Fetch Python 2.3.0 Test Vectors |
| 80 | + working-directory: ./ |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors |
| 84 | + mkdir -p $PYTHON_23_VECTOR_PATH |
| 85 | + DOWNLOAD_NAME=python23.zip |
| 86 | + curl --no-progress-meter --output $DOWNLOAD_NAME --location $VECTORS_URL |
| 87 | + unzip -o -qq $DOWNLOAD_NAME -d $PYTHON_23_VECTOR_PATH |
| 88 | + rm $DOWNLOAD_NAME |
| 89 | + |
| 90 | + - name: Decrypt Python 2.3.0 Test Vectors on .net48 (Windows ONLY) |
| 91 | + working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors |
| 92 | + if: matrix.os == 'windows-latest' |
| 93 | + shell: bash |
| 94 | + run: | |
| 95 | + PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors |
| 96 | + DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ |
| 97 | + dotnet test --framework net48 |
| 98 | + |
| 99 | + - name: Decrypt Python 2.3.0 Test Vectors on .net6.0 |
| 100 | + working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors |
| 101 | + if: matrix.os != 'windows-latest' |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors |
| 105 | + if [ "$RUNNER_OS" == "macOS" ]; then |
| 106 | + DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ |
| 107 | + DYLD_LIBRARY_PATH="/usr/local/opt/[email protected]/lib" \ |
| 108 | + dotnet test --framework net6.0 |
| 109 | + else |
| 110 | + DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ |
| 111 | + dotnet test --framework net6.0 |
| 112 | + fi |
| 113 | + |
| 114 | + generate_vectors: |
| 115 | + strategy: |
| 116 | + matrix: |
| 117 | + os: [ |
| 118 | + ubuntu-latest, |
| 119 | + macos-latest, |
| 120 | + ] |
| 121 | + runs-on: ${{ matrix.os }} |
| 122 | + permissions: |
| 123 | + id-token: write |
| 124 | + contents: read |
| 125 | + env: |
| 126 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 |
| 127 | + DOTNET_NOLOGO: 1 |
| 128 | + steps: |
| 129 | + - name: Support longpaths on Git checkout |
| 130 | + run: | |
| 131 | + git config --global core.longpaths true |
| 132 | + - uses: actions/checkout@v2 |
| 133 | + - name: Init Submodules |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + git submodule update --init libraries |
| 137 | + git submodule update --init --recursive mpl |
| 138 | + |
| 139 | + - name: Configure AWS Credentials |
| 140 | + uses: aws-actions/configure-aws-credentials@v4 |
| 141 | + with: |
| 142 | + aws-region: us-west-2 |
| 143 | + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2 |
| 144 | + role-session-name: NetTests |
| 145 | + |
| 146 | + - name: Setup .NET Core SDK 6 |
| 147 | + uses: actions/setup-dotnet@v3 |
| 148 | + with: |
| 149 | + dotnet-version: '6.0.x' |
| 150 | + |
| 151 | + - name: Setup Dafny |
| 152 | + uses: dafny-lang/[email protected] |
| 153 | + with: |
| 154 | + dafny-version: ${{ inputs.dafny }} |
| 155 | + |
| 156 | + - name: Download Dependencies |
| 157 | + working-directory: ./AwsEncryptionSDK |
| 158 | + run: make setup_net |
| 159 | + |
| 160 | + - name: Compile AwsEncryptionSDK implementation |
| 161 | + shell: bash |
| 162 | + working-directory: ./AwsEncryptionSDK |
| 163 | + run: | |
| 164 | + # This works because `node` is installed by default on GHA runners |
| 165 | + CORES=$(node -e 'console.log(os.cpus().length)') |
| 166 | + make transpile_net CORES=$CORES |
| 167 | + |
| 168 | + |
| 169 | + # # TODO: Fix Zip file creation on Windows |
| 170 | + # # - name: Zip the Generated Test Vectors for ESDK-JS on Windows |
| 171 | + # # if: matrix.os == 'windows-latest' |
| 172 | + # # shell: pwsh |
| 173 | + # # run: | |
| 174 | + # # # NET_41_VECTOR_PATH=$GITHUB_WORKSPACE/net41/vectors |
| 175 | + # # Set-Location -Path "$env:GITHUB_WORKSPACE\net41\vectors" |
| 176 | + # # Compress-Archive -Path "$env:GITHUB_WORKSPACE\net41\vectors\*" -DestinationPath "$env:GITHUB_WORKSPACE\net41\vectors\net41.zip" |
| 177 | + |
| 178 | + |
| 179 | + - name: Generate Test Vectors with .NET Framework net6.0 |
| 180 | + # TODO Post-#619: Fix Zip file creation on Windows |
| 181 | + if: matrix.os != 'windows-latest' |
| 182 | + working-directory: ./AwsEncryptionSDK |
| 183 | + shell: bash |
| 184 | + run: | |
| 185 | + NET_41_VECTOR_PATH=net41/vectors |
| 186 | + mkdir -p $NET_41_VECTOR_PATH |
| 187 | + GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator |
| 188 | + dotnet run --project $GEN_PATH --framework net6.0 -- \ |
| 189 | + --encrypt-manifest $GEN_PATH/resources/0006-awses-message-decryption-generation.v2.json \ |
| 190 | + --output-dir $NET_41_VECTOR_PATH |
| 191 | + |
| 192 | + - name: Zip the Generated Test Vectors for ESDK-JS on Mac/Linux |
| 193 | + if: matrix.os != 'windows-latest' |
| 194 | + working-directory: ./AwsEncryptionSDK |
| 195 | + shell: bash |
| 196 | + run: | |
| 197 | + NET_41_VECTOR_PATH=net41/vectors |
| 198 | + cd $NET_41_VECTOR_PATH |
| 199 | + zip -qq net41.zip -r . |
| 200 | + |
| 201 | + - name: Upload Zip File |
| 202 | + uses: actions/upload-artifact@v4 |
| 203 | + if: matrix.os != 'windows-latest' |
| 204 | + with: |
| 205 | + name: ${{matrix.os}}_vector_artifact |
| 206 | + path: AwsEncryptionSDK/net41/vectors/*.zip |
| 207 | + |
| 208 | + decrypt_net_vectors_with_js: |
| 209 | + needs: generate_vectors |
| 210 | + strategy: |
| 211 | + matrix: |
| 212 | + os: [ |
| 213 | + ubuntu-latest, |
| 214 | + macos-latest, |
| 215 | + ] |
| 216 | + runs-on: ${{ matrix.os }} |
| 217 | + permissions: |
| 218 | + id-token: write |
| 219 | + contents: read |
| 220 | + steps: |
| 221 | + - name: Support longpaths on Git checkout |
| 222 | + run: | |
| 223 | + git config --global core.longpaths true |
| 224 | + - uses: actions/checkout@v2 |
| 225 | + - name: Init Submodules |
| 226 | + shell: bash |
| 227 | + run: | |
| 228 | + git submodule update --init libraries |
| 229 | + git submodule update --init --recursive mpl |
| 230 | + |
| 231 | + - name: Configure AWS Credentials |
| 232 | + uses: aws-actions/configure-aws-credentials@v4 |
| 233 | + with: |
| 234 | + aws-region: us-west-2 |
| 235 | + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2 |
| 236 | + role-session-name: NetTests |
| 237 | + |
| 238 | + - name: Set up Dirs |
| 239 | + working-directory: ./AwsEncryptionSDK |
| 240 | + run: | |
| 241 | + NET_41_VECTOR_PATH=AwsEncryptionSDK/net41/vectors |
| 242 | + mkdir -p $NET_41_VECTOR_PATH |
| 243 | + |
| 244 | + - name: Download Encrypt Manifest Artifact |
| 245 | + uses: actions/download-artifact@v4 |
| 246 | + with: |
| 247 | + name: ${{matrix.os}}_vector_artifact |
| 248 | + path: AwsEncryptionSDK/net41/vectors |
| 249 | + |
| 250 | + - uses: actions/setup-node@v4 |
| 251 | + with: |
| 252 | + node-version: 17 |
| 253 | + |
| 254 | + - name: Install deps |
| 255 | + run: | |
| 256 | + openssl version |
| 257 | + npm install @aws-crypto/integration-node |
| 258 | + npm install fast-xml-parser |
| 259 | + |
| 260 | + - name: Decrypt Generated Test Vectors with ESDK-JS |
| 261 | + working-directory: ./AwsEncryptionSDK |
| 262 | + # TODO Post-#619: Fix Zip file creation on Windows |
| 263 | + shell: bash |
| 264 | + run: | |
| 265 | + NET_41_VECTOR_PATH=net41/vectors |
| 266 | + cd $NET_41_VECTOR_PATH |
| 267 | + npx -y @aws-crypto/integration-node decrypt -v net41.zip -c cpu -f 100 |
| 268 | + |
| 269 | + |
0 commit comments