Fix identity samples running in CI (#3632)
This commit is contained in:
parent
d96216f509
commit
7c34ab088e
@ -91,6 +91,7 @@ include(AzureVersion)
|
||||
|
||||
if(BUILD_SAMPLES)
|
||||
add_subdirectory(samples/helpers/get-env)
|
||||
add_subdirectory(samples/helpers/service)
|
||||
endif()
|
||||
|
||||
# sub-projects
|
||||
|
||||
17
samples/helpers/service/CMakeLists.txt
Normal file
17
samples/helpers/service/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required (VERSION 3.12)
|
||||
project(service LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
||||
add_library(
|
||||
service
|
||||
INTERFACE
|
||||
inc/azure/service/client.hpp
|
||||
)
|
||||
|
||||
target_include_directories(service INTERFACE inc)
|
||||
21
samples/helpers/service/LICENSE
Normal file
21
samples/helpers/service/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
3
samples/helpers/service/README.md
Normal file
3
samples/helpers/service/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Generic Service for Samples
|
||||
|
||||
This is a helper library for samples that provides a generic service client library.
|
||||
@ -19,11 +19,11 @@ namespace Azure { namespace Service {
|
||||
|
||||
public:
|
||||
explicit Client(
|
||||
const std::string& someParameter,
|
||||
const std::string& serviceUrl,
|
||||
std::shared_ptr<Core::Credentials::TokenCredential> credential)
|
||||
: m_credential(std::move(credential))
|
||||
{
|
||||
static_cast<void>(someParameter); // to suppress the "unused variable" warning.
|
||||
static_cast<void>(serviceUrl); // to suppress the "unused variable" warning.
|
||||
}
|
||||
|
||||
void DoSomething(const Core::Context& context) const
|
||||
@ -8,26 +8,26 @@ set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
add_executable(chained_token_credential_sample chained_token_credential.cpp)
|
||||
target_link_libraries(chained_token_credential_sample PRIVATE azure-identity)
|
||||
target_link_libraries(chained_token_credential_sample PRIVATE azure-identity service)
|
||||
target_include_directories(chained_token_credential_sample PRIVATE .)
|
||||
create_per_service_target_build_for_sample(identity chained_token_credential_sample)
|
||||
|
||||
add_executable(client_certificate_credential_sample client_certificate_credential.cpp)
|
||||
target_link_libraries(client_certificate_credential_sample PRIVATE azure-identity)
|
||||
target_link_libraries(client_certificate_credential_sample PRIVATE azure-identity service get-env-helper)
|
||||
target_include_directories(client_certificate_credential_sample PRIVATE .)
|
||||
create_per_service_target_build_for_sample(identity client_certificate_credential_sample)
|
||||
|
||||
add_executable(client_secret_credential_sample client_secret_credential.cpp)
|
||||
target_link_libraries(client_secret_credential_sample PRIVATE azure-identity)
|
||||
target_link_libraries(client_secret_credential_sample PRIVATE azure-identity service get-env-helper)
|
||||
target_include_directories(client_secret_credential_sample PRIVATE .)
|
||||
create_per_service_target_build_for_sample(identity client_secret_credential_sample)
|
||||
|
||||
add_executable(environment_credential_sample environment_credential.cpp)
|
||||
target_link_libraries(environment_credential_sample PRIVATE azure-identity)
|
||||
target_link_libraries(environment_credential_sample PRIVATE azure-identity service)
|
||||
target_include_directories(environment_credential_sample PRIVATE .)
|
||||
create_per_service_target_build_for_sample(identity environment_credential_sample)
|
||||
|
||||
add_executable(managed_identity_credential_sample managed_identity_credential.cpp)
|
||||
target_link_libraries(managed_identity_credential_sample PRIVATE azure-identity)
|
||||
target_link_libraries(managed_identity_credential_sample PRIVATE azure-identity service)
|
||||
target_include_directories(managed_identity_credential_sample PRIVATE .)
|
||||
create_per_service_target_build_for_sample(identity managed_identity_credential_sample)
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <get_env.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <azure/identity/client_certificate_credential.hpp>
|
||||
|
||||
#include <azure/service/client.hpp>
|
||||
|
||||
// These functions should be getting the real Tenant ID, Client ID, and the Client Certificate to
|
||||
// authenticate.
|
||||
std::string GetTenantId() { return std::string(); }
|
||||
std::string GetClientId() { return std::string(); }
|
||||
std::string GetClientCertificatePath() { return std::string(); }
|
||||
// The following environment variables must be set before running the sample.
|
||||
// * AZURE_TENANT_ID: Tenant ID for the Azure account.
|
||||
// * AZURE_CLIENT_ID: The Client ID to authenticate the request.
|
||||
// * AZURE_CLIENT_CERTIFICATE_PATH: The path to a client certificate.
|
||||
std::string GetTenantId() { return std::getenv("AZURE_TENANT_ID"); }
|
||||
std::string GetClientId() { return std::getenv("AZURE_CLIENT_ID"); }
|
||||
std::string GetClientCertificatePath() { return std::getenv("AZURE_CLIENT_CERTIFICATE_PATH"); }
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@ -1,18 +1,21 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <get_env.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <azure/identity/client_secret_credential.hpp>
|
||||
|
||||
#include <azure/service/client.hpp>
|
||||
|
||||
// These functions should be getting the real Tenant ID, Client ID, and the Client Secret to
|
||||
// authenticate. It is recommended to NOT hardcode the secret in the code, but to get it from the
|
||||
// environment or read it from a secure location.
|
||||
std::string GetTenantId() { return std::string(); }
|
||||
std::string GetClientId() { return std::string(); }
|
||||
std::string GetClientSecret() { return std::string(); }
|
||||
// The following environment variables must be set before running the sample.
|
||||
// * AZURE_TENANT_ID: Tenant ID for the Azure account.
|
||||
// * AZURE_CLIENT_ID: The Client ID to authenticate the request.
|
||||
// * AZURE_CLIENT_SECRET: The client secret.
|
||||
std::string GetTenantId() { return std::getenv("AZURE_TENANT_ID"); }
|
||||
std::string GetClientId() { return std::getenv("AZURE_CLIENT_ID"); }
|
||||
std::string GetClientSecret() { return std::getenv("AZURE_CLIENT_SECRET"); }
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
92
sdk/identity/test-resources-pre.ps1
Normal file
92
sdk/identity/test-resources-pre.ps1
Normal file
@ -0,0 +1,92 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
# IMPORTANT: Do not invoke this file directly. Please instead run eng/New-TestResources.ps1 from the repository root.
|
||||
|
||||
#Requires -Version 6.0
|
||||
#Requires -PSEdition Core
|
||||
|
||||
using namespace System.Security.Cryptography
|
||||
using namespace System.Security.Cryptography.X509Certificates
|
||||
|
||||
# Use same parameter names as declared in eng/New-TestResources.ps1 (assume validation therein).
|
||||
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
|
||||
param (
|
||||
# Captures any arguments from eng/New-TestResources.ps1 not declared here (no parameter errors).
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
$RemainingArguments
|
||||
)
|
||||
|
||||
# By default stop for any error.
|
||||
if (!$PSBoundParameters.ContainsKey('ErrorAction')) {
|
||||
$ErrorActionPreference = 'Stop'
|
||||
}
|
||||
|
||||
$certPath = Join-Path $(Get-Location) "azure-identity-test2.pem"
|
||||
|
||||
@"
|
||||
Bag Attributes
|
||||
Microsoft Local Key set: <No Values>
|
||||
localKeyID: 01 00 00 00
|
||||
friendlyName: te-66f5c973-4fc8-4cd3-8acc-64964d79b693
|
||||
Microsoft CSP Name: Microsoft Software Key Storage Provider
|
||||
Key Attributes
|
||||
X509v3 Key Usage: 90
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDPdm4pukO7ugEx
|
||||
8wXrmo4VIEoicp7w3QsEJGA2bMx9nHMvwugG54t14QpfqBQYQWLeL1HmpcDeivVD
|
||||
+15ZXeGLCPVZBHhoY8ZWGibfhAAzqQ0P9Ca1kydjvB4uJcEnF/RYtQv6n6OwmdO1
|
||||
wJ22JNcRlMtZqmnb/Q0In2fjXEbdl85/GZlYzMQRdyfI0yriSRBcYV2kg0zeXCxf
|
||||
mCvB3rb6I1KpoUFHlkeHtkeDwm0VHUEt4Hz8ghcB00tI5eS2fH2rPkINQKc6+0QU
|
||||
C2KICQC+GzJsYDbwQOao5Vhk80H5LRuM9Ndzv+fU3lLnktYCgXgL9AX4L/R9Z4Pz
|
||||
tuao/qbRAgMBAAECggEBAMQZIrooiTuZ7uVC3Ja96Y1IjyqOg3QSzAXnSFZJcuVM
|
||||
i4hayC02khkjVUXjvtLKg2SW/+hvRqZUXM8cfCsm1Tkxh4/T7OhnXyMl5xahU/uA
|
||||
0IsC8c/xv2rDdxeRskh8mQd8Yk1MtlIIpRgIcE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
|
||||
+Azo8UoedANgndtZ2n11RSjmlQ6TE/WGlsirHExqr6y/l71znoQm1y3E2cArbsmy
|
||||
hp0P5v42PKxmAx4pR0EjNKsd
|
||||
-----END PRIVATE KEY-----
|
||||
Bag Attributes
|
||||
localKeyID: 01 00 00 00
|
||||
1.3.6.1.4.1.311.17.3.71: 61 00 6E 00 74 00 6B 00 2D 00 6C 00 61 00 70 00 74 00 6F 00 70 00 00 00
|
||||
subject=CN = azure-identity-test
|
||||
|
||||
issuer=CN = azure-identity-test
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDODCCAiCgAwIBAgIQNqa9U3MBxqBF7ksWk+XRkzANBgkqhkiG9w0BAQsFADAe
|
||||
MRwwGgYDVQQDDBNhenVyZS1pZGVudGl0eS10ZXN0MCAXDTIyMDQyMjE1MDYwNloY
|
||||
DzIyMjIwMTAxMDcwMDAwWjAeMRwwGgYDVQQDDBNhenVyZS1pZGVudGl0eS10ZXN0
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz3ZuKbpDu7oBMfMF65qO
|
||||
FSBKInKe8N0LBCRgNmzMfZxzL8LoBueLdeEKX6gUGEFi3i9R5qXA3or1Q/teWV3h
|
||||
iwj1WQR4aGPGVhom34QAM6kND/QmtZMnY7weLiXBJxf0WLUL+p+jsJnTtcCdtiTX
|
||||
EZTLWapp2/0NCJ9n41xG3ZfOfxmZWMzEEXcnyNMq4kkQXGFdpINM3lwsX5grwd62
|
||||
+iNSqaFBR5ZHh7ZHg8JtFR1BLeB8/IIXAdNLSOXktnx9qz5CDUCnOvtEFAtiiAkA
|
||||
vhsybGA28EDmqOVYZPNB+S0bjPTXc7/n1N5S55LWAoF4C/QF+C/0fWeD87bmqP6m
|
||||
0QIDAQABo3AwbjAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwIG
|
||||
CCsGAQUFBwMBMB4GA1UdEQQXMBWCE2F6dXJlLWlkZW50aXR5LXRlc3QwHQYDVR0O
|
||||
BBYEFCoJ5tInmafyNuR0tGxZOz522jlWMA0GCSqGSIb3DQEBCwUAA4IBAQBzLXpw
|
||||
Xmrg1sQTmzMnS24mREKxj9B3YILmgsdBMrHkH07QUROee7IbQ8gfBKeln0dEcfYi
|
||||
Jyh42jn+fmg9AR17RP80wPthD2eKOt4WYNkNM3H8U4JEo+0ML0jZyswynpR48h/E
|
||||
m96sm/NUeKUViD5iVTb1uHL4j8mQAN1IbXcunXvrrek1CzFVn5Rpah0Tn+6cYVKd
|
||||
Jg531i53udzusgZtV1NPZ82tzYkPQG1vxB//D9vd0LzmcfCvT50MKhz0r/c5yJYk
|
||||
i9q94DBuzMhe+O9j+Ob2pVQt5akVFJVtIVSfBZzRBAd66u9JeADlT4sxwS4QAUHi
|
||||
RrCsEpJsnJXkx/6O
|
||||
-----END CERTIFICATE-----
|
||||
"@ > $certPath
|
||||
|
||||
$EnvironmentVariables["AZURE_CLIENT_CERTIFICATE_PATH"] = $certPath
|
||||
Loading…
Reference in New Issue
Block a user