diff --git a/.clang-format b/.clang-format index b74f533b67..92664c6313 100644 --- a/.clang-format +++ b/.clang-format @@ -33,10 +33,26 @@ CompactNamespaces: true Cpp11BracedListStyle: true FixNamespaceComments: true IndentWidth: 2 -IncludeBlocks: Preserve +IncludeBlocks: Regroup IndentCaseLabels: true NamespaceIndentation: Inner PointerAlignment: Left PenaltyReturnTypeOnItsOwnLine: 300 TabWidth: 2 UseTab: Never +IncludeCategories: + - Regex: '^$' + Priority: 80 +# Note: get_env.hpp must be included before any other Azure SDK headers. + - Regex: '^["<]get_env.hpp' + Priority: 10 + - Regex: '<[[:alnum:]_.]+>' + Priority: 90 + - Regex: '' + Priority: 50 + - Regex: '^$' + Priority: 60 + - Regex: '' + Priority: 70 + - Regex: '^".+' + Priority: 20 diff --git a/.vscode/cspell.json b/.vscode/cspell.json index d9ffa4ba4a..e2c6cefd34 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -97,6 +97,7 @@ "LPSTR", "LPWSTR", "MHSM", + "mmdc", "moxygen", "MSAL", "MSRC", @@ -154,6 +155,7 @@ "usgoviowa", "usgovvirginia", "vcpkg", + "Verdana", "Viet", "Viktor", "vusg", diff --git a/eng/common/pipelines/templates/steps/docs-metadata-release.yml b/eng/common/pipelines/templates/steps/docs-metadata-release.yml deleted file mode 100644 index 7b6fb183a5..0000000000 --- a/eng/common/pipelines/templates/steps/docs-metadata-release.yml +++ /dev/null @@ -1,119 +0,0 @@ -# intended to be used as part of a release process -parameters: - - name: ArtifactLocation - type: string - default: 'not-specified' - - name: PackageRepository - type: string - default: 'not-specified' - - name: ReleaseSha - type: string - default: 'not-specified' - - name: RepoId - type: string - default: $(Build.Repository.Name) - - name: WorkingDirectory - type: string - default: '' - - name: ScriptDirectory - type: string - default: eng/common/scripts - - name: TargetDocRepoName - type: string - default: '' - - name: TargetDocRepoOwner - type: string - default: '' - - name: PRBranchName - type: string - default: 'main-rdme' - - name: PRLabels - type: string - default: 'auto-merge' - - name: ArtifactName - type: string - default: '' - - name: Language - type: string - default: '' - - name: DocRepoDestinationPath - type: string - default: '' #usually docs-ref-services/ - - name: CIConfigs - type: string - default: '[]' - - name: GHReviewersVariable - type: string - default: '' - - name: GHTeamReviewersVariable - type: string - default: '' # externally set, as eng-common does not have the identity-resolver. Run as pre-step - - name: OnboardingBranch - type: string - default: '' - - name: CloseAfterOpenForTesting - type: boolean - default: false - - name: SkipPackageJson - type: object - default: false - - name: SparseCheckoutPaths - type: object - default: null - -steps: -- pwsh: | - if ($IsWindows) { - REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /f /v LongPathsEnabled /t REG_DWORD /d 1 - git config --system core.longpaths true - } - else { - Write-Host "This script is not executing on Windows, skipping registry modification." - } - displayName: Enable Long Paths if Necessary - -- ${{ if not(parameters.SparseCheckoutPaths) }}: - - pwsh: | - git clone https://github.com/${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} ${{ parameters.WorkingDirectory }}/repo - displayName: Clone Documentation Repository - ignoreLASTEXITCODE: false - -- ${{ if parameters.SparseCheckoutPaths }}: - - template: /eng/common/pipelines/templates/steps/sparse-checkout.yml - parameters: - SkipCheckoutNone: true - Repositories: - - Name: ${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} - WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo - Paths: ${{ parameters.SparseCheckoutPaths }} - -- template: /eng/common/pipelines/templates/steps/set-default-branch.yml - parameters: - WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo -- task: PowerShell@2 - displayName: 'Apply Documentation Updates From Artifact' - inputs: - targetType: filePath - filePath: ${{ parameters.ScriptDirectory }}/update-docs-metadata.ps1 - arguments: > - -ArtifactLocation ${{ parameters.ArtifactLocation }} - -Repository ${{ parameters.PackageRepository }} - -ReleaseSHA ${{ parameters.ReleaseSha }} - -RepoId ${{ parameters.RepoId }} - -WorkDirectory "${{ parameters.WorkingDirectory }}" - -DocRepoLocation "${{ parameters.WorkingDirectory }}/repo" - -Language "${{parameters.Language}}" - -Configs "${{ parameters.CIConfigs }}" - pwsh: true - env: - GH_TOKEN: $(azuresdk-github-pat) - -- template: /eng/common/pipelines/templates/steps/git-push-changes.yml - parameters: - BaseRepoBranch: $(DefaultBranch) - BaseRepoOwner: ${{ parameters.TargetDocRepoOwner }} - CommitMsg: "Update docs metadata and targeting for release of ${{ parameters.ArtifactName }}" - TargetRepoName: ${{ parameters.TargetDocRepoName }} - TargetRepoOwner: ${{ parameters.TargetDocRepoOwner }} - WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo - ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }} diff --git a/eng/common/scripts/Test-SampleMetadata.ps1 b/eng/common/scripts/Test-SampleMetadata.ps1 index c20396b0a9..d0a4670113 100644 --- a/eng/common/scripts/Test-SampleMetadata.ps1 +++ b/eng/common/scripts/Test-SampleMetadata.ps1 @@ -247,6 +247,7 @@ begin { "azure-network-watcher", "azure-notebooks", "azure-notification-hubs", + "azure-openai", "azure-open-datasets", "azure-personalizer", "azure-pipelines", diff --git a/eng/common/scripts/TypeSpec-Project-Generate.ps1 b/eng/common/scripts/TypeSpec-Project-Generate.ps1 index feba00d37e..d8845d60d0 100644 --- a/eng/common/scripts/TypeSpec-Project-Generate.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Generate.ps1 @@ -5,8 +5,8 @@ param ( [Parameter(Position=0)] [ValidateNotNullOrEmpty()] [string] $ProjectDirectory, - [Parameter(Position=1)] - [string] $typespecAdditionalOptions ## addtional typespec emitter options, separated by semicolon if more than one, e.g. option1=value1;option2=value2 + [string] $TypespecAdditionalOptions = $null, ## addtional typespec emitter options, separated by semicolon if more than one, e.g. option1=value1;option2=value2 + [switch] $SaveInputs = $false ## saves the temporary files during execution, default false ) $ErrorActionPreference = "Stop" @@ -80,12 +80,17 @@ try { } } $typespecCompileCommand = "npx tsp compile $mainTypeSpecFile --emit $emitterName$emitterAdditionalOptions" - if ($typespecAdditionalOptions) { - $options = $typespecAdditionalOptions.Split(";"); + if ($TypespecAdditionalOptions) { + $options = $TypespecAdditionalOptions.Split(";"); foreach ($option in $options) { $typespecCompileCommand += " --option $emitterName.$option" } } + + if ($SaveInputs) { + $typespecCompileCommand += " --option $emitterName.save-inputs=true" + } + Write-Host($typespecCompileCommand) Invoke-Expression $typespecCompileCommand @@ -95,7 +100,7 @@ finally { Pop-Location } -$shouldCleanUp = $configuration["cleanup"] ?? $true +$shouldCleanUp = !$SaveInputs if ($shouldCleanUp) { Remove-Item $tempFolder -Recurse -Force } diff --git a/eng/common/scripts/TypeSpec-Project-Process.ps1 b/eng/common/scripts/TypeSpec-Project-Process.ps1 new file mode 100644 index 0000000000..a5e909d5dc --- /dev/null +++ b/eng/common/scripts/TypeSpec-Project-Process.ps1 @@ -0,0 +1,135 @@ +# For details see https://github.com/Azure/azure-sdk-tools/blob/main/doc/common/TypeSpec-Project-Scripts.md + +[CmdletBinding()] +param ( + [Parameter(Position = 0)] + [ValidateNotNullOrEmpty()] + [string] $TypeSpecProjectDirectory, # A directory of `tspconfig.yaml` or a remoteUrl of `tspconfig.yaml` + [Parameter(Position = 1)] + [string] $CommitHash, + [Parameter(Position = 2)] + [string] $RepoUrl +) + +. $PSScriptRoot/common.ps1 +. $PSScriptRoot/Helpers/PSModule-Helpers.ps1 +Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module + +function CreateUpdate-TspLocation([System.Object]$tspConfig, [string]$TypeSpecProjectDirectory, [string]$CommitHash, [string]$repo, [string]$repoRoot) { + $serviceDir = "" + $additionalDirs = @() + + # Parse tspcofig.yaml to get service-dir, additionalDirectories, and package-dir + if ($tspConfig["parameters"] -and $tspConfig["parameters"]["service-dir"]) { + $serviceDir = $tspConfig["parameters"]["service-dir"]["default"]; + } + else { + Write-Error "Missing service-dir in parameters section of tspconfig.yaml." + exit 1 + } + if ($tspConfig["parameters"]["dependencies"] -and $tspConfig["parameters"]["dependencies"]["additionalDirectories"]) { + $additionalDirs = $tspConfig["parameters"]["dependencies"]["additionalDirectories"]; + } + + $packageDir = Get-PackageDir $tspConfig + + # Create service-dir if not exist + $serviceDir = Join-Path $repoRoot $serviceDir + if (!(Test-Path -Path $serviceDir)) { + New-Item -Path $serviceDir -ItemType Directory + Write-Host "created service folder $serviceDir" + } + + # Create package-dir if not exist + $packageDir = Join-Path $serviceDir $packageDir + if (!(Test-Path -Path $packageDir)) { + New-Item -Path $packageDir -ItemType Directory + Write-Host "created package folder $packageDir" + } + + # Load tsp-location.yaml if exist + $tspLocationYamlPath = Join-Path $packageDir "tsp-location.yaml" + $tspLocationYaml = @{} + if (Test-Path -Path $tspLocationYamlPath) { + $tspLocationYaml = Get-Content -Path $tspLocationYamlPath -Raw | ConvertFrom-Yaml + } + else { + Write-Host "creating tsp-location.yaml in $packageDir" + } + + # Update tsp-location.yaml + $tspLocationYaml["commit"] = $CommitHash + $tspLocationYaml["repo"] = $repo + $tspLocationYaml["directory"] = $TypeSpecProjectDirectory + $tspLocationYaml["additionalDirectories"] = $additionalDirs + $tspLocationYaml |ConvertTo-Yaml | Out-File $tspLocationYamlPath + Write-Host "updated tsp-location.yaml in $packageDir" + return $packageDir +} + +function Get-PackageDir([System.Object]$tspConfig) { + $emitterName = "" + if (Test-Path "Function:$GetEmitterNameFn") { + $emitterName = &$GetEmitterNameFn + } + else { + Write-Error "Missing $GetEmitterNameFn function in {$Language} SDK repo script." + exit 1 + } + $packageDir = "" + if ($tspConfig["options"] -and $tspConfig["options"]["$emitterName"] -and $tspConfig["options"]["$emitterName"]["package-dir"]) { + $packageDir = $tspConfig["options"]["$emitterName"]["package-dir"] + } + else { + Write-Error "Missing package-dir in $emitterName options of tspconfig.yaml." + exit 1 + } + return $packageDir +} + +$repo = "" +if ($RepoUrl) { + if ($RepoUrl -match "^https://github.com/(?[^/]*/azure-rest-api-specs(-pr)?).*") { + $repo = $Matches["repo"] + } + else { + Write-Host "Parameter 'RepoUrl' has incorrect value: $RepoUrl. It should be similar like 'https://github.com/Azure/azure-rest-api-specs'" + exit 1 + } +} + +$repoRootPath = (Join-Path $PSScriptRoot .. .. ..) +$repoRootPath = Resolve-Path $repoRootPath +$repoRootPath = $repoRootPath -replace "\\", "/" +$tspConfigPath = Join-Path $repoRootPath 'tspconfig.yaml' +# example url of tspconfig.yaml: https://github.com/Azure/azure-rest-api-specs-pr/blob/724ccc4d7ef7655c0b4d5c5ac4a5513f19bbef35/specification/containerservice/Fleet.Management/tspconfig.yaml +if ($TypeSpecProjectDirectory -match '^https://github.com/(?Azure/azure-rest-api-specs(-pr)?)/blob/(?[0-9a-f]{40})/(?.*)/tspconfig.yaml$') { + try { + $TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "github.com", "raw.githubusercontent.com" + $TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "/blob/", "/" + Invoke-WebRequest $TypeSpecProjectDirectory -OutFile $tspConfigPath -MaximumRetryCount 3 + } + catch { + Write-Host "Failed to download '$TypeSpecProjectDirectory'" + Write-Error $_.Exception.Message + return + } + $repo = $Matches["repo"] + $TypeSpecProjectDirectory = $Matches["path"] + $CommitHash = $Matches["commit"] + # TODO support the branch name in url then get the commithash from branch name +} else { + $tspConfigPath = Join-Path $TypeSpecProjectDirectory "tspconfig.yaml" + if (!(Test-Path $tspConfigPath)) { + Write-Error "Failed to find tspconfig.yaml in '$TypeSpecProjectDirectory'" + exit 1 + } +} +$tspConfigYaml = Get-Content $tspConfigPath -Raw | ConvertFrom-Yaml +# call CreateUpdate-TspLocation function +$sdkProjectFolder = CreateUpdate-TspLocation $tspConfigYaml $TypeSpecProjectDirectory $CommitHash $repo $repoRootPath + +# call TypeSpec-Project-Sync.ps1 +& "$PSScriptRoot/TypeSpec-Project-Sync.ps1" $sdkProjectFolder +# call TypeSpec-Project-Generate.ps1 +& "$PSScriptRoot/TypeSpec-Project-Generate.ps1" $sdkProjectFolder \ No newline at end of file diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index f8763de350..b5a497179d 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -76,7 +76,7 @@ function Login([string]$subscription, [string]$clusterGroup, [switch]$skipPushIm if (!$skipPushImages) { $registry = RunOrExitOnFailure az acr list -g $clusterGroup --subscription $subscription -o json $registryName = ($registry | ConvertFrom-Json).name - RunOrExitOnFailure az acr login -n $registryName + RunOrExitOnFailure az acr login -n $registryName --subscription $subscription } } @@ -387,6 +387,21 @@ function CheckDependencies() throw "Please update helm to version >= $MIN_HELM_VERSION (current version: $helmVersionString)`nAdditional information for updating helm version can be found here: https://helm.sh/docs/intro/install/" } + # Ensure docker is running via command and handle command hangs + if (!$skipPushImages) { + $LastErrorActionPreference = $ErrorActionPreference + $ErrorActionPreference = 'Continue' + $job = Start-Job { docker ps; return $LASTEXITCODE } + $result = $job | Wait-Job -Timeout 5 | Receive-Job + + $ErrorActionPreference = $LastErrorActionPreference + $job | Remove-Job -Force + + if (($result -eq $null -and $job.State -ne "Completed") -or ($result | Select -Last 1) -ne 0) { + throw "Docker does not appear to be running. Start/restart docker." + } + } + if ($shouldError) { exit 1 } diff --git a/eng/common/testproxy/publish-proxy-logs.yml b/eng/common/testproxy/publish-proxy-logs.yml index 543527a443..543186edd3 100644 --- a/eng/common/testproxy/publish-proxy-logs.yml +++ b/eng/common/testproxy/publish-proxy-logs.yml @@ -5,12 +5,14 @@ steps: - pwsh: | Copy-Item -Path "${{ parameters.rootFolder }}/test-proxy.log" -Destination "${{ parameters.rootFolder }}/proxy.log" displayName: Copy Log File + condition: succeededOrFailed() - template: ../pipelines/templates/steps/publish-artifact.yml parameters: - ArtifactName: "$(System.JobName)-proxy-logs" + ArtifactName: "$(System.StageName)-$(System.JobName)-$(System.JobAttempt)-proxy-logs" ArtifactPath: "${{ parameters.rootFolder }}/proxy.log" - pwsh: | Remove-Item -Force ${{ parameters.rootFolder }}/proxy.log displayName: Cleanup Copied Log File + condition: succeededOrFailed() diff --git a/samples/integration/vcpkg-all-smoke/src/main.cpp b/samples/integration/vcpkg-all-smoke/src/main.cpp index 678fe23126..705a59a436 100644 --- a/samples/integration/vcpkg-all-smoke/src/main.cpp +++ b/samples/integration/vcpkg-all-smoke/src/main.cpp @@ -7,6 +7,7 @@ */ #include "get_env.hpp" + #include #include #include @@ -18,6 +19,7 @@ #include #include #include + #include using namespace Azure::Security::KeyVault::Keys; diff --git a/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_administration_client.hpp b/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_administration_client.hpp index aa17c5a18e..5bc6bd05b2 100644 --- a/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_administration_client.hpp +++ b/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_administration_client.hpp @@ -5,9 +5,11 @@ #include "azure/attestation/attestation_client_models.hpp" #include "azure/attestation/attestation_client_options.hpp" + #include #include #include + #include namespace Azure { namespace Core { namespace Http { namespace _internal { diff --git a/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client.hpp b/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client.hpp index d7c44d4941..f3e2706538 100644 --- a/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client.hpp +++ b/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client.hpp @@ -5,9 +5,11 @@ #include "azure/attestation/attestation_client_models.hpp" #include "azure/attestation/attestation_client_options.hpp" + #include #include #include + #include namespace Azure { namespace Core { namespace Http { namespace _internal { diff --git a/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client_models.hpp b/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client_models.hpp index c4db47e2ae..88817b8304 100644 --- a/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client_models.hpp +++ b/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client_models.hpp @@ -10,12 +10,14 @@ #pragma once #include "azure/attestation/dll_import_export.hpp" + #include #include #include #include #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client_options.hpp b/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client_options.hpp index b9f1a2450a..f6cfbc5e51 100644 --- a/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client_options.hpp +++ b/sdk/attestation/azure-security-attestation/inc/azure/attestation/attestation_client_options.hpp @@ -11,6 +11,7 @@ #include "azure/attestation/attestation_client_models.hpp" #include "dll_import_export.hpp" + #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/attestation/attest_openenclave_shared.cpp b/sdk/attestation/azure-security-attestation/samples/attestation/attest_openenclave_shared.cpp index 6cf6cc47c0..92fa12594e 100644 --- a/sdk/attestation/azure-security-attestation/samples/attestation/attest_openenclave_shared.cpp +++ b/sdk/attestation/azure-security-attestation/samples/attestation/attest_openenclave_shared.cpp @@ -24,8 +24,10 @@ #include #include "attestation_collateral.hpp" + #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/attestation/attest_openenclave_with_draft_policy.cpp b/sdk/attestation/azure-security-attestation/samples/attestation/attest_openenclave_with_draft_policy.cpp index 2547cf1899..3f0cc91141 100644 --- a/sdk/attestation/azure-security-attestation/samples/attestation/attest_openenclave_with_draft_policy.cpp +++ b/sdk/attestation/azure-security-attestation/samples/attestation/attest_openenclave_with_draft_policy.cpp @@ -24,8 +24,10 @@ #include #include "attestation_collateral.hpp" + #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave.cpp b/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave.cpp index 9b9283c008..cd97b7b684 100644 --- a/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave.cpp +++ b/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave.cpp @@ -24,8 +24,10 @@ #include #include "attestation_collateral.hpp" + #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_binary.cpp b/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_binary.cpp index 2ecc6ddacd..cb9ff6bd83 100644 --- a/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_binary.cpp +++ b/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_binary.cpp @@ -24,8 +24,10 @@ #include #include "attestation_collateral.hpp" + #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_json.cpp b/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_json.cpp index d70c5f43a3..b7a18a96fe 100644 --- a/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_json.cpp +++ b/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_json.cpp @@ -24,8 +24,10 @@ #include #include "attestation_collateral.hpp" + #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/attestation/attestation_collateral.cpp b/sdk/attestation/azure-security-attestation/samples/attestation/attestation_collateral.cpp index 909183566a..53231ab42a 100644 --- a/sdk/attestation/azure-security-attestation/samples/attestation/attestation_collateral.cpp +++ b/sdk/attestation/azure-security-attestation/samples/attestation/attestation_collateral.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "attestation_collateral.hpp" + #include // cspell:disable diff --git a/sdk/attestation/azure-security-attestation/samples/basic-operations/create_admin_client.cpp b/sdk/attestation/azure-security-attestation/samples/basic-operations/create_admin_client.cpp index 652f955970..394d9cb799 100644 --- a/sdk/attestation/azure-security-attestation/samples/basic-operations/create_admin_client.cpp +++ b/sdk/attestation/azure-security-attestation/samples/basic-operations/create_admin_client.cpp @@ -21,6 +21,7 @@ #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/basic-operations/create_client.cpp b/sdk/attestation/azure-security-attestation/samples/basic-operations/create_client.cpp index 9c6d0a4c5f..eeaa32ce60 100644 --- a/sdk/attestation/azure-security-attestation/samples/basic-operations/create_client.cpp +++ b/sdk/attestation/azure-security-attestation/samples/basic-operations/create_client.cpp @@ -16,6 +16,7 @@ #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/policy-certificates/add_policy_certificate.cpp b/sdk/attestation/azure-security-attestation/samples/policy-certificates/add_policy_certificate.cpp index 2103a441a5..d81e7fbed7 100644 --- a/sdk/attestation/azure-security-attestation/samples/policy-certificates/add_policy_certificate.cpp +++ b/sdk/attestation/azure-security-attestation/samples/policy-certificates/add_policy_certificate.cpp @@ -26,6 +26,7 @@ #include #include "cryptohelpers.hpp" + #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/policy-certificates/cryptohelpers.hpp b/sdk/attestation/azure-security-attestation/samples/policy-certificates/cryptohelpers.hpp index edf87acf48..a55b3d5dc9 100644 --- a/sdk/attestation/azure-security-attestation/samples/policy-certificates/cryptohelpers.hpp +++ b/sdk/attestation/azure-security-attestation/samples/policy-certificates/cryptohelpers.hpp @@ -7,16 +7,17 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include #include #include + +#include +#include +#include +#include +#include /** * @brief The Cryptography class provides a set of basic cryptographic primatives required * by the attestation samples. diff --git a/sdk/attestation/azure-security-attestation/samples/policy-certificates/get_policy_certificates.cpp b/sdk/attestation/azure-security-attestation/samples/policy-certificates/get_policy_certificates.cpp index a5cbcd5cf4..d289751dc8 100644 --- a/sdk/attestation/azure-security-attestation/samples/policy-certificates/get_policy_certificates.cpp +++ b/sdk/attestation/azure-security-attestation/samples/policy-certificates/get_policy_certificates.cpp @@ -21,6 +21,7 @@ #include #include "cryptohelpers.hpp" + #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/policy/reset_sealed_policy.cpp b/sdk/attestation/azure-security-attestation/samples/policy/reset_sealed_policy.cpp index 4ebdd8c80e..757b37e4c7 100644 --- a/sdk/attestation/azure-security-attestation/samples/policy/reset_sealed_policy.cpp +++ b/sdk/attestation/azure-security-attestation/samples/policy/reset_sealed_policy.cpp @@ -20,11 +20,13 @@ #include #include "cryptohelpers.hpp" + #include #include #include #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/policy/set_policy.cpp b/sdk/attestation/azure-security-attestation/samples/policy/set_policy.cpp index 063ab26a79..4c45487d0e 100644 --- a/sdk/attestation/azure-security-attestation/samples/policy/set_policy.cpp +++ b/sdk/attestation/azure-security-attestation/samples/policy/set_policy.cpp @@ -23,6 +23,7 @@ #include #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/samples/policy/set_sealed_policy.cpp b/sdk/attestation/azure-security-attestation/samples/policy/set_sealed_policy.cpp index b65f24ef72..c736d8a0dc 100644 --- a/sdk/attestation/azure-security-attestation/samples/policy/set_sealed_policy.cpp +++ b/sdk/attestation/azure-security-attestation/samples/policy/set_sealed_policy.cpp @@ -20,11 +20,13 @@ #include #include "cryptohelpers.hpp" + #include #include #include #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/src/attestation_administration_client.cpp b/sdk/attestation/azure-security-attestation/src/attestation_administration_client.cpp index 30fb8dbf9e..488f20b615 100644 --- a/sdk/attestation/azure-security-attestation/src/attestation_administration_client.cpp +++ b/sdk/attestation/azure-security-attestation/src/attestation_administration_client.cpp @@ -2,18 +2,20 @@ // SPDX-License-Identifier: MIT #include "azure/attestation/attestation_administration_client.hpp" + #include "azure/attestation/attestation_client.hpp" #include "private/attestation_client_models_private.hpp" #include "private/attestation_client_private.hpp" #include "private/attestation_common_request.hpp" #include "private/attestation_deserializers_private.hpp" #include "private/package_version.hpp" + #include #include #include #include -#include +#include #include // cspell: words jwks diff --git a/sdk/attestation/azure-security-attestation/src/attestation_client.cpp b/sdk/attestation/azure-security-attestation/src/attestation_client.cpp index 667f4bb916..9f616ebf23 100644 --- a/sdk/attestation/azure-security-attestation/src/attestation_client.cpp +++ b/sdk/attestation/azure-security-attestation/src/attestation_client.cpp @@ -2,19 +2,21 @@ // SPDX-License-Identifier: MIT #include "azure/attestation/attestation_client.hpp" + #include "azure/attestation/attestation_administration_client.hpp" #include "private/attestation_client_models_private.hpp" #include "private/attestation_client_private.hpp" #include "private/attestation_common_request.hpp" #include "private/attestation_deserializers_private.hpp" #include "private/package_version.hpp" + #include #include #include #include #include -#include +#include #include using namespace Azure::Security::Attestation; diff --git a/sdk/attestation/azure-security-attestation/src/private/attestation_client_models_private.hpp b/sdk/attestation/azure-security-attestation/src/private/attestation_client_models_private.hpp index ac81128938..585f1f993e 100644 --- a/sdk/attestation/azure-security-attestation/src/private/attestation_client_models_private.hpp +++ b/sdk/attestation/azure-security-attestation/src/private/attestation_client_models_private.hpp @@ -12,7 +12,9 @@ #include "azure/attestation/attestation_client_models.hpp" #include "azure/attestation/attestation_client_options.hpp" + #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/src/private/attestation_client_private.cpp b/sdk/attestation/azure-security-attestation/src/private/attestation_client_private.cpp index c3237bde0a..11d81c6073 100644 --- a/sdk/attestation/azure-security-attestation/src/private/attestation_client_private.cpp +++ b/sdk/attestation/azure-security-attestation/src/private/attestation_client_private.cpp @@ -9,7 +9,9 @@ */ #include "attestation_client_models_private.hpp" #include "crypto/inc/crypto.hpp" + #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/src/private/attestation_client_private.hpp b/sdk/attestation/azure-security-attestation/src/private/attestation_client_private.hpp index bfc68430b3..ba71f4ddd0 100644 --- a/sdk/attestation/azure-security-attestation/src/private/attestation_client_private.hpp +++ b/sdk/attestation/azure-security-attestation/src/private/attestation_client_private.hpp @@ -16,10 +16,12 @@ #include "azure/attestation/attestation_client_options.hpp" #include "crypto/inc/crypto.hpp" #include "jsonhelpers_private.hpp" + #include #include #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/src/private/attestation_common_request.cpp b/sdk/attestation/azure-security-attestation/src/private/attestation_common_request.cpp index f8893a6300..060d4ef5e3 100644 --- a/sdk/attestation/azure-security-attestation/src/private/attestation_common_request.cpp +++ b/sdk/attestation/azure-security-attestation/src/private/attestation_common_request.cpp @@ -2,8 +2,10 @@ // SPDX-License-Identifier: MIT #include "attestation_common_request.hpp" + #include #include + #include using namespace Azure::Security::Attestation; diff --git a/sdk/attestation/azure-security-attestation/src/private/attestation_common_request.hpp b/sdk/attestation/azure-security-attestation/src/private/attestation_common_request.hpp index 57722311b6..53ef9d8138 100644 --- a/sdk/attestation/azure-security-attestation/src/private/attestation_common_request.hpp +++ b/sdk/attestation/azure-security-attestation/src/private/attestation_common_request.hpp @@ -11,6 +11,7 @@ #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/src/private/attestation_deserializers_private.cpp b/sdk/attestation/azure-security-attestation/src/private/attestation_deserializers_private.cpp index 684cec9432..366856f0cc 100644 --- a/sdk/attestation/azure-security-attestation/src/private/attestation_deserializers_private.cpp +++ b/sdk/attestation/azure-security-attestation/src/private/attestation_deserializers_private.cpp @@ -12,10 +12,12 @@ */ #include "attestation_deserializers_private.hpp" + #include "attestation_client_models_private.hpp" #include "attestation_client_private.hpp" #include "azure/attestation/attestation_client_models.hpp" #include "jsonhelpers_private.hpp" + #include #include #include @@ -25,6 +27,7 @@ #include #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/src/private/attestation_deserializers_private.hpp b/sdk/attestation/azure-security-attestation/src/private/attestation_deserializers_private.hpp index 9b72f35fac..4526bea823 100644 --- a/sdk/attestation/azure-security-attestation/src/private/attestation_deserializers_private.hpp +++ b/sdk/attestation/azure-security-attestation/src/private/attestation_deserializers_private.hpp @@ -16,7 +16,9 @@ #include "attestation_client_models_private.hpp" #include "azure/attestation/attestation_client.hpp" #include "azure/attestation/attestation_client_models.hpp" + #include + #include #include diff --git a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/openssl_helpers.hpp b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/openssl_helpers.hpp index 691328ec21..cb6f956d2c 100644 --- a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/openssl_helpers.hpp +++ b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/openssl_helpers.hpp @@ -3,12 +3,13 @@ #pragma once #include -#include -#include #include #include #include +#include +#include + namespace Azure { namespace Security { namespace Attestation { namespace _detail { // Helpers to provide RAII wrappers for OpenSSL types. diff --git a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcert.cpp b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcert.cpp index 3f16e58521..66abd5cd5b 100644 --- a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcert.cpp +++ b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcert.cpp @@ -9,13 +9,21 @@ */ #include "opensslcert.hpp" + #include "../inc/crypto.hpp" #include "openssl_helpers.hpp" #include "opensslkeys.hpp" + #include + #include #include #include +#include +#include +#include +#include + #include #include #include @@ -24,10 +32,6 @@ #include #include #include -#include -#include -#include -#include // cspell::words OpenSSL X509 OpenSSLX509 diff --git a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcert.hpp b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcert.hpp index e703260042..ce7efa2e7d 100644 --- a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcert.hpp +++ b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcert.hpp @@ -13,18 +13,20 @@ #include "../../jsonhelpers_private.hpp" #include "../inc/crypto.hpp" #include "openssl_helpers.hpp" + #include -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include +#include + // cspell::words OpenSSL X509 OpenSSLX509 namespace Azure { namespace Security { namespace Attestation { namespace _detail { diff --git a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcrypto.cpp b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcrypto.cpp index a5b2efc353..e6aa9be0d7 100644 --- a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcrypto.cpp +++ b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslcrypto.cpp @@ -11,7 +11,9 @@ #include "../inc/crypto.hpp" #include "opensslcert.hpp" #include "opensslkeys.hpp" + #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslkeys.cpp b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslkeys.cpp index 916c76a487..b01fc93d1c 100644 --- a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslkeys.cpp +++ b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslkeys.cpp @@ -9,22 +9,26 @@ */ #include "opensslkeys.hpp" + #include "../inc/crypto.hpp" #include "openssl_helpers.hpp" + #include + #include #include #include +#include +#include +#include +#include + #include #include #include #include #include #include -#include -#include -#include -#include namespace Azure { namespace Security { namespace Attestation { namespace _detail { diff --git a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslkeys.hpp b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslkeys.hpp index 3526b3e58a..3b60ae334c 100644 --- a/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslkeys.hpp +++ b/sdk/attestation/azure-security-attestation/src/private/crypto/openssl/opensslkeys.hpp @@ -12,16 +12,18 @@ #include "../inc/crypto.hpp" #include "openssl_helpers.hpp" + #include -#include -#include -#include -#include #include #include #include #include +#include +#include +#include +#include + namespace Azure { namespace Security { namespace Attestation { namespace _detail { /** Represents an Asymmetric Key. diff --git a/sdk/attestation/azure-security-attestation/src/private/jsonhelpers.cpp b/sdk/attestation/azure-security-attestation/src/private/jsonhelpers.cpp index ffbb3247ce..e263e7600b 100644 --- a/sdk/attestation/azure-security-attestation/src/private/jsonhelpers.cpp +++ b/sdk/attestation/azure-security-attestation/src/private/jsonhelpers.cpp @@ -12,6 +12,7 @@ */ #include "jsonhelpers_private.hpp" + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/src/private/jsonhelpers_private.hpp b/sdk/attestation/azure-security-attestation/src/private/jsonhelpers_private.hpp index 9bba0704ac..20f936d188 100644 --- a/sdk/attestation/azure-security-attestation/src/private/jsonhelpers_private.hpp +++ b/sdk/attestation/azure-security-attestation/src/private/jsonhelpers_private.hpp @@ -14,9 +14,11 @@ #pragma once #include "azure/attestation/attestation_client.hpp" + #include #include #include + #include #include #include diff --git a/sdk/attestation/azure-security-attestation/test/ut/attestation_collateral.cpp b/sdk/attestation/azure-security-attestation/test/ut/attestation_collateral.cpp index a83527f805..a08e5f1512 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/attestation_collateral.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/attestation_collateral.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "attestation_collateral.hpp" + #include namespace Azure { namespace Security { namespace Attestation { namespace Test { diff --git a/sdk/attestation/azure-security-attestation/test/ut/attestation_metadata.cpp b/sdk/attestation/azure-security-attestation/test/ut/attestation_metadata.cpp index e6dad5d89f..be0c3cc528 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/attestation_metadata.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/attestation_metadata.cpp @@ -3,12 +3,15 @@ #include "attestation_collateral.hpp" #include "azure/attestation/attestation_client.hpp" + #include #include #include -#include + #include +#include + using namespace Azure::Security::Attestation; using namespace Azure::Security::Attestation::Models; using namespace Azure::Core; diff --git a/sdk/attestation/azure-security-attestation/test/ut/attestation_test.cpp b/sdk/attestation/azure-security-attestation/test/ut/attestation_test.cpp index 1a4ff40f4f..3e74a40409 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/attestation_test.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/attestation_test.cpp @@ -4,12 +4,15 @@ #include "../src/private/crypto/inc/crypto.hpp" #include "attestation_collateral.hpp" #include "azure/attestation/attestation_client.hpp" + #include #include #include -#include + #include +#include + using namespace Azure::Security::Attestation; using namespace Azure::Security::Attestation::Models; using namespace Azure::Core; diff --git a/sdk/attestation/azure-security-attestation/test/ut/crypto_test.cpp b/sdk/attestation/azure-security-attestation/test/ut/crypto_test.cpp index a988b22613..ba6912b2a1 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/crypto_test.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/crypto_test.cpp @@ -3,10 +3,13 @@ #include "../../src/private/crypto/inc/crypto.hpp" #include "crypto_test_collateral.hpp" + #include -#include + #include +#include + namespace Azure { namespace Security { namespace Attestation { namespace Test { using namespace Azure::Security::Attestation::_detail; using namespace Azure::Core::Diagnostics::_internal; diff --git a/sdk/attestation/azure-security-attestation/test/ut/policycertmgmt_test.cpp b/sdk/attestation/azure-security-attestation/test/ut/policycertmgmt_test.cpp index 27c3ce57b4..51f8842f58 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/policycertmgmt_test.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/policycertmgmt_test.cpp @@ -5,14 +5,17 @@ #include "attestation_collateral.hpp" #include "azure/attestation/attestation_administration_client.hpp" #include "azure/identity/client_secret_credential.hpp" + #include #include #include + #include -#include #include #include +#include + using namespace Azure::Security::Attestation; using namespace Azure::Security::Attestation::Models; using namespace Azure::Security::Attestation::_detail; diff --git a/sdk/attestation/azure-security-attestation/test/ut/policygetset_test.cpp b/sdk/attestation/azure-security-attestation/test/ut/policygetset_test.cpp index cf266ffa09..a7b65973a7 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/policygetset_test.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/policygetset_test.cpp @@ -5,14 +5,17 @@ #include "attestation_collateral.hpp" #include "azure/attestation/attestation_administration_client.hpp" #include "azure/identity/client_secret_credential.hpp" + #include #include #include + #include -#include #include #include +#include + using namespace Azure::Security::Attestation; using namespace Azure::Security::Attestation::Models; using namespace Azure::Security::Attestation::_detail; diff --git a/sdk/attestation/azure-security-attestation/test/ut/token_test.cpp b/sdk/attestation/azure-security-attestation/test/ut/token_test.cpp index 7725792062..0e128a7ba8 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/token_test.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/token_test.cpp @@ -6,10 +6,12 @@ #include "../../src/private/attestation_deserializers_private.hpp" #include "../../src/private/crypto/inc/crypto.hpp" #include "azure/attestation/attestation_client.hpp" + #include #include #include #include + #include // cspell:words jwk jwks diff --git a/sdk/attestation/azure-security-attestation/test/ut/tpmattestation_test.cpp b/sdk/attestation/azure-security-attestation/test/ut/tpmattestation_test.cpp index d8ba1c091c..4a15b4076e 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/tpmattestation_test.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/tpmattestation_test.cpp @@ -4,12 +4,15 @@ #include "attestation_collateral.hpp" #include "azure/attestation/attestation_administration_client.hpp" #include "azure/attestation/attestation_client.hpp" + #include #include #include -#include + #include +#include + using namespace Azure::Security::Attestation; using namespace Azure::Security::Attestation::Models; using namespace Azure::Core; diff --git a/sdk/core/azure-core-amqp/CMakeLists.txt b/sdk/core/azure-core-amqp/CMakeLists.txt index 3e04eb2435..fc04f1e23d 100644 --- a/sdk/core/azure-core-amqp/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/CMakeLists.txt @@ -43,6 +43,7 @@ set (AZURE_CORE_AMQP_HEADER inc/azure/core/amqp/common/global_state.hpp inc/azure/core/amqp/connection.hpp inc/azure/core/amqp/connection_string_credential.hpp + inc/azure/core/amqp/endpoint.hpp inc/azure/core/amqp/link.hpp inc/azure/core/amqp/message_receiver.hpp inc/azure/core/amqp/message_sender.hpp diff --git a/sdk/core/azure-core-amqp/README.md b/sdk/core/azure-core-amqp/README.md index a32389abf3..6e1bf986cb 100644 --- a/sdk/core/azure-core-amqp/README.md +++ b/sdk/core/azure-core-amqp/README.md @@ -1,15 +1,16 @@ # Azure SDK AMQP Library for C++ Azure::Core::Amqp (`azure-core-amqp`) provides an implementation -to enable developers to create Azure SDKs which consume the AMQP protocol. +to enable developers to create Azure SDKs which consume the AMQP protocol. Note that this is *NOT* a general purpose AMQP library, it is intended solely for the purposes of +building Azure C++ SDK clients which communicate with Azure services over AMQP. ## Getting started ### Include the package -The easiest way to acquire the OpenTelemetry library is leveraging vcpkg package manager. See the corresponding [Azure SDK for C++ readme section][azsdk_vcpkg_install]. +The easiest way to acquire the AMQP library is leveraging vcpkg package manager. See the corresponding [Azure SDK for C++ readme section][azsdk_vcpkg_install]. -To install Azure Core OpenTelemetry package via vcpkg: +To install Azure Core AMQP package via vcpkg: ```cmd > vcpkg install azure-core-amqp-cpp @@ -24,6 +25,16 @@ target_link_libraries( PRIVATE Azure::azure-core-amqp) ## Key concepts +The AMQP Protocol is a relatively complicated protocol which is used by Azure services to communicate with clients. This library provides a +set of classes which can be used to build Azure SDK clients which communicate with Azure services over AMQP. + +The AMQP library provides the following classes: + +- AmqpClient - The basic client used to communicate with the AMQP server. +- MessageSender - A class which is used to send messages to an AMQP server. +- MessageReceiver - A class which is used to receive messages from an AMQP server. + + ## Examples diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/claims_based_security.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/claims_based_security.hpp index 66e3b53538..c8b595025b 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/claims_based_security.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/claims_based_security.hpp @@ -4,6 +4,7 @@ #pragma once #include "azure/core/amqp/session.hpp" + #include namespace Azure { namespace Core { namespace Amqp { namespace _detail { @@ -15,7 +16,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { Ok, Error, Failed, - InstanceClosed + InstanceClosed, }; enum class CbsOpenResult @@ -30,7 +31,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { { Invalid, Sas, - Jwt + Jwt, }; #if defined(TESTING_BUILD) @@ -59,13 +60,13 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { ClaimsBasedSecurity(ClaimsBasedSecurity&&) noexcept = default; ClaimsBasedSecurity& operator=(ClaimsBasedSecurity&&) noexcept = default; - CbsOpenResult Open(Azure::Core::Context = {}); + CbsOpenResult Open(Context const& context = {}); void Close(); std::tuple PutToken( CbsTokenType type, std::string const& audience, std::string const& token, - Azure::Core::Context = {}); + Context const& context = {}); void SetTrace(bool traceEnabled); private: diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/common/async_operation_queue.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/common/async_operation_queue.hpp index 3881d19b4f..421006d3aa 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/common/async_operation_queue.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/common/async_operation_queue.hpp @@ -4,6 +4,7 @@ #pragma once #include + #include #include #include @@ -35,7 +36,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Common { namespace template std::unique_ptr> WaitForPolledResult( - Azure::Core::Context context, + Context const& context, Poller&... pollers) { do @@ -78,7 +79,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Common { namespace void Poll() {} - template void Poll(PT const& first, Ts const&... rest) + template void Poll(PT& first, Ts&... rest) { first.Poll(); Poll(rest...); diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/common/global_state.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/common/global_state.hpp index 9447976140..1dec4b5cd1 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/common/global_state.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/common/global_state.hpp @@ -15,7 +15,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Common { namespace * */ - class GlobalStateHolder { + class GlobalStateHolder final { GlobalStateHolder(); ~GlobalStateHolder(); diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/connection.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/connection.hpp index 0cec95fa01..785634a69b 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/connection.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/connection.hpp @@ -8,68 +8,124 @@ #include "connection_string_credential.hpp" #include "models/amqp_value.hpp" #include "session.hpp" + #include + #include +#include #include #include namespace Azure { namespace Core { namespace Amqp { namespace _detail { class ConnectionImpl; + class ConnectionFactory; }}}} // namespace Azure::Core::Amqp::_detail namespace Azure { namespace Core { namespace Amqp { namespace _internal { class Session; - struct ConnectionOptions - { - // std::chrono::seconds IdleTimeout{std::chrono::seconds(1)}; - uint32_t MaxFrameSize{512}; - uint16_t MaxSessions{65535}; - - Azure::Core::Amqp::Models::AmqpValue Properties; - - std::chrono::seconds Timeout{0}; - - /** Enable tracing from the uAMQP stack. - */ - bool EnableTrace{false}; - - /** Defines the ID of the container for this connection. If empty, a unique 128 bit value will - * be used. - */ - std::string ContainerId; - - std::string HostName; - uint16_t Port{_detail::AmqpsPort}; // Assume TLS port by default. + class Error; - // Default transport to be used. Normally only needed for socket listeners which need to - // specify the listening socket characteristics. - std::shared_ptr Transport{}; + /** @brief The default port used to connect to an AMQP server that does NOT use TLS. */ + constexpr uint16_t AmqpPort = 5672; - // Optional SASL plain credentials. - std::shared_ptr - SaslCredentials{}; - }; - - class Error; + /** @brief The default port to use to connect to an AMQP server using TLS. */ + constexpr uint16_t AmqpTlsPort = 5671; + /** + * @brief The state of the connection. + * + * @remarks This enum is used to track the state of the connection. The state machine is + * implemented in the Connection class. For more information about various connection states, see + * the [AMQP Connection + * States](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#doc-idp184736) + * definition. + * + */ enum class ConnectionState { + /** @brief Start + * In this state a connection exists, but nothing has been sent or received. This is the + * state an implementation would be in immediately after performing a socket connect or + * socket accept. + */ Start, + /** @brief Header Received + * In this state the connection header has been received from the peer but a connection header + * has not been sent. + */ HeaderReceived, + /** @brief Header Sent + * In this state the connection header has been sent to the peer but no connection header has + * been received. + */ HeaderSent, + /** @brief Header Exchanged + * In this state the connection header has been sent to the peer and a connection header has + * been received from the peer. + */ HeaderExchanged, + /** @brief Open Pipe + * In this state both the connection header and the open frame have been sent but nothing has + * been received. + */ OpenPipe, + /** @brief OC Pipe + * In this state, the connection header, the open frame, any pipelined connection traffic, and + * the close frame have been sent but nothing has been received. + */ OcPipe, + /** @brief Open Received + * In this state the connection headers have been exchanged. An open frame has been received + * from the peer but an open frame has not been sent. + */ OpenReceived, + /** @brief Open Sent + * In this state the connection headers have been exchanged. An open frame has been sent to the + * peer but no open frame has yet been received. + */ OpenSent, + /** @brief Close Pipe + * In this state the connection headers have been exchanged. An open frame, any pipelined + * connection traffic, and the close frame have been sent but no open frame has yet been + * received from the peer. + */ ClosePipe, + /** @brief Opened + * In this state the connection header and the open frame have been both sent and received. + */ Opened, + /** @brief Close Received + * In this state a close frame has been received indicating that the peer has initiated an AMQP + * close. No further frames are expected to arrive on the connection; however, frames can still + * be sent. If desired, an implementation MAY do a TCP half-close at this point to shut down the + * read side of the connection. + */ CloseReceived, + /** @brief Close Sent + * In this state a close frame has been sent to the peer. It is illegal to write anything more + * onto the connection, however there could potentially still be incoming frames. If desired, an + * implementation MAY do a TCP half-close at this point to shutdown the write side of the + * connection. + */ CloseSent, + /** @brief Discarding + * The DISCARDING state is a variant of the CLOSE_SENT state where the close is triggered by an + * error. In this case any incoming frames on the connection MUST be silently discarded until + * the peer's close frame is received. + */ Discarding, + /** @brief End + * In this state it is illegal for either endpoint to write anything more onto the connection. + * The connection can be safely closed and discarded. + */ End, - Error + + /** @brief Error + * In this state an error has occurred on the connection. It is illegal for either endpoint to + * write anything more onto the connection. The connection can be safely closed and discarded. + */ + Error, }; class Connection; @@ -77,8 +133,11 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { /** @brief The ConnectionEvents interface defines a series of events triggered on a connection * object. */ - struct ConnectionEvents - { + class ConnectionEvents { + protected: + ~ConnectionEvents(){}; + + public: /** @brief Called when the connection state changes. * * @param connection The connection object whose state changed. @@ -111,62 +170,209 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { * * @param connection The connection object. */ - virtual void OnIoError(Connection const& connection) = 0; + virtual void OnIOError(Connection const& connection) = 0; + }; + + /** @brief Options used to create a connection. */ + struct ConnectionOptions final + { + /** @brief The idle timeout for the connection. + * + * If no frames are received within the timeout, the connection will be closed. + */ + std::chrono::milliseconds IdleTimeout{std::chrono::milliseconds(60000)}; + + /** @brief The maximum frame size for the connection. + * + * The maximum frame size is the largest frame that can be received on the connection. During + * the initial connection negotiation, each peer will send a max frame size. The smaller of the + * two values will be used as the maximum frame size for the connection. + * + * @remarks The maximum frame size must be at least 512 bytes. The default value is the maximum + * value for a uint32. + */ + uint32_t MaxFrameSize{std::numeric_limits::max()}; + + /** @brief The maximum number of channels supported. + * + * A single connection may have multiple independent sessions active simultaneously up to the + * negotiated maximum channel count. + */ + uint16_t MaxChannelCount{65535}; + + /** @brief Properties for the connection. + * + * The properties map contains a set of fields intended to indicate information about the + * connection and its container. + * + */ + Models::AmqpMap Properties; + + /** @brief Port used to communicate with server. + * + * @remarks The default port is the AMQP TLS Port (5671). Ports other than the default will not + * use TLS to communicate with the service. + */ + uint16_t Port{AmqpTlsPort}; + + /** + * Note that the AMQP specification defines the following fields in the open performative which + * are not supported by the underlying uAMQP stack: + * + * - outgoing-locales + * - incoming-locales + * - offered-capabilities + * - desired-capabilities + * + */ + + /** @brief Defines the ID of the container for this connection. If empty, a unique 128 bit value + * will be used. + */ + std::string ContainerId; + + /** @brief Enable tracing from the uAMQP stack. + */ + bool EnableTrace{false}; }; class Connection final { public: + /** @brief Construct a new AMQP Connection. + * + * @param hostName The name of the host to connect to. + * @param options The options to use when creating the connection. + * @param eventHandler The event handler for the connection. + * + * @remarks The requestUri must be a valid AMQP URI. + */ Connection( - std::shared_ptr transport, + std::string const& hostName, ConnectionOptions const& options, ConnectionEvents* eventHandler = nullptr); + /** @brief Construct a new AMQP Connection. + * + * @param transport The transport to use for the connection. + * @param options The options to use when creating the connection. + * @param eventHandler The event handler for the connection. + * + * @remarks This constructor should only be used for an AMQP listener - it is not intended for + * use in a client. + */ Connection( - std::string const& requestUri, + Network::_internal::Transport const& transport, ConnectionOptions const& options, ConnectionEvents* eventHandler = nullptr); + /** @brief Destroy an AMQP connection */ ~Connection(); - Connection(Connection const&) = default; - Connection& operator=(Connection const&) = default; - Connection(Connection&&) noexcept = default; - Connection& operator=(Connection&&) = default; - Connection(std::shared_ptr impl) : m_impl{impl} {} - - std::shared_ptr GetImpl() const { return m_impl; } - + /** @brief Opens the current connection. + * + * @remarks In general, a customer will not need to call this method, instead the connection + * will be opened implicitly by a Session object derived from the connection. It primarily + * exists as a test hook. + * + */ void Open(); + + /** @brief Starts listening for incoming connections. + * + * @remarks This method should only be called on a connection that was created with a transport + * object. + * + */ void Listen(); + /** @brief Closes the current connection. + * + * @param condition The condition for closing the connection. + * @param description The description for closing the connection. + * @param info Additional information for closing the connection. + * + * @remarks In general, a customer will not need to call this method, instead the connection + * will be closed implicitly by a Session object derived from the connection. It primarily + * exists as a test hook. + * + */ void Close( std::string const& condition, std::string const& description, - Azure::Core::Amqp::Models::AmqpValue info); + Models::AmqpValue info); + + void Poll(); - void Poll() const; + /** @brief Gets host configured by the connection. + * + * @return The host used in the connection. + */ + std::string GetHost() const; + /** @brief Gets the port configured by the connection. + * + * @return The port used in the connection. + */ + uint16_t GetPort() const; + + /** @brief Gets the max frame size configured for the connection. + * + * @return The configured maximum frame size for the connection. + */ uint32_t GetMaxFrameSize() const; + + /** @brief Gets the max frame size configured for the remote node. + * + * @return The configured maximum frame size for the remote node. + */ uint32_t GetRemoteMaxFrameSize() const; - void SetMaxFrameSize(uint32_t frameSize); + + /** @brief Gets the max channel count configured for the connection. + * + * @return The configured maximum channel count for the connection. + */ uint16_t GetMaxChannel() const; - void SetMaxChannel(uint16_t frameSize); - std::chrono::milliseconds GetIdleTimeout() const; - void SetIdleTimeout(std::chrono::milliseconds timeout); - void SetRemoteIdleTimeoutEmptyFrameSendRatio(double idleTimeoutEmptyFrameSendRatio); - void SetProperties(Azure::Core::Amqp::Models::AmqpValue properties); - Azure::Core::Amqp::Models::AmqpValue GetProperties() const; - uint64_t HandleDeadlines(); // ??? - Endpoint CreateEndpoint(); - void StartEndpoint(Endpoint const& endpoint); + /** @brief Gets the idle timeout configured for the connection. + * + * @return The configured idle timeout in milliseconds for the connection. + */ + std::chrono::milliseconds GetIdleTimeout() const; - uint16_t GetEndpointIncomingChannel(Endpoint endpoint); - void DestroyEndpoint(Endpoint endpoint); + /** @brief Gets the properties for the connection. + * + * @return The properties for the connection. + */ + Models::AmqpMap GetProperties() const; - void SetTrace(bool enableTrace); + /** @brief Sets the percentage of the idle timeout before an empty frame is sent to the remote + * node. + * + * @param idleTimeoutEmptyFrameSendRatio The percentage of the idle timeout before an empty + * frame is sent to the remote node. + * + * This field determines when to send empty frames to the remote node to keep the connection + * alive as a percentage of the remote nodes idle timeout. For + * example, if the remote node has an idle timeout of 5 minutes, a value of 0.5 will cause an + * empty frame to be sent every 2.5 minutes. + * + * @remarks: The default value for this field is 0.5. + * + * @remarks: Note that this is a dynamic property on the connection, it can be set after the + * connection is opened. + */ + void SetIdleEmptyFrameSendPercentage(double idleTimeoutEmptyFrameSendRatio); private: - std::shared_ptr m_impl; + /** @brief Create an AMQP Connection from an existing connection implementation. + * + * @remarks This constructor is an implementation detail of the AMQP stack and should never be + * called by clients. + * + */ + Connection(std::shared_ptr<_detail::ConnectionImpl> impl) : m_impl{impl} {} + + std::shared_ptr<_detail::ConnectionImpl> m_impl; + friend class _detail::ConnectionFactory; }; }}}} // namespace Azure::Core::Amqp::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/connection_string_credential.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/connection_string_credential.hpp index 44ed03e776..f83c602ba8 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/connection_string_credential.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/connection_string_credential.hpp @@ -4,8 +4,12 @@ #pragma once #include "network/sasl_transport.hpp" + +#include + #include #include +#include #include namespace Azure { namespace Core { namespace Amqp { namespace _internal { @@ -14,29 +18,14 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { // "Endpoint=sb://.servicebus.windows.net/;SharedAccessKeyName=;SharedAccessKey=;EntityPath=" // - enum class CredentialType - { - None, - SaslPlain, - ServiceBusSas, - BearerToken, - }; - - class ConnectionStringCredential { + class ConnectionStringParser final { public: - ConnectionStringCredential(const std::string& connectionString, CredentialType credentialType) - : m_credentialType{credentialType} + ConnectionStringParser(const std::string& connectionString) { ParseConnectionString(connectionString); } - virtual ~ConnectionStringCredential() = default; + ~ConnectionStringParser() = default; - // Prevent tearing of the ConnectionStringCredential. - ConnectionStringCredential(ConnectionStringCredential const&) = delete; - ConnectionStringCredential& operator=(ConnectionStringCredential const&) = delete; - - virtual std::shared_ptr GetTransport() const = 0; - CredentialType GetCredentialType() const { return m_credentialType; } std::string const& GetEndpoint() const { return m_endpoint; } std::string const& GetSharedAccessKeyName() const { return m_sharedAccessKeyName; } std::string const& GetSharedAccessKey() const { return m_sharedAccessKey; } @@ -46,61 +35,56 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { private: void ParseConnectionString(const std::string& connectionString); - const CredentialType m_credentialType; std::string m_endpoint; std::string m_sharedAccessKeyName; std::string m_sharedAccessKey; std::string m_uri; std::string m_hostName; uint16_t m_port; - - protected: std::string m_entityPath; }; - /** @brief A connection string based credential used for AMQP Connection Based Security using an - * SAS token. + /** @brief A connection string based credential used for AMQP Connection Based Security + * using a SAS token. */ - class ServiceBusSasConnectionStringCredential final : public ConnectionStringCredential { + class ServiceBusSasConnectionStringCredential final : public Credentials::TokenCredential { public: /** @brief Create an instance of the ServiceBusSasConnectionStringCredential. * * @param connectionString The connection string for the Service Bus namespace. * @param entityPath The name of the entity to connect to. * - * @remark If the connectionString contains an EntityPath element, and the entityPath parameter - * is provided, this constructor will throw an exception if the two values do not match. + * @remark If the connectionString contains an EntityPath element, and the entityPath + * parameter is provided, this constructor will throw an exception if the two values do + * not match. * */ ServiceBusSasConnectionStringCredential( const std::string& connectionString, const std::string& entityPath = {}) - : ConnectionStringCredential(connectionString, CredentialType::ServiceBusSas) + : TokenCredential("ServiceBusSasConnectionStringCredential"), + m_connectionParser(connectionString) { // If we weren't able to determine the entity path from the ConnectionStringCredential // constructor, use the entity path passed in by the user. - if (m_entityPath.empty()) + if (m_connectionParser.GetEntityPath().empty()) { m_entityPath = entityPath; } - else if (!entityPath.empty() && m_entityPath != entityPath) + else if (!entityPath.empty() && m_connectionParser.GetEntityPath() != entityPath) { // If the user provided an entity path, but it doesn't match the one in the connection // string, throw. - throw std::invalid_argument("Unable to determine entityPath."); + throw std::invalid_argument( + "Entity Path provided: '" + entityPath + + "' does not match connection string entity path: '" + + m_connectionParser.GetEntityPath() + "'."); } } /** @brief Destroy a SAS connection string credential. */ ~ServiceBusSasConnectionStringCredential() override = default; - /** @brief Generate an SAS token with the specified expiration time for this connection string - * credential. - * - * @param expiresOn The expiration time for the SAS token. - */ - std::string GenerateSasToken(std::chrono::system_clock::time_point const& expiresOn) const; - /** @brief Returns the expected audience for this credential. */ std::string GetAudience(); @@ -110,20 +94,46 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { * * @return A SASL transport configured for SASL Anonymous. */ - virtual std::shared_ptr GetTransport() const override; - }; + virtual std::shared_ptr GetTransport() const; - /** A SASL PLAIN connection string credential. - * - * @note This credential type is not supported for Service Bus. - * - */ - class SaslPlainConnectionStringCredential final : public ConnectionStringCredential { - public: - SaslPlainConnectionStringCredential(const std::string& connectionString); + std::string const& GetEndpoint() const { return m_connectionParser.GetEndpoint(); } + std::string const& GetSharedAccessKeyName() const + { + return m_connectionParser.GetSharedAccessKeyName(); + } + std::string const& GetSharedAccessKey() const + { + return m_connectionParser.GetSharedAccessKey(); + } + std::string const& GetEntityPath() const { return m_connectionParser.GetEntityPath(); } + std::string const& GetHostName() const { return m_connectionParser.GetHostName(); } + uint16_t GetPort() const { return m_connectionParser.GetPort(); } - std::shared_ptr GetTransport() const override; + /** + * @brief Gets an authentication token. + * + * @param tokenRequestContext A context to get the token in. + * @param context A context to control the request lifetime. + * + * @return Authentication token. + * + * @throw Credentials::AuthenticationException Authentication error occurred. + */ + virtual Credentials::AccessToken GetToken( + Credentials::TokenRequestContext const& tokenRequestContext, + Context const& context) const override; private: + ConnectionStringParser m_connectionParser; + std::string m_entityPath; + + ///** @brief Generate an SAS token with the specified expiration time for this connection + /// string + // * credential. + // * + // * @param expiresOn The expiration time for the SAS token. + // */ + std::string GenerateSasToken(std::chrono::system_clock::time_point const& expiresOn) const; }; + }}}} // namespace Azure::Core::Amqp::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/endpoint.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/endpoint.hpp new file mode 100644 index 0000000000..54dfe6d37b --- /dev/null +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/endpoint.hpp @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-Licence-Identifier: MIT + +#pragma once + +#include "common/async_operation_queue.hpp" +#include "connection_string_credential.hpp" +#include "models/amqp_value.hpp" + +#include +#include +#include +#include + +extern "C" +{ + struct ENDPOINT_INSTANCE_TAG; + struct LINK_ENDPOINT_INSTANCE_TAG; +} +namespace Azure { namespace Core { namespace Amqp { namespace _detail { + class EndpointFactory; + class LinkEndpointFactory; +}}}} // namespace Azure::Core::Amqp::_detail +namespace Azure { namespace Core { namespace Amqp { namespace _internal { + + // An "Endpoint" is an intermediate type used to create sessions in an OnNewSession callback. + class Endpoint final { + public: + ~Endpoint(); + Endpoint(Endpoint&& that) noexcept : m_endpoint{that.m_endpoint} { that.m_endpoint = nullptr; } + + private: + ENDPOINT_INSTANCE_TAG* m_endpoint; + Endpoint(ENDPOINT_INSTANCE_TAG* endpoint) : m_endpoint{endpoint} {}; + + Endpoint(Endpoint const&) = delete; + Endpoint& operator=(Endpoint const&) = delete; + Endpoint& operator=(Endpoint&& other); + ENDPOINT_INSTANCE_TAG* Release() + { + ENDPOINT_INSTANCE_TAG* rv = m_endpoint; + m_endpoint = nullptr; + return rv; + } + friend class _detail::EndpointFactory; + }; + + // A "Link Endpoint" is an intermediate type used to create new Links in an OnLinkAttached + // callback. Note that LinkEndpoints do not support copy semantics, and the only way to + // retrieve the underlying LINK_ENDPOINT_INSTANCE_TAG is to call Release(). That is because + // the primary use scenario for a LinkEndpoint is to call link_create_from_endpoint, and + // link_create_from_endpoint takes ownership of the underlying LINK_ENDPOINT object. + class LinkEndpoint final { + public: + LinkEndpoint(LinkEndpoint&& that) noexcept : m_endpoint{that.m_endpoint} + { + that.m_endpoint = nullptr; + } + ~LinkEndpoint(){}; + + private: + LINK_ENDPOINT_INSTANCE_TAG* m_endpoint; + + LinkEndpoint(LINK_ENDPOINT_INSTANCE_TAG* endpoint) : m_endpoint{endpoint} {}; + LINK_ENDPOINT_INSTANCE_TAG* Release() + { + LINK_ENDPOINT_INSTANCE_TAG* rv = m_endpoint; + m_endpoint = nullptr; + return rv; + } + + /* NOTE: We do *NOT* own a LinkEndpoint object, it is completely controlled by uAMQP-c. As + * such, we are not allowed to free it.*/ + LinkEndpoint(Endpoint const&) = delete; + LinkEndpoint& operator=(LinkEndpoint const&) = delete; + + LinkEndpoint& operator=(Endpoint&& other); + friend class _detail::LinkEndpointFactory; + }; +}}}} // namespace Azure::Core::Amqp::_internal + +namespace Azure { namespace Core { namespace Amqp { namespace _detail { + class EndpointFactory final { + public: + static _internal::Endpoint CreateEndpoint(ENDPOINT_INSTANCE_TAG* endpoint); + static ENDPOINT_INSTANCE_TAG* Release(_internal::Endpoint& endpoint) + { + return endpoint.Release(); + } + }; + class LinkEndpointFactory final { + public: + static _internal::LinkEndpoint CreateLinkEndpoint(LINK_ENDPOINT_INSTANCE_TAG* endpoint); + static LINK_ENDPOINT_INSTANCE_TAG* Release(_internal::LinkEndpoint& linkEndpoint) + { + return linkEndpoint.Release(); + } + }; + +}}}} // namespace Azure::Core::Amqp::_detail diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/link.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/link.hpp index 976eb30d21..5acc8c731e 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/link.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/link.hpp @@ -4,123 +4,121 @@ #pragma once #include "models/amqp_value.hpp" +#include "models/message_source.hpp" +#include "models/message_target.hpp" #include #include #include #include -struct LINK_INSTANCE_TAG; -namespace Azure { namespace Core { namespace Amqp { - namespace _internal { - class Session; - struct LinkEndpoint; - enum class SenderSettleMode; - enum class ReceiverSettleMode; - - enum class LinkDurability - { - None, - Configuration, - UnsettledState - }; - - enum class SessionRole - { - Sender, - Receiver - }; - } // namespace _internal - - namespace _detail { - class LinkImpl; - - enum class LinkState - { - Invalid, - Detached, - HalfAttachedAttachSent, - HalfAttachAttachReceived, - Attached, - Error, - }; - enum class LinkTransferResult - { - Error, - Busy - }; - - enum class LinkDeliverySettleReason - { - DispositionReceived, - Settled, - NotDelivered, - Timeout, - Cancelled, - }; - - class Error; - class Link; - - class Link final { - public: - Link( - _internal::Session const& session, - std::string const& name, - _internal::SessionRole role, - std::string const& source, - std::string const& target); - Link( - _internal::Session const& session, - _internal::LinkEndpoint& linkEndpoint, - std::string const& name, - _internal::SessionRole role, - std::string const& source, - std::string const& target); - Link(std::shared_ptr impl) : m_impl{impl} {} - ~Link() noexcept; - - Link(Link const&) = default; - Link& operator=(Link const&) = default; - Link(Link&&) noexcept = default; - Link& operator=(Link&&) noexcept = default; - - operator LINK_INSTANCE_TAG*() const; - std::shared_ptr<_detail::LinkImpl> GetImpl() const { return m_impl; } - - void SetSenderSettleMode(_internal::SenderSettleMode senderSettleMode); - _internal::SenderSettleMode GetSenderSettleMode() const; - - void SetReceiverSettleMode(_internal::ReceiverSettleMode receiverSettleMode); - _internal::ReceiverSettleMode GetReceiverSettleMode() const; - - void SetInitialDeliveryCount(uint32_t initialDeliveryCount); - uint32_t GetInitialDeliveryCount() const; - - void SetMaxMessageSize(uint64_t maxMessageSize); - uint64_t GetMaxMessageSize() const; - - uint64_t GetPeerMaxMessageSize() const; - - void SetAttachProperties(Azure::Core::Amqp::Models::AmqpValue attachProperties); - void SetMaxLinkCredit(uint32_t maxLinkCredit); - - std::string GetName() const; - - std::string const& GetTarget() const; - std::string const& GetSource() const; - - uint32_t GetReceivedMessageId() const; - - void Attach(); - - void Detach( - bool close, - std::string const& errorCondition, - std::string const& errorDescription, - Azure::Core::Amqp::Models::AmqpValue& info); - - private: - std::shared_ptr m_impl; - }; - } // namespace _detail -}}} // namespace Azure::Core::Amqp + +namespace Azure { namespace Core { namespace Amqp { namespace _internal { + class Session; + class LinkEndpoint; + enum class SenderSettleMode; + enum class ReceiverSettleMode; + + enum class LinkDurability + { + None, + Configuration, + UnsettledState, + }; + + enum class SessionRole + { + Sender, + Receiver, + }; +}}}} // namespace Azure::Core::Amqp::_internal + +namespace Azure { namespace Core { namespace Amqp { namespace _detail { + class LinkImpl; + + enum class LinkState + { + Invalid, + Detached, + HalfAttachedAttachSent, + HalfAttachAttachReceived, + Attached, + Error, + }; + + enum class LinkTransferResult + { + Error, + Busy, + }; + + enum class LinkDeliverySettleReason + { + DispositionReceived, + Settled, + NotDelivered, + Timeout, + Cancelled, + }; + +#if defined(TESTING_BUILD) + class Link final { + public: + Link( + _internal::Session const& session, + std::string const& name, + _internal::SessionRole role, + Models::_internal::MessageSource const& source, + Models::_internal::MessageTarget const& target); + Link( + _internal::Session const& session, + _internal::LinkEndpoint& linkEndpoint, + std::string const& name, + _internal::SessionRole role, + Models::_internal::MessageSource const& source, + Models::_internal::MessageTarget const& target); + ~Link() noexcept; + + Link(Link const&) = default; + Link& operator=(Link const&) = default; + Link(Link&&) noexcept = default; + Link& operator=(Link&&) noexcept = default; + + void SetSenderSettleMode(_internal::SenderSettleMode senderSettleMode); + _internal::SenderSettleMode GetSenderSettleMode() const; + + void SetReceiverSettleMode(_internal::ReceiverSettleMode receiverSettleMode); + _internal::ReceiverSettleMode GetReceiverSettleMode() const; + + void SetInitialDeliveryCount(uint32_t initialDeliveryCount); + uint32_t GetInitialDeliveryCount() const; + + void SetMaxMessageSize(uint64_t maxMessageSize); + uint64_t GetMaxMessageSize() const; + + uint64_t GetPeerMaxMessageSize() const; + + void SetAttachProperties(Models::AmqpValue attachProperties); + void SetMaxLinkCredit(uint32_t maxLinkCredit); + + std::string GetName() const; + + Models::_internal::MessageTarget const& GetTarget() const; + Models::_internal::MessageSource const& GetSource() const; + + uint32_t GetReceivedMessageId() const; + + void Attach(); + + void Detach( + bool close, + std::string const& errorCondition, + std::string const& errorDescription, + Models::AmqpValue& info); + + private: + Link(std::shared_ptr impl) : m_impl{impl} {} + + std::shared_ptr m_impl; + }; +#endif // defined(TESTING_BUILD) +}}}} // namespace Azure::Core::Amqp::_detail diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/management.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/management.hpp index 3fa702bf67..c22a77a862 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/management.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/management.hpp @@ -5,7 +5,9 @@ #include "models/amqp_message.hpp" #include "session.hpp" + #include + #include #include #include @@ -21,7 +23,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { Ok, Error, FailedBadStatus, - InstanceClosed + InstanceClosed, }; enum class ManagementOpenStatus @@ -66,6 +68,14 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { */ std::string ExpectedStatusDescriptionKeyName = "statusDescription"; + /** @brief The name of the management node. + * + * By default, the name of the management node is "$management", but under certain + * circumstances, management operations can be performed on a different node (for instance, + * $cbs for claims based authentication) + */ + std::string ManagementNodeName = "$management"; + /** * @brief Enable trace logging for the management operations. */ @@ -75,8 +85,11 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { /** * @brief Callback event handler for management events such as error. */ - struct ManagementEvents - { + class ManagementEvents { + protected: + ~ManagementEvents() {} + + public: /** @brief Called when an error occurs. */ virtual void OnError() = 0; @@ -121,17 +134,17 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { * @brief Create a new Management object instance. * * @param session - the session on which to create the instance. - * @param managementNodeName - the name of the message source and target. + * @param managementEntityPath - the entity path of the management object. * @param options - additional options for the Management object. * @param managementEvents - events associated with the management object. */ Management( Session const& session, - std::string const& managementNodeName, + std::string const& managementEntityPath, ManagementOptions const& options, ManagementEvents* managementEvents = nullptr); - Management(std::shared_ptr impl) : m_impl{impl} {} + Management(std::shared_ptr<_detail::ManagementImpl> impl) : m_impl{impl} {} ~Management() noexcept = default; /** @@ -139,7 +152,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { * * @returns The result of the open operation. */ - ManagementOpenStatus Open(Azure::Core::Context const& context = {}); + ManagementOpenStatus Open(Context const& context = {}); /** * @brief Close the management instance. @@ -159,16 +172,19 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { * * @returns a ManagementOperationResult which includes the high level result of the operation, * the HTTP response status code, the status description, and the response message. + * + * @remark The messageToSend is intentionally passed by value because the ExecuteOperation needs + * to modify the message to add the required properties for the management operation. */ ManagementOperationResult ExecuteOperation( std::string const& operationToPerform, std::string const& typeOfOperation, std::string const& locales, - Azure::Core::Amqp::Models::AmqpMessage const& messageToSend, - Azure::Core::Context context = {}); + Models::AmqpMessage messageToSend, + Context const& context = {}); private: - std::shared_ptr m_impl; + std::shared_ptr<_detail::ManagementImpl> m_impl; }; }}}} // namespace Azure::Core::Amqp::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/message_receiver.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/message_receiver.hpp index dda531cb62..31d3139a03 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/message_receiver.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/message_receiver.hpp @@ -10,130 +10,119 @@ #include "models/amqp_message.hpp" #include "models/amqp_value.hpp" #include "session.hpp" + #include #include + #include -namespace Azure { namespace Core { namespace Amqp { - namespace _detail { - class MessageReceiverImpl; - } - namespace _internal { - enum class MessageReceiverState - { - Invalid, - Idle, - Opening, - Open, - Closing, - Error - }; - - enum class ReceiverSettleMode - { - First, - Second - }; - - class MessageReceiver; - - struct MessageReceiverOptions - { - std::string Name; - std::vector AuthenticationScopes; - ReceiverSettleMode SettleMode{ReceiverSettleMode::First}; - std::string TargetAddress; - bool EnableTrace{false}; - Azure::Nullable InitialDeliveryCount; - Azure::Nullable MaxMessageSize; - - bool Batching{false}; - std::chrono::seconds BatchMaxAge{std::chrono::seconds(5)}; - std::vector Capabilities; - uint32_t Credit{1}; - LinkDurability Durability{}; - bool DynamicAddress{false}; - ExpiryPolicy SenderExpiryPolicy{}; - ExpiryPolicy ReceiverExpiryPolicy{}; - std::chrono::seconds ExpiryTimeout{std::chrono::seconds(0)}; - // LinkFilter - bool ManualCredits{}; - Azure::Core::Amqp::Models::AmqpValue Properties; - - std::vector SenderCapabilities; - LinkDurability SenderDurability{}; - std::chrono::seconds SenderExpiryTimeout{std::chrono::seconds(0)}; - }; - - struct MessageReceiverEvents - { - virtual void OnMessageReceiverStateChanged( - MessageReceiver const& receiver, - MessageReceiverState newState, - MessageReceiverState oldState) - = 0; - virtual Azure::Core::Amqp::Models::AmqpValue OnMessageReceived( - MessageReceiver const& receiver, - Azure::Core::Amqp::Models::AmqpMessage const& message) - = 0; - }; - - class MessageReceiver final { - public: - MessageReceiver( - Session& session, - std::string const& receiverSource, - MessageReceiverOptions const& options, - MessageReceiverEvents* receiverEvents = nullptr); - MessageReceiver( - Session& session, - std::shared_ptr credentials, - std::string const& receiverSource, - MessageReceiverOptions const& options, - MessageReceiverEvents* receiverEvents = nullptr); - MessageReceiver( - Session& session, - std::shared_ptr credentials, - std::string const& receiverSource, - MessageReceiverOptions const& options, - MessageReceiverEvents* receiverEvents = nullptr); - MessageReceiver( - Session const& session, - LinkEndpoint& linkEndpoint, - std::string const& receiverSource, - MessageReceiverOptions const& options, - MessageReceiverEvents* receiverEvents = nullptr); - - MessageReceiver() = default; - MessageReceiver(std::shared_ptr impl) - : m_impl{impl} - { - } - ~MessageReceiver() noexcept; - - MessageReceiver(MessageReceiver const&) = default; - MessageReceiver& operator=(MessageReceiver const&) = default; - MessageReceiver(MessageReceiver&&) = default; - MessageReceiver& operator=(MessageReceiver&&) = default; - - operator bool() const; - - void Open(Azure::Core::Context const& context = {}); - void Close(); - std::string GetLinkName() const; - std::string GetSourceName() const; - uint32_t GetReceivedMessageId(); - void SendMessageDisposition( - const char* linkName, - uint32_t messageNumber, - Azure::Core::Amqp::Models::AmqpValue deliveryState); - void SetTrace(bool traceEnabled); - - Azure::Core::Amqp::Models::AmqpMessage WaitForIncomingMessage( - Azure::Core::Context context = {}); - - private: - std::shared_ptr m_impl; - }; - } // namespace _internal -}}} // namespace Azure::Core::Amqp +namespace Azure { namespace Core { namespace Amqp { namespace _detail { + class MessageReceiverImpl; + class MessageReceiverFactory; +}}}} // namespace Azure::Core::Amqp::_detail + +namespace Azure { namespace Core { namespace Amqp { namespace _internal { + enum class MessageReceiverState + { + Invalid, + Idle, + Opening, + Open, + Closing, + Error, + }; + + enum class ReceiverSettleMode + { + First, + Second, + }; + + class MessageReceiver; + + struct MessageReceiverOptions + { + std::string Name; + std::vector AuthenticationScopes; + ReceiverSettleMode SettleMode{ReceiverSettleMode::First}; + Models::_internal::MessageTarget MessageTarget; + bool EnableTrace{false}; + Nullable InitialDeliveryCount; + Nullable MaxMessageSize; + + bool Batching{false}; + std::chrono::seconds BatchMaxAge{std::chrono::seconds(5)}; + std::vector Capabilities; + uint32_t Credit{1}; + LinkDurability Durability{}; + bool DynamicAddress{false}; + ExpiryPolicy SenderExpiryPolicy{}; + ExpiryPolicy ReceiverExpiryPolicy{}; + std::chrono::seconds ExpiryTimeout{std::chrono::seconds(0)}; + // LinkFilter + bool ManualCredits{}; + Models::AmqpValue Properties; + + std::vector SenderCapabilities; + LinkDurability SenderDurability{}; + std::chrono::seconds SenderExpiryTimeout{std::chrono::seconds(0)}; + }; + + class MessageReceiverEvents { + protected: + ~MessageReceiverEvents() = default; + + public: + virtual void OnMessageReceiverStateChanged( + MessageReceiver const& receiver, + MessageReceiverState newState, + MessageReceiverState oldState) + = 0; + virtual Models::AmqpValue OnMessageReceived( + MessageReceiver const& receiver, + Models::AmqpMessage const& message) + = 0; + }; + + class MessageReceiver final { + public: + MessageReceiver( + Session& session, + Models::_internal::MessageSource const& receiverSource, + MessageReceiverOptions const& options, + MessageReceiverEvents* receiverEvents = nullptr); + MessageReceiver( + Session const& session, + LinkEndpoint& linkEndpoint, + Models::_internal::MessageSource const& receiverSource, + MessageReceiverOptions const& options, + MessageReceiverEvents* receiverEvents = nullptr); + + MessageReceiver() = default; + ~MessageReceiver() noexcept; + + MessageReceiver(MessageReceiver const&) = default; + MessageReceiver& operator=(MessageReceiver const&) = default; + MessageReceiver(MessageReceiver&&) = default; + MessageReceiver& operator=(MessageReceiver&&) = default; + + operator bool() const; + + void Open(Context const& context = {}); + void Close(); + std::string GetLinkName() const; + std::string GetSourceName() const; + uint32_t GetReceivedMessageId(); + void SendMessageDisposition( + const char* linkName, + uint32_t messageNumber, + Models::AmqpValue deliveryState); + + Models::AmqpMessage WaitForIncomingMessage(Context const& context = {}); + + private: + MessageReceiver(std::shared_ptr<_detail::MessageReceiverImpl> impl) : m_impl{impl} {} + friend class _detail::MessageReceiverFactory; + std::shared_ptr<_detail::MessageReceiverImpl> m_impl; + }; +}}}} // namespace Azure::Core::Amqp::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/message_sender.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/message_sender.hpp index 3a70f1a5cb..18afb81a85 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/message_sender.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/message_sender.hpp @@ -10,134 +10,178 @@ #include "link.hpp" #include "models/amqp_message.hpp" #include "models/amqp_value.hpp" + #include + #include -namespace Azure { namespace Core { namespace Amqp { - namespace _detail { - class MessageSenderImpl; - } - namespace _internal { - enum class MessageSendResult - { - Invalid, - Ok, - Error, - Timeout, - Cancelled - }; - enum class MessageSenderState - { - Invalid, - Idle, - Opening, - Open, - Closing, - Error - }; - - enum class SenderSettleMode - { - Unsettled, - Settled, - Mixed - }; - - class MessageSender; - struct MessageSenderEvents - { - virtual void OnMessageSenderStateChanged( - MessageSender const& sender, - MessageSenderState newState, - MessageSenderState oldState) - = 0; - }; - - struct MessageSenderOptions - { - std::string Name; - SenderSettleMode SettleMode{}; - std::string SourceAddress; - std::vector AuthenticationScopes; - Azure::Nullable MaxMessageSize; - bool EnableTrace{false}; - Azure::Nullable InitialDeliveryCount; - - // Copied from Go, not sure if they're needed. - std::vector Capabilities; - LinkDurability Durability{}; - bool DynamicAddress{false}; - ExpiryPolicy SenderExpiryPolicy{}; - std::chrono::seconds ExpiryTimeout{std::chrono::seconds(0)}; - bool IgnoreDispositionErrors{false}; - - Azure::Core::Amqp::Models::AmqpValue Properties; - - ReceiverSettleMode RequestedReceiverSettleMode{}; - - std::vector TargetCapabilities; - LinkDurability TargetDurability{}; - ExpiryPolicy TargetExpiryPolicy{}; - std::chrono::seconds TargetExpiryTimeout{std::chrono::seconds(0)}; - }; - - class MessageSender { - public: - using MessageSendCompleteCallback = std::function; - - MessageSender( - Session const& session, - std::string const& target, - MessageSenderOptions const& options, - MessageSenderEvents* events); - - /** @brief Specialization of MessageSender class intended for use in a Message receiving - * handler. - */ - MessageSender( - Session const& session, - LinkEndpoint& newLinkEndpoint, - std::string const& target, - MessageSenderOptions const& options, - MessageSenderEvents* events); - MessageSender( - Session const& session, - std::shared_ptr credential, - std::string const& target, - MessageSenderOptions const& options, - MessageSenderEvents* events); - MessageSender( - Session const& session, - std::shared_ptr credential, - std::string const& target, - MessageSenderOptions const& options, - MessageSenderEvents* events); - MessageSender(std::shared_ptr sender) - : m_impl{sender} - { - } - virtual ~MessageSender() noexcept; - - MessageSender(MessageSender const&) = default; - MessageSender& operator=(MessageSender const&) = default; - MessageSender(MessageSender&&) noexcept = default; - MessageSender& operator=(MessageSender&&) noexcept = default; - - void Open(Azure::Core::Context const& context = {}); - void Close(); - std::tuple Send( - Azure::Core::Amqp::Models::AmqpMessage const& message, - Azure::Core::Context context = {}); - void QueueSend( - Azure::Core::Amqp::Models::AmqpMessage const& message, - MessageSendCompleteCallback onSendComplete, - Azure::Core::Context context = {}); - void SetTrace(bool traceEnabled); - - private: - std::shared_ptr m_impl; - }; - } // namespace _internal -}}} // namespace Azure::Core::Amqp +namespace Azure { namespace Core { namespace Amqp { namespace _detail { + class MessageSenderImpl; + class MessageSenderFactory; +}}}} // namespace Azure::Core::Amqp::_detail + +namespace Azure { namespace Core { namespace Amqp { namespace _internal { + enum class MessageSendStatus + { + Invalid, + Ok, + Error, + Timeout, + Cancelled, + }; + enum class MessageSenderState + { + Invalid, + Idle, + Opening, + Open, + Closing, + Error, + }; + + enum class SenderSettleMode + { + Unsettled, + Settled, + Mixed, + }; + + class MessageSender; + class MessageSenderEvents { + protected: + ~MessageSenderEvents() = default; + + public: + virtual void OnMessageSenderStateChanged( + MessageSender const& sender, + MessageSenderState newState, + MessageSenderState oldState) + = 0; + }; + + struct MessageSenderOptions final + { + /** @brief The name of the link associated with the message sender. + * + * Links are named so that they can be recovered when communication is interrupted. Link names + * MUST uniquely identify the link amongst all links of the same direction between the two + * participating containers. Link names are only used when attaching a link, so they can be + * arbitrarily long without a significant penalty. + * + */ + std::string Name; + + /** @brief The settle mode for the link associated with the message sender. + * + * This field indicates how the deliveries sent over the link SHOULD be settled. When this + * field is set to "mixed", the unsettled map MUST be sent even if it is empty. When this + * field is set to "settled", the value of the unsettled map MUST NOT be sent. See + * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transactions-v1.0-os.html#doc-idp145616 + * for more details. + * + */ + SenderSettleMode SettleMode{}; + + /** @brief The source for the link associated with the message sender. */ + Models::_internal::MessageSource MessageSource; + + /** @brief The Maximum message size for the link associated with the message sender. */ + Nullable MaxMessageSize; + + /** @brief The initial delivery count for the link associated with the message. + * + * The delivery-count is initialized by the sender when a link endpoint is created, and is + * incremented whenever a message is sent. Note that the value of this field can be + * overwritten by the remote peer if a link endpoint is attached with a transfer-id that + * indicates that the peer's value for the delivery-count is ahead of the sender's value. + * + */ + Nullable InitialDeliveryCount; + + /** @brief If true, the message sender will log trace events. */ + bool EnableTrace{false}; + }; + + class MessageSender final { + public: + using MessageSendCompleteCallback + = std::function; + + /** @brief Construct a message sender. + * + * @param session The AMQP session. + * @param target The target to which messages will be sent. + * @param options The options to use when sending messages. + * @param events The events handler for the message sender. + * + */ + MessageSender( + Session const& session, + Models::_internal::MessageTarget const& target, + MessageSenderOptions const& options, + MessageSenderEvents* events); + + /** @brief Construct a message sender for use in a message receiving handler. + * + * @param session The AMQP session. + * @param newLinkEndpoint The link endpoint to use for sending messages. + * @param target The target to which messages will be sent. + * @param options The options to use when sending messages. + * @param events The events handler for the message sender. + * + * @remarks This constructor is primarily used for testing scenarios. + */ + MessageSender( + Session const& session, + LinkEndpoint& newLinkEndpoint, + Models::_internal::MessageTarget const& target, + MessageSenderOptions const& options, + MessageSenderEvents* events); + + ~MessageSender() noexcept; + + MessageSender(MessageSender const&) = default; + MessageSender& operator=(MessageSender const&) = default; + MessageSender(MessageSender&&) noexcept = default; + MessageSender& operator=(MessageSender&&) noexcept = default; + + /** @brief Opens a message sender. + * + * @param context The context to use for the operation. + */ + void Open(Context const& context = {}); + + /** @brief Closes a message sender. + * + */ + void Close(); + + /** @brief Send a message synchronously to the target of the message sender. + * + * @param message The message to send. + * @param context The context to use for the operation. + * + * @return A tuple containing the status of the send operation and the send disposition. + */ + std::tuple Send( + Models::AmqpMessage const& message, + Context const& context = {}); + + /** @brief Queue a message to be sent to the target of the message sender. + */ + void QueueSend( + Models::AmqpMessage const& message, + MessageSendCompleteCallback onSendComplete, + Context const& context = {}); + + private: + /** @brief Construct a MessageSender from a low level message sender implementation. + * + * @remarks This function should never be called by a user. It is used internally by the SDK. + */ + MessageSender(std::shared_ptr<_detail::MessageSenderImpl> sender) : m_impl{sender} {} + + friend class _detail::MessageSenderFactory; + std::shared_ptr<_detail::MessageSenderImpl> m_impl; + }; +}}}} // namespace Azure::Core::Amqp::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_header.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_header.hpp index 905ec9a99c..a3d5b27e7a 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_header.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_header.hpp @@ -5,6 +5,7 @@ #include #include + #include #include #include @@ -52,7 +53,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { * @remarks For more information, see [AMQP * Section 3.2.1](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-header). */ - Azure::Nullable TimeToLive; + Nullable TimeToLive; /** @brief If true, the message has not been acquired by any other link. * diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_message.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_message.hpp index d115f11011..8d4670fe85 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_message.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_message.hpp @@ -6,8 +6,10 @@ #include "amqp_header.hpp" #include "amqp_properties.hpp" #include "amqp_value.hpp" + #include #include + #include #include @@ -65,8 +67,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { */ AmqpMessage& operator=(AmqpMessage&&) = default; - bool operator==(AmqpMessage const& other) const noexcept; - bool operator!=(AmqpMessage const& other) const noexcept { return !(*this == other); } + bool operator==(AmqpMessage const& that) const noexcept; + bool operator!=(AmqpMessage const& that) const noexcept { return !(*this == that); } AmqpMessage(std::nullptr_t) : m_hasValue{false} {} operator bool() const noexcept { return m_hasValue; } @@ -266,7 +268,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * @remarks This class should not be used directly. It is used by the uAMQP interoperability * layer. */ - class AmqpMessageFactory { + class AmqpMessageFactory final { public: static AmqpMessage FromUamqp(UniqueMessageHandle const& properties); static AmqpMessage FromUamqp(MESSAGE_INSTANCE_TAG* properties); diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_properties.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_properties.hpp index 8a1aae613c..d1d7d7a136 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_properties.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_properties.hpp @@ -4,8 +4,10 @@ #pragma once #include "amqp_value.hpp" + #include #include + #include #include @@ -27,19 +29,19 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { MessageProperties() = default; ~MessageProperties() = default; - Azure::Nullable MessageId; - Azure::Nullable CorrelationId; - Azure::Nullable> UserId; - Azure::Nullable To; - Azure::Nullable Subject; - Azure::Nullable ReplyTo; - Azure::Nullable ContentType; - Azure::Nullable ContentEncoding; - Azure::Nullable AbsoluteExpiryTime; - Azure::Nullable CreationTime; - Azure::Nullable GroupId; - Azure::Nullable GroupSequence; - Azure::Nullable ReplyToGroupId; + Nullable MessageId; + Nullable CorrelationId; + Nullable> UserId; + Nullable To; + Nullable Subject; + Nullable ReplyTo; + Nullable ContentType; + Nullable ContentEncoding; + Nullable AbsoluteExpiryTime; + Nullable CreationTime; + Nullable GroupId; + Nullable GroupSequence; + Nullable ReplyToGroupId; bool operator==(MessageProperties const&) const noexcept; bool ShouldSerialize() const noexcept; @@ -58,7 +60,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * @remarks This class should not be used directly. It is used by the uAMQP interoperability * layer. */ - class MessagePropertiesFactory { + class MessagePropertiesFactory final { public: static MessageProperties FromUamqp(UniquePropertiesHandle const& properties); static UniquePropertiesHandle ToUamqp(MessageProperties const& properties); diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_protocol.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_protocol.hpp index 34b666fa67..3943001b68 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_protocol.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_protocol.hpp @@ -7,6 +7,7 @@ #pragma once #include + #include struct AMQPVALUE_DECODER_HANDLE_DATA_TAG; @@ -21,9 +22,6 @@ template <> struct Azure::Core::_internal::UniqueHandleHelper::type; diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_value.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_value.hpp index 0d5235b00c..2842928f85 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_value.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_value.hpp @@ -5,9 +5,10 @@ #include "amqp_header.hpp" -#include #include #include + +#include #include #include #include @@ -37,7 +38,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace { None = 0, Configuration = 1, - UnsettledState = 2 + UnsettledState = 2, }; // Note : Should be an extendable Enumeration. @@ -46,7 +47,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace LinkDetach, SessionEnd, ConnectionClose, - Never + Never, }; }}}}} // namespace Azure::Core::Amqp::Models::_internal @@ -90,7 +91,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { class AmqpComposite; class AmqpDescribed; - class AmqpValue { + class AmqpValue final { public: /** @brief Construct an AMQP null (empty) value. * diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/message_source.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/message_source.hpp index 740ed16cf9..46dddd853a 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/message_source.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/message_source.hpp @@ -18,19 +18,19 @@ template <> struct Azure::Core::_internal::UniqueHandleHelper SourceTerminusDurability; - Azure::Nullable SourceTerminusExpiryPolicy; - Azure::Nullable Timeout; - Azure::Nullable Dynamic; - Azure::Core::Amqp::Models::AmqpMap DynamicNodeProperties; - Azure::Nullable DistributionMode; - Azure::Core::Amqp::Models::AmqpMap Filter; - Azure::Core::Amqp::Models::AmqpValue DefaultOutcome; - Azure::Core::Amqp::Models::AmqpArray Outcomes; - Azure::Core::Amqp::Models::AmqpArray Capabilities; + AmqpValue Address; + Nullable SourceTerminusDurability; + Nullable SourceTerminusExpiryPolicy; + Nullable Timeout; + Nullable Dynamic; + AmqpMap DynamicNodeProperties; + Nullable DistributionMode; + AmqpMap Filter; + AmqpValue DefaultOutcome; + AmqpArray Outcomes; + AmqpArray Capabilities; }; class MessageSource final { @@ -42,7 +42,14 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace ~MessageSource() = default; // Create a described source from an AMQP Value - used in the OnLinkAttached. - MessageSource(Azure::Core::Amqp::Models::AmqpValue const& value); + MessageSource(AmqpValue const& value); + + /** @brief Copies a MessageSource */ + MessageSource(MessageSource const& that); + + /** Assigns a message source from another. + */ + MessageSource& operator=(MessageSource const& that); /** @brief Creates a message source with detailed options. * @@ -67,7 +74,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * * @remarks Creates an AMQP Described value with the descriptor being the message source (0x29). */ - operator const Azure::Core::Amqp::Models::AmqpValue() const; + AmqpValue AsAmqpValue() const; /** @brief Gets the address of the source. * @@ -77,7 +84,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * [source](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-source) * for more information about the fields in a message source. */ - Azure::Core::Amqp::Models::AmqpValue GetAddress() const; + AmqpValue GetAddress() const; /** @brief Gets the durability of the source. * @@ -130,7 +137,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * [source](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-source) * for more information about the fields in a message source. */ - Azure::Core::Amqp::Models::AmqpMap GetDynamicNodeProperties() const; + AmqpMap GetDynamicNodeProperties() const; /** @brief Gets the distribution mode of the source. * @@ -150,7 +157,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * set](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-filter-set) * for more information. */ - Azure::Core::Amqp::Models::AmqpMap GetFilter() const; + AmqpMap GetFilter() const; /** @brief Gets the default outcome of the source. * @@ -161,7 +168,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * for more information about the fields in a message source. * */ - Azure::Core::Amqp::Models::AmqpValue GetDefaultOutcome() const; + AmqpValue GetDefaultOutcome() const; /** @brief Gets the outcomes of the source. * @@ -172,7 +179,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * [source](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-source) * for more information about the fields in a message source. */ - Azure::Core::Amqp::Models::AmqpArray GetOutcomes() const; + AmqpArray GetOutcomes() const; /** @brief Gets the capabilities of the source. * @@ -183,7 +190,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * for more information about the fields in a message source. * */ - Azure::Core::Amqp::Models::AmqpArray GetCapabilities() const; + AmqpArray GetCapabilities() const; private: operator SOURCE_INSTANCE_TAG*() const { return m_source.get(); } diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/message_target.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/message_target.hpp index 3e3af66b77..b41e31ee1e 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/message_target.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/message_target.hpp @@ -19,13 +19,13 @@ using UniqueMessageTargetHandle = Azure::Core::_internal::UniqueHandle TerminusDurabilityValue; - Azure::Nullable TerminusExpiryPolicyValue; - Azure::Nullable Timeout; - Azure::Nullable Dynamic; + Nullable TerminusDurabilityValue; + Nullable TerminusExpiryPolicyValue; + Nullable Timeout; + Nullable Dynamic; AmqpMap DynamicNodeProperties; AmqpArray Capabilities; }; @@ -38,6 +38,9 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace /** @brief Deletes a message target. */ ~MessageTarget() = default; + /** @brief Copies a MessageTarget */ + MessageTarget(MessageTarget const& that); + /** @brief Creates a message target with the given address. * * @param address The address of the target. @@ -62,13 +65,15 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * * @remarks Normally used in the OnLinkAttached callback. */ - MessageTarget(Azure::Core::Amqp::Models::AmqpValue const& value); + MessageTarget(Models::AmqpValue const& value); + + MessageTarget& operator=(MessageTarget const& that); /** @brief Creates an AMQP value from a message target. * * @remarks Creates an AMQP Described value with the descriptor being the message target (0x29). */ - operator const Azure::Core::Amqp::Models::AmqpValue() const; + AmqpValue AsAmqpValue() const; /** @brief The address of the target. * @@ -79,7 +84,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * for more information about the fields in a message target. * */ - Azure::Core::Amqp::Models::AmqpValue GetAddress() const; + AmqpValue GetAddress() const; /** @brief The durability of the target. * @@ -128,7 +133,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * for more information about the fields in a message target. * */ - Azure::Core::Amqp::Models::AmqpMap GetDynamicNodeProperties() const; + AmqpMap GetDynamicNodeProperties() const; /** @brief Retrieve the capabilities on this message target. * @@ -137,7 +142,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace * for more information about the fields in a message target. * */ - Azure::Core::Amqp::Models::AmqpArray GetCapabilities() const; + AmqpArray GetCapabilities() const; private: UniqueMessageTargetHandle m_target; diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/messaging_values.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/messaging_values.hpp index 5a1ffc6212..83ea4c6795 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/messaging_values.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/models/messaging_values.hpp @@ -5,22 +5,22 @@ #include "amqp_value.hpp" namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace _internal { - struct Messaging - { - static Azure::Core::Amqp::Models::AmqpValue CreateSource(std::string const& address); - static Azure::Core::Amqp::Models::AmqpValue CreateTarget(std::string const& address); - static Azure::Core::Amqp::Models::AmqpValue DeliveryReceived( - uint32_t sectionNumber, - uint64_t sectionOffset); - static Azure::Core::Amqp::Models::AmqpValue DeliveryAccepted(); - static Azure::Core::Amqp::Models::AmqpValue DeliveryRejected( + class Messaging final { + public: + static Models::AmqpValue DeliveryReceived(uint32_t sectionNumber, uint64_t sectionOffset); + static Models::AmqpValue DeliveryAccepted(); + static Models::AmqpValue DeliveryRejected( std::string const& errorCondition, std::string const& errorDescription); - static Azure::Core::Amqp::Models::AmqpValue DeliveryReleased(); - static Azure::Core::Amqp::Models::AmqpValue DeliveryModified( + static Models::AmqpValue DeliveryReleased(); + static Models::AmqpValue DeliveryModified( bool deliveryFailed, bool undeliverableHere, - Azure::Core::Amqp::Models::AmqpValue annotations); + Models::AmqpValue annotations); + + private: + Messaging() = delete; + ~Messaging() = delete; }; }}}}} // namespace Azure::Core::Amqp::Models::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/amqp_header_detect_transport.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/amqp_header_detect_transport.hpp index 16a7c9b04c..d3971e0233 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/amqp_header_detect_transport.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/amqp_header_detect_transport.hpp @@ -4,26 +4,27 @@ #pragma once #include "transport.hpp" + #include namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - /** A transport that detects the AMQP header on an incoming message. Used when listening for - * incoming AMQP connections and messages. + /** @brief Factory to create a transport which detects the AMQP header on an incoming message. + * Used when listening for incoming AMQP connections and messages. */ - class AmqpHeaderDetectTransport final : public Transport { + class AmqpHeaderDetectTransportFactory final { public: - /** Construct a new instance of the Amqp Header Detect Transport. - * * - * * @param parentTransport The parent transport to read from. - * * @param eventHandler The event handler to notify when the AMQP header is detected. - * * + /** Construct a new instance of an Amqp Header Detect Transport. + * + * @param parentTransport The parent transport to read from. + * @param eventHandler The event handler to notify when the AMQP header is detected. + * */ - AmqpHeaderDetectTransport( + static Transport Create( std::shared_ptr parentTransport, TransportEvents* eventHandler); - ~AmqpHeaderDetectTransport() = default; + AmqpHeaderDetectTransportFactory() = delete; }; }}}}} // namespace Azure::Core::Amqp::Network::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/sasl_transport.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/sasl_transport.hpp index c63ef2bd97..3d089e63ef 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/sasl_transport.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/sasl_transport.hpp @@ -4,26 +4,46 @@ #pragma once #include "transport.hpp" + #include namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - class SaslTransport final : public Transport { + /** @brief Factory to create a transport using SASL authentication. + * + */ + class SaslTransportFactory final { public: - // Configure the transport using SASL plain. - SaslTransport( + /** @brief Create a transport using SASL Plain. + * + * @param[in] saslKeyName The SASL key name. + * @param[in] saslKey The SASL key. + * @param[in] hostName The host name. + * @param[in] hostPort The host port. + * @param[in] eventHandler The transport event handler. + * + */ + static Transport Create( std::string const& saslKeyName, std::string const& saslKey, std::string const& hostName, uint16_t hostPort, TransportEvents* eventHandler = nullptr); - // Configure the transport using SASL Anonymous. - SaslTransport( + + /** @brief Create a transport using SASL Anonymous + * + * @param[in] hostName The host name. + * @param[in] hostPort The host port. + * @param[in] eventHandler The transport event handler. + * + */ + static Transport Create( std::string const& hostName, uint16_t hostPort, TransportEvents* eventHandler = nullptr); - ~SaslTransport() = default; + + SaslTransportFactory() = delete; }; }}}}} // namespace Azure::Core::Amqp::Network::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/socket_listener.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/socket_listener.hpp index 4461e408e7..6fe5860d49 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/socket_listener.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/socket_listener.hpp @@ -4,6 +4,7 @@ #pragma once #include "transport.hpp" + #include #include #include @@ -15,10 +16,14 @@ struct IO_INTERFACE_DESCRIPTION_TAG; namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - struct SocketListenerEvents - { + class SocketListenerEvents { + protected: + ~SocketListenerEvents() {} + + public: virtual void OnSocketAccepted(std::shared_ptr newTransport) = 0; }; + class SocketListener final { public: SocketListener(uint16_t port, SocketListenerEvents* eventHandler); diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/socket_transport.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/socket_transport.hpp index 8fae201bcb..61ff9da59c 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/socket_transport.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/socket_transport.hpp @@ -4,19 +4,32 @@ #pragma once #include "transport.hpp" + #include + #include namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - class SocketTransport final : public Transport { + /** @brief Factory used to create a socket connection to the remote node. */ + class SocketTransportFactory final { public: - SocketTransport( + /** + * @brief Creates a socket connection to the remote node. + * + * @param hostName Fully qualified domain name or IP address of the remote node. + * @param hostPort Port number of the remote node. + * @param eventHandler Optional pointer to the event handler to be notified of transport events. + * + * @return The created transport. + */ + static Transport Create( std::string const& hostName, uint16_t hostPort, TransportEvents* eventHandler = nullptr); - ~SocketTransport() = default; + + SocketTransportFactory() = delete; }; }}}}} // namespace Azure::Core::Amqp::Network::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/tls_transport.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/tls_transport.hpp index 32848dab02..5ee93bbe8d 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/tls_transport.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/tls_transport.hpp @@ -4,18 +4,28 @@ #pragma once #include "transport.hpp" + #include namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - class TlsTransport final : public Transport { - + /** @brief Factory to create a TLS connection to a remote node. + */ + class TlsTransportFactory final { public: - TlsTransport(TransportEvents* eventHandler = nullptr); - TlsTransport( + /** @brief Creates a TLS transport. + * * + * * @param hostName Host name to connect to. + * * @param hostPort Port to connect to. + * * @param eventHandler Optional event handler. + * * @return Transport. + * * + */ + static Transport Create( std::string const& hostName, uint16_t hostPort, TransportEvents* eventHandler = nullptr); - ~TlsTransport() = default; + + TlsTransportFactory() = delete; }; }}}}} // namespace Azure::Core::Amqp::Network::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/transport.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/transport.hpp index e8ab1494f9..6c7ed51680 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/transport.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/network/transport.hpp @@ -5,6 +5,8 @@ // SPDX-Licence-Identifier: MIT #pragma once +#include + #include #include #include @@ -16,60 +18,122 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac }}}}} // namespace Azure::Core::Amqp::Network::_detail namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - enum class TransportState - { - Closed, - Closing, - Open, - Opening, - Unknown - }; - enum class TransportOpenResult + /** @brief Status of a transport open operation. + * + * + */ + enum class TransportOpenStatus { + /// Transport is in invalid state. Invalid, + /// Transport open successful. Ok, + /// Transport open failed with an error. Error, - Cancelled + /// Transport open was cancelled. + Cancelled, }; - enum class TransportSendResult + + /** @brief Status of a transport send operation. + * + */ + enum class TransportSendStatus { + /// Send status Invalid - this should never be returned. Invalid, + + /// Send status unknown Unknown, + + /// Send successful Ok, + + /// Send completed with an error. Error, - Cancelled + + /// Send was cancelled. + Cancelled, }; class Transport; - struct TransportEvents - { - virtual void OnOpenComplete(TransportOpenResult openResult) = 0; + /** Transport operational events. + * + * Normally a client will not have to register for these events, but they are available for + * clients if necessary. + */ + class TransportEvents { + protected: + ~TransportEvents() {} + + public: + /** @brief Called when bytes are received on the transport. + * + * @param transport The transport on which bytes are received. + * @param buffer The buffer containing the bytes received. + * @param size The size of the buffer. + * + */ virtual void OnBytesReceived( Transport const& transport, const unsigned char* buffer, size_t size) = 0; - virtual void OnIoError() = 0; + + /** @brief Called when an error has occurred on the transport */ + virtual void OnIOError() = 0; }; - class Transport { + class Transport final { public: - using TransportCloseCompleteFn = std::function; - using TransportSendCompleteFn = std::function; - Transport(std::shared_ptr<_detail::TransportImpl> impl) : m_impl{impl} {} - virtual ~Transport(); - virtual bool Open(); - virtual bool Close(TransportCloseCompleteFn); - virtual bool Send(uint8_t*, size_t, TransportSendCompleteFn) const; + using TransportSendCompleteFn = std::function; + + /** @brief Called when a transport object is destroyed. */ + ~Transport(); + + /** @brief Open the transport. + * + * @param context The context for cancellation. + * @return TransportOpenStatus + */ + TransportOpenStatus Open(Context const& context = {}); + + /** @brief Close the transport. + * + * @param context - The context for cancellation. + * + */ + void Close(Context const& context = {}); + + /** @brief Send bytes on the transport. + * + * @param buffer The buffer containing the bytes to send. + * @param size The size of the buffer. + * @param callback The callback to be called when the send operation is completed. + * @return bool + */ + bool Send(uint8_t* buffer, size_t size, TransportSendCompleteFn callback) const; + + /** @brief Poll the transport for events. + */ void Poll() const; - virtual std::shared_ptr<_detail::TransportImpl> GetImpl() const { return m_impl; } + + /** @brief Set the event handler for the transport. + * + * @param events The event handler to be set. + * + * @remarks Normally a client will not have to register for these events via this method, but + * there may be circumstances where it is necessary (if, for instance the transport was created + * internally as a result of a socket listener). + */ void SetEventHandler(TransportEvents* events); - protected: - Transport(TransportEvents* events); + Transport(std::shared_ptr<_detail::TransportImpl> impl) : m_impl{impl} {} + std::shared_ptr<_detail::TransportImpl> GetImpl() const { return m_impl; } + + private: std::shared_ptr<_detail::TransportImpl> m_impl; }; }}}}} // namespace Azure::Core::Amqp::Network::_internal diff --git a/sdk/core/azure-core-amqp/inc/azure/core/amqp/session.hpp b/sdk/core/azure-core-amqp/inc/azure/core/amqp/session.hpp index 2577a7aa5c..c46754024b 100644 --- a/sdk/core/azure-core-amqp/inc/azure/core/amqp/session.hpp +++ b/sdk/core/azure-core-amqp/inc/azure/core/amqp/session.hpp @@ -5,6 +5,7 @@ #include "common/async_operation_queue.hpp" #include "connection_string_credential.hpp" +#include "endpoint.hpp" #include "models/amqp_value.hpp" #include @@ -12,154 +13,149 @@ #include #include -extern "C" -{ - struct ENDPOINT_INSTANCE_TAG; - struct LINK_ENDPOINT_INSTANCE_TAG; -} - -namespace Azure { namespace Core { namespace Amqp { - namespace _detail { - class SessionImpl; - } // namespace _detail - namespace _internal { - - class Connection; - class Cbs; - - // Dummy operations for operations that should never be used. - class Flow; - class Attach; - class Disposition; - class Detach; - class Transfer; - enum class SessionRole; - - struct SessionOptions - { - uint32_t IncomingWindow; - uint32_t OutgoingWindow; - uint32_t MaxLinks; - }; - - enum class ExpiryPolicy - { - LinkDetach, - SessionEnd, - ConnectionClose, - Never - }; - - // An "Endpoint" is an intermediate type used to create sessions in an OnNewSession callback. - struct Endpoint - { - ENDPOINT_INSTANCE_TAG* m_endpoint; - Endpoint(ENDPOINT_INSTANCE_TAG* endpoint) : m_endpoint{endpoint} {}; - ~Endpoint(); - Endpoint(Endpoint const&) = delete; - Endpoint& operator=(Endpoint const&) = delete; - - Endpoint(Endpoint&& other) noexcept : m_endpoint{other.m_endpoint} - { - other.m_endpoint = nullptr; - } - Endpoint& operator=(Endpoint&& other); - ENDPOINT_INSTANCE_TAG* Release() - { - ENDPOINT_INSTANCE_TAG* rv = m_endpoint; - m_endpoint = nullptr; - return rv; - } - }; - - // A "Link Endpoint" is an intermediate type used to create new Links in an OnLinkAttached - // callback. Note that LinkEndpoints do not support copy semantics, and the only way to - // retrieve the underlying LINK_ENDPOINT_INSTANCE_TAG is to call Release(). That is because - // the primary use scenario for a LinkEndpoint is to call link_create_from_endpoint, and - // link_create_from_endpoint takes ownership of the underlying LINK_ENDPOINT object. - struct LinkEndpoint - { - LINK_ENDPOINT_INSTANCE_TAG* m_endpoint; - LinkEndpoint(LINK_ENDPOINT_INSTANCE_TAG* endpoint) : m_endpoint{endpoint} {}; - /* NOTE: We do *NOT* own a LinkEndpoint object, it is completely controlled by uAMQP-c. As - * such, we are not allowed to free it.*/ - ~LinkEndpoint(){}; - LinkEndpoint(Endpoint const&) = delete; - LinkEndpoint& operator=(LinkEndpoint const&) = delete; - - LinkEndpoint(LinkEndpoint&& other) noexcept : m_endpoint{other.m_endpoint} - { - other.m_endpoint = nullptr; - } - LinkEndpoint& operator=(Endpoint&& other); - LINK_ENDPOINT_INSTANCE_TAG* Release() - { - LINK_ENDPOINT_INSTANCE_TAG* rv = m_endpoint; - m_endpoint = nullptr; - return rv; - } - }; - - enum class SessionState - { - Unmapped, - BeginSent, - BeginReceived, - Mapped, - EndSent, - EndReceived, - Discarding, - Error, - }; - - enum class SessionSendTransferResult - { - Ok, - Error, - Busy, - }; - - class Session; - struct SessionEvents - { - virtual bool OnLinkAttached( - Session const& session, - LinkEndpoint& newLink, - std::string const& name, - SessionRole role, - Azure::Core::Amqp::Models::AmqpValue source, - Azure::Core::Amqp::Models::AmqpValue target, - Azure::Core::Amqp::Models::AmqpValue properties) - = 0; - }; - - class Session final { - public: - Session( - Connection const& parentConnection, - Endpoint& newEndpoint, - SessionEvents* eventHandler = nullptr); - Session(Connection const& parentConnection, SessionEvents* eventHandler = nullptr); - Session(std::shared_ptr impl) : m_impl{impl} {} - ~Session() noexcept; - - Session(Session const&) = delete; - Session& operator=(Session const&) = delete; - Session(Session&&) noexcept = delete; - Session& operator=(Session&&) noexcept = delete; - std::shared_ptr GetImpl() const { return m_impl; } - void SetIncomingWindow(uint32_t incomingWindow); - uint32_t GetIncomingWindow() const; - void SetOutgoingWindow(uint32_t outgoingWindow); - uint32_t GetOutgoingWindow() const; - void SetHandleMax(uint32_t handleMax); - uint32_t GetHandleMax() const; - - void Begin(); - void End(std::string const& condition_value, std::string const& description); - - private: - std::shared_ptr m_impl; - }; - } // namespace _internal -}}} // namespace Azure::Core::Amqp +namespace Azure { namespace Core { namespace Amqp { namespace _detail { + class SessionImpl; + class SessionFactory; +}}}} // namespace Azure::Core::Amqp::_detail + +namespace Azure { namespace Core { namespace Amqp { namespace _internal { + + class Connection; + enum class SessionRole; + + enum class ExpiryPolicy + { + LinkDetach, + SessionEnd, + ConnectionClose, + Never, + }; + + enum class SessionState + { + Unmapped, + BeginSent, + BeginReceived, + Mapped, + EndSent, + EndReceived, + Discarding, + Error, + }; + + enum class SessionSendTransferResult + { + Ok, + Error, + Busy, + }; + + class Session; + class SessionEvents { + protected: + ~SessionEvents() = default; + + public: + virtual bool OnLinkAttached( + Session const& session, + LinkEndpoint& newLink, + std::string const& name, + SessionRole role, + Models::AmqpValue const& source, + Models::AmqpValue const& target, + Models::AmqpValue const& properties) + = 0; + }; + + struct SessionOptions final + { + /** @brief The Audience to which an authentication operation applies when using Claims Based + * Authentication. */ + std::vector AuthenticationScopes; + + /** @brief Represents the initial incoming window size for the sender. See [AMQP Session Flow + * Control](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#doc-session-flow-control) + * for more information.*/ + Nullable InitialIncomingWindowSize; + /** @brief Represents the initial outgoing window size for the sender. See [AMQP Session Flow + * Control](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#doc-session-flow-control) + * for more information.*/ + Nullable InitialOutgoingWindowSize; + + /** @brief Represents the maximum number of link handles which can be used on the session. See + * [AMQP Session Flow + * Control](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#doc-session-flow-control) + * for more information.*/ + Nullable MaximumLinkCount; + }; + + class Session final { + public: + /** @brief Create a new AMQP Session object on the specified parent connection. + * + * @param parentConnection - Connection upon which to create the session. + * @param credential - Credential to use for authentication. + * @param options - Options to use when creating the session. + * @param eventHandler - Event handler for session events. + */ + Session( + Connection const& parentConnection, + std::shared_ptr credential, + SessionOptions const& options = {}, + SessionEvents* eventHandler = nullptr); + + /** @brief Construct a new session associated with the specified connection over the specified + * endpoint. + * + * @param parentConnection - Connection upon which to create the session. + * @param newEndpoint - AMQP Endpoint from which to create the session. + * @param eventHandler - Event handler for session events. + * + * @remarks Note that this function is normally only called from a application listening for + * incoming connections, not from an AMQP client. + */ + Session( + Connection const& parentConnection, + Endpoint& newEndpoint, + SessionOptions const& options = {}, + SessionEvents* eventHandler = nullptr); + + /** @brief Destroys the session object. */ + ~Session() noexcept; + + /** @brief Returns the current value of the incoming window. + * + * @returns The current incoming message window. + */ + uint32_t GetIncomingWindow() const; + /** @brief Returns the current value of the outgoing window. + * + * @returns The current outgoing message window. + */ + uint32_t GetOutgoingWindow() const; + + /** @brief Returns the maximum number of links currently configured. + * + * @returns The current maximum number of links configured. + */ + uint32_t GetHandleMax() const; + + void Begin(); + void End(std::string const& condition_value, std::string const& description); + + friend class _detail::SessionFactory; + + private: + /** @brief Construct a new Session object from an existing implementation instance. + * + * @param impl - Implementation object + * + * @remarks This function is used internally by the library and is not intended for use by any + * client. + */ + Session(std::shared_ptr<_detail::SessionImpl> impl) : m_impl{impl} {} + + std::shared_ptr<_detail::SessionImpl> m_impl; + }; + +}}}} // namespace Azure::Core::Amqp::_internal diff --git a/sdk/core/azure-core-amqp/samples/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/CMakeLists.txt index fe440b682f..96a74d5b7d 100644 --- a/sdk/core/azure-core-amqp/samples/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/CMakeLists.txt @@ -7,12 +7,4 @@ cmake_minimum_required (VERSION 3.13) # Include sub-projects. -add_subdirectory ("local_server_sample") -add_subdirectory ("local_client_sample") -add_subdirectory ("local_client_async_sample") -add_subdirectory ("eventhub_writer_sample") -add_subdirectory ("eventhub_sas_writer_sample") -add_subdirectory ("eventhub_token_writer_sample") -add_subdirectory ("eventhub_async_writer_sample") -add_subdirectory ("eventhub_reader_sample") -add_subdirectory ("eventhub_sas_reader_sample") +add_subdirectory ("internal") diff --git a/sdk/core/azure-core-amqp/samples/README.md b/sdk/core/azure-core-amqp/samples/README.md new file mode 100644 index 0000000000..5f2966a7d3 --- /dev/null +++ b/sdk/core/azure-core-amqp/samples/README.md @@ -0,0 +1,92 @@ +--- +page_type: sample +languages: +- C++ +products: +- azure +- azure-core-amqp +urlFragment: azure-core-amqp + +--- + +# Samples for the Microsoft Azure SDK for C++ AMQP client library + +These code samples show common scenario operations for the Azure SDK for C++ AMQP support. + +The AMQP client library is a C++ library for communicating with entities that use the AMQP +protocol. It is a wrapper around the [Azure uAMQP Library](https://github.com/Azure/azure-uamqp-c/). + +These samples are intended to demonstrate common AMQP use scenarios for Azure Service authors and are +not intended to be a comprehensive collection of all possible uses for the library. The samples are +grouped into folders by feature set. Each sample includes a README that describes the scenario. + +> **NOTE** AMQP Support in the Azure SDK for C++ is intended *only* for use with Azure services. +It is *not* a general purpose AMQP library. Because the library is intended for internal consumption only, +the contents of this library are NOT subject to the normal breaking change policies for the Azure SDK and +may change at any time without warning + +## Prerequisites + +The samples are compatible with C++ 14 and later. + +## Sample Overview + +All samples are standalone console applications that can be built and run independently. Each sample has similar dependencies: They assume that an existing +Azure EventHubs instance has been created and the following environment variables are set: + +- `EVENTHUB_CONNECTION_STRING`: The connection string for the EventHubs instance. +- `EVENTHUB_NAME`: The name of the EventHubs instance. +- `SAMPLES_CLIENT_ID`: The client ID for the EventHubs instance. +- `SAMPLES_CLIENT_SECRET`: The client secret for the EventHubs instance. +- `SAMPLES_TENANT_ID`: The tenant ID for the EventHubs instance. + +If you have cloned the azure-sdk-for-cpp repo, this can be done using the [Azure SDK Live Test Resource Management tools](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/TestResources/README.md). + +```pwsh +Connect-AzAccount -Subscription 'YOUR SUBSCRIPTION ID' +eng\common\testResources\New-TestResources.ps1 -Location Westus -ServiceDirectory core\azure-core-amqp\samples +``` + +This will establish a connection to your Azure account and create a resource group and an EventHubs instance. The connection string and other information will be displayed in the console. + + +## Building and Running the Samples +To build the samples, create a build directory and use CMake to generate the build files. For example: + +```bash +mkdir build +cd build +cmake .. +``` + +Then use CMake to build the samples: + +```bash +cmake --build . +``` + +Each sample is built into its own directory. For example, the `eventhub_sas_reader_sample` is built into the `eventhub_sas_reader_sample` directory. + +### eventhub_sas_reader_sample +Demonstrates reading messages from the Azure Event Hubs service using the AMQP protocol with SAS authentication. + +### eventhub_sas_writer_sample +Demonstrates writing messages to the Azure Event Hubs service using the AMQP protocol with SAS authentication. + +### eventhub_token_reader_sample +Demonstrates reading messages from the Azure Event Hubs service using the AMQP protocol with an Azure bearer token authentication. + +### eventhub_token_writer_sample +Demonstrates writing messages to the Azure Event Hubs service using the AMQP protocol with an Azure bearer token authentication. + +### local_client_async_sample +Demonstrates sending messages to a local AMQP server using the AMQP protocol using queued send operations. + +### local_client_sample +Demonstrates sending messages to a local AMQP server using the AMQP protocol. + +### local_server_sample +Demonstrates receiving messages from a local AMQP server using the AMQP protocol. + +### eventhub_get_eventhub_properties_sample +Demonstrates receiving messages from the Azure Event Hubs service using an AMQP Management API. diff --git a/sdk/core/azure-core-amqp/samples/internal/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/CMakeLists.txt new file mode 100644 index 0000000000..2b342756d7 --- /dev/null +++ b/sdk/core/azure-core-amqp/samples/internal/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright(c) Microsoft Corporation.All rights reserved. +# SPDX - License - Identifier : MIT + +# CMakeList.txt : Top-level CMake project file, do global configuration +# and include sub-projects here. +# +cmake_minimum_required (VERSION 3.13) + +# Include sub-projects. +add_subdirectory ("local_server_sample") +add_subdirectory ("local_client_sample") +add_subdirectory ("local_client_async_sample") +#add_subdirectory ("eventhub_writer_sample") +add_subdirectory ("eventhub_sas_writer_sample") +add_subdirectory ("eventhub_token_reader_sample") +add_subdirectory ("eventhub_token_writer_sample") +#add_subdirectory ("eventhub_async_writer_sample") +#add_subdirectory ("eventhub_reader_sample") +add_subdirectory ("eventhub_sas_reader_sample") +add_subdirectory ("eventhub_get_properties_sample") diff --git a/sdk/core/azure-core-amqp/samples/eventhub_async_writer_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/eventhub_async_writer_sample/CMakeLists.txt similarity index 59% rename from sdk/core/azure-core-amqp/samples/eventhub_async_writer_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/eventhub_async_writer_sample/CMakeLists.txt index 645ad14ace..711792b2d9 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_async_writer_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_async_writer_sample/CMakeLists.txt @@ -10,9 +10,7 @@ project(eventhub_writer_async_sample) add_executable(eventhub_writer_async_sample eventhub_async_writer_sample.cpp ) -add_dependencies(eventhub_writer_async_sample azure-core-amqp) - -target_include_directories(eventhub_writer_async_sample PRIVATE ${azure-core-amqp_SOURCE_DIR}) +add_dependencies(eventhub_writer_async_sample Azure::azure-core-amqp) # Link test executable against the prototype. -target_link_libraries(eventhub_writer_async_sample PRIVATE azure-core-amqp) +target_link_libraries(eventhub_writer_async_sample PRIVATE Azure::azure-core-amqp get-env-helper) diff --git a/sdk/core/azure-core-amqp/samples/eventhub_async_writer_sample/eventhub_async_writer_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/eventhub_async_writer_sample/eventhub_async_writer_sample.cpp similarity index 65% rename from sdk/core/azure-core-amqp/samples/eventhub_async_writer_sample/eventhub_async_writer_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/eventhub_async_writer_sample/eventhub_async_writer_sample.cpp index aef293de86..ea6ee56c63 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_async_writer_sample/eventhub_async_writer_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_async_writer_sample/eventhub_async_writer_sample.cpp @@ -1,8 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT +#undef _CRT_SECURE_NO_WARNINGS +#include + #include #include + #include #include #include @@ -17,19 +21,27 @@ int main() EH_CONNECTION_STRING)}; std::string targetUrl = "amqps://" + credentials->GetHostName() + "/" + credentials->GetEntityPath(); - Azure::Core::Amqp::_internal::ConnectionOptions connectOptions; - connectOptions.ContainerId = "some"; - connectOptions.HostName = credentials->GetHostName(); - connectOptions.SaslCredentials = credentials; - Azure::Core::Amqp::_internal::Connection connection(targetUrl, connectOptions); + std::string targetEntity = credentials->GetEntityPath(); + if (targetEntity.empty()) + { + targetEntity = GetEnvHelper::GetEnv("EVENTHUB_NAME"); + } + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.ContainerId = "some"; + connectionOptions.SaslCredentials = credentials; + + Azure::Core::Amqp::_internal::Connection connection( + credentials->GetHostName(), credentials->GetPort(), credentials, connectionOptions); + + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = std::numeric_limits::max(); + sessionOptions.InitialOutgoingWindowSize = std::numeric_limits::max(); - Azure::Core::Amqp::_internal::Session session(connection, nullptr); - session.SetIncomingWindow(std::numeric_limits::max()); - session.SetOutgoingWindow(std::numeric_limits::max()); + Azure::Core::Amqp::_internal::Session session(connection); Azure::Core::Amqp::_internal::MessageSenderOptions senderOptions; senderOptions.Name = "sender-link"; - senderOptions.SourceAddress = "ingress"; + senderOptions.MessageSource = "ingress"; senderOptions.SettleMode = Azure::Core::Amqp::_internal::SenderSettleMode::Unsettled; senderOptions.MaxMessageSize = std::numeric_limits::max(); @@ -60,9 +72,8 @@ int main() << " milliseconds. " << (static_cast(messageSendCount) / static_cast( - std::chrono::duration_cast(timeDiff).count())) - * 1000 - << " msgs/sec" << std::endl; + std::chrono::duration_cast(timeDiff).count())) + << " msg/sec" << std::endl; sender.Close(); } diff --git a/sdk/core/azure-core-amqp/samples/internal/eventhub_get_properties_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/eventhub_get_properties_sample/CMakeLists.txt new file mode 100644 index 0000000000..b919ddc78d --- /dev/null +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_get_properties_sample/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright(c) Microsoft Corporation.All rights reserved. +# SPDX - License - Identifier : MIT + +cmake_minimum_required(VERSION 3.13) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +project(eventhub_get_eventhub_properties_sample) + +add_executable(eventhub_get_eventhub_properties_sample + eventhub_get_eventhub_properties_sample.cpp +) +add_dependencies(eventhub_get_eventhub_properties_sample Azure::azure-core-amqp) + +target_link_libraries(eventhub_get_eventhub_properties_sample PRIVATE Azure::azure-core-amqp Azure::azure-identity get-env-helper) diff --git a/sdk/core/azure-core-amqp/samples/internal/eventhub_get_properties_sample/eventhub_get_eventhub_properties_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/eventhub_get_properties_sample/eventhub_get_eventhub_properties_sample.cpp new file mode 100644 index 0000000000..dbecd6cd72 --- /dev/null +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_get_properties_sample/eventhub_get_eventhub_properties_sample.cpp @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-Licence-Identifier: MIT + +#undef _CRT_SECURE_NO_WARNINGS +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +constexpr const char* EH_AUTHENTICATION_SCOPE = "https://eventhubs.azure.net/.default"; + +struct EventHubProperties final +{ + std::string Name; + std::vector PartitionIds; + Azure::DateTime CreatedAt; +}; + +EventHubProperties GetEventHubProperties( + Azure::Core::Amqp::_internal::Session const& session, + std::string const& eventHubName) +{ + + // Create a management client off the session. + // Eventhubs management APIs return a status code in the "status-code" application properties. + Azure::Core::Amqp::_internal::ManagementOptions managementClientOptions; + managementClientOptions.EnableTrace = false; + managementClientOptions.ExpectedStatusCodeKeyName = "status-code"; + Azure::Core::Amqp::_internal::Management managementClient( + session, eventHubName, managementClientOptions); + + managementClient.Open(); + + // Send a message to the management endpoint to retrieve the properties of the eventhub. + Azure::Core::Amqp::Models::AmqpMessage message; + message.ApplicationProperties["name"] = Azure::Core::Amqp::Models::AmqpValue{eventHubName}; + message.SetBody(Azure::Core::Amqp::Models::AmqpValue{}); + auto result = managementClient.ExecuteOperation( + "READ" /* operation */, + "com.microsoft:eventhub" /* type of operation */, + "" /* locales */, + message); + + EventHubProperties properties; + if (result.Status == Azure::Core::Amqp::_internal::ManagementOperationStatus::Error) + { + std::cerr << "Error: " << result.Message.ApplicationProperties["status-description"]; + } + else + { + std::cout << "Management endpoint properties message: " << result.Message; + if (result.Message.BodyType != Azure::Core::Amqp::Models::MessageBodyType::Value) + { + throw std::runtime_error("Unexpected body type"); + } + + auto body = result.Message.GetBodyAsAmqpValue(); + if (body.GetType() != Azure::Core::Amqp::Models::AmqpValueType::Map) + { + throw std::runtime_error("Unexpected body type"); + } + auto bodyMap = body.AsMap(); + properties.Name = static_cast(bodyMap["name"]); + properties.CreatedAt = Azure::DateTime(std::chrono::system_clock::from_time_t( + static_cast(bodyMap["created_at"].AsTimestamp()).count())); + auto partitions = bodyMap["partition_ids"].AsArray(); + for (const auto& partition : partitions) + { + properties.PartitionIds.push_back(static_cast(partition)); + } + } + managementClient.Close(); + + return properties; +} + +struct EventHubPartitionProperties final +{ + std::string Name; + std::string PartitionId; + int64_t BeginningSequenceNumber{}; + int64_t LastEnqueuedSequenceNumber{}; + std::string LastEnqueuedOffset; + Azure::DateTime LastEnqueuedTimeUtc; + bool IsEmpty{}; +}; + +EventHubPartitionProperties GetPartitionProperties( + Azure::Core::Amqp::_internal::Session const& session, + std::string const& eventHubName, + std::string const& partitionId) +{ + + // Create a management client off the session. + // Eventhubs management APIs return a status code in the "status-code" application properties. + Azure::Core::Amqp::_internal::ManagementOptions managementClientOptions; + managementClientOptions.EnableTrace = false; + managementClientOptions.ExpectedStatusCodeKeyName = "status-code"; + Azure::Core::Amqp::_internal::Management managementClient( + session, eventHubName, managementClientOptions); + + managementClient.Open(); + + // Send a message to the management endpoint to retrieve the properties of the eventhub. + Azure::Core::Amqp::Models::AmqpMessage message; + message.ApplicationProperties["name"] = Azure::Core::Amqp::Models::AmqpValue{eventHubName}; + message.ApplicationProperties["partition"] = Azure::Core::Amqp::Models::AmqpValue{partitionId}; + message.SetBody(Azure::Core::Amqp::Models::AmqpValue{}); + auto result = managementClient.ExecuteOperation( + "READ" /* operation */, + "com.microsoft:partition" /* type of operation */, + "" /* locales */, + message); + + EventHubPartitionProperties properties; + if (result.Status == Azure::Core::Amqp::_internal::ManagementOperationStatus::Error) + { + std::cerr << "Error: " << result.Message.ApplicationProperties["status-description"]; + } + else + { + std::cout << "Partition properties message: " << result.Message; + if (result.Message.BodyType != Azure::Core::Amqp::Models::MessageBodyType::Value) + { + throw std::runtime_error("Unexpected body type"); + } + + auto body = result.Message.GetBodyAsAmqpValue(); + if (body.GetType() != Azure::Core::Amqp::Models::AmqpValueType::Map) + { + throw std::runtime_error("Unexpected body type"); + } + auto bodyMap = body.AsMap(); + properties.Name = static_cast(bodyMap["name"]); + properties.PartitionId = static_cast(bodyMap["partition"]); + properties.BeginningSequenceNumber = bodyMap["begin_sequence_number"]; + properties.LastEnqueuedSequenceNumber = bodyMap["last_enqueued_sequence_number"]; + properties.LastEnqueuedOffset = static_cast(bodyMap["last_enqueued_offset"]); + properties.LastEnqueuedTimeUtc = Azure::DateTime(std::chrono::system_clock::from_time_t( + std::chrono::duration_cast( + static_cast(bodyMap["last_enqueued_time_utc"].AsTimestamp())) + .count())); + properties.IsEmpty = bodyMap["is_partition_empty"]; + } + managementClient.Close(); + + return properties; +} + +int main() +{ + // Retrieve the eventhub connection string so we can extract the host name and entity name. We + // are NOT using the connection string to authenticate with the eventhub, only to retrieve the + // host name and entity (if present). + std::string eventhubConnectionString = GetEnvHelper::GetEnv("EVENTHUB_CONNECTION_STRING"); + + Azure::Core::Amqp::_internal::ConnectionStringParser connectionParser(eventhubConnectionString); + std::string eventhubsHost = connectionParser.GetHostName(); + std::string eventhubsEntity = connectionParser.GetEntityPath(); + if (eventhubsEntity.empty()) + { + eventhubsEntity = GetEnvHelper::GetEnv("EVENTHUB_NAME"); + } + + // Establish the connection to the eventhub. + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.ContainerId = "some"; + connectionOptions.EnableTrace = false; + connectionOptions.Port = connectionParser.GetPort(); + Azure::Core::Amqp::_internal::Connection connection( + connectionParser.GetHostName(), connectionOptions); + + auto credential{std::make_shared( + GetEnvHelper::GetEnv("SAMPLES_TENANT_ID"), + GetEnvHelper::GetEnv("SAMPLES_CLIENT_ID"), + GetEnvHelper::GetEnv("SAMPLES_CLIENT_SECRET"))}; + + // Establish a session to the eventhub. + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = std::numeric_limits::max(); + sessionOptions.InitialOutgoingWindowSize = std::numeric_limits::max(); + sessionOptions.AuthenticationScopes = {EH_AUTHENTICATION_SCOPE}; + Azure::Core::Amqp::_internal::Session session(connection, credential, sessionOptions); + + auto eventHubProperties = GetEventHubProperties(session, eventhubsEntity); + for (const auto& partition : eventHubProperties.PartitionIds) + { + std::cout << "Partition: " << partition << std::endl; + auto partitionProperties = GetPartitionProperties(session, eventhubsEntity, partition); + std::cout << "Partition properties: " << std::endl; + std::cout << " Name: " << partitionProperties.Name << std::endl; + std::cout << " PartitionId: " << partitionProperties.PartitionId << std::endl; + std::cout << " BeginningSequenceNumber: " << partitionProperties.BeginningSequenceNumber + << std::endl; + std::cout << " LastEnqueuedSequenceNumber: " << partitionProperties.LastEnqueuedSequenceNumber + << std::endl; + std::cout << " LastEnqueuedOffset: " << partitionProperties.LastEnqueuedOffset << std::endl; + std::cout << " LastEnqueuedTimeUtc: " << partitionProperties.LastEnqueuedTimeUtc.ToString() + << std::endl; + std::cout << " IsEmpty: " << std::boolalpha << partitionProperties.IsEmpty << std::endl; + } +} diff --git a/sdk/core/azure-core-amqp/samples/eventhub_reader_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/eventhub_reader_sample/CMakeLists.txt similarity index 60% rename from sdk/core/azure-core-amqp/samples/eventhub_reader_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/eventhub_reader_sample/CMakeLists.txt index 3a356b39e7..f82e9a9493 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_reader_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_reader_sample/CMakeLists.txt @@ -11,9 +11,7 @@ project(eventhub_reader_sample) add_executable(eventhub_reader_sample eventhub_reader_sample.cpp ) -add_dependencies(eventhub_reader_sample azure-core-amqp) - -target_include_directories(eventhub_reader_sample PRIVATE ${azure-core-amqp_SOURCE_DIR}) +add_dependencies(eventhub_reader_sample Azure::azure-core-amqp) # Link test executable against the prototype. -target_link_libraries(eventhub_reader_sample PRIVATE azure-core-amqp) +target_link_libraries(eventhub_reader_sample PRIVATE Azure::azure-core-amqp) diff --git a/sdk/core/azure-core-amqp/samples/eventhub_reader_sample/eventhub_reader_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/eventhub_reader_sample/eventhub_reader_sample.cpp similarity index 69% rename from sdk/core/azure-core-amqp/samples/eventhub_reader_sample/eventhub_reader_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/eventhub_reader_sample/eventhub_reader_sample.cpp index fa642f81b6..cf52fed4d0 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_reader_sample/eventhub_reader_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_reader_sample/eventhub_reader_sample.cpp @@ -3,6 +3,7 @@ #include #include + #include #include #include @@ -12,22 +13,25 @@ int main() { - Azure::Core::Amqp::_internal::ConnectionOptions connectOptions; - connectOptions.ContainerId = "whatever"; - connectOptions.EnableTrace = false; - connectOptions.SaslCredentials + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.ContainerId = "whatever"; + connectionOptions.EnableTrace = false; + connectionOptions.SaslCredentials = std::make_shared( EH_CONNECTION_STRING); - std::string hostUrl = "amqps://" + connectOptions.SaslCredentials->GetHostName() + "/" - + connectOptions.SaslCredentials->GetEntityPath() + "/ConsumerGroups/$Default/Partitions/0"; + std::string hostUrl = "amqps://" + connectionOptions.SaslCredentials->GetHostName() + "/" + + connectionOptions.SaslCredentials->GetEntityPath() + + "/ConsumerGroups/$Default/Partitions/0"; + + Azure::Core::Amqp::_internal::Connection connection(hostUrl, connectionOptions); - Azure::Core::Amqp::_internal::Connection connection(hostUrl, connectOptions); - Azure::Core::Amqp::_internal::Session session(connection, nullptr); - session.SetIncomingWindow(100); + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = 100; + Azure::Core::Amqp::_internal::Session session(connection, sessionOptions); Azure::Core::Amqp::_internal::MessageReceiverOptions receiverOptions; receiverOptions.Name = "receiver-link"; - receiverOptions.TargetAddress = "ingress-rx"; + receiverOptions.MessageTarget = "ingress-rx"; receiverOptions.SettleMode = Azure::Core::Amqp::_internal::ReceiverSettleMode::First; receiverOptions.MaxMessageSize = std::numeric_limits::max(); @@ -56,9 +60,8 @@ int main() << " milliseconds. " << (static_cast(messageReceiveCount) / static_cast( - std::chrono::duration_cast(timeDiff).count())) - * 1000 - << " msgs/sec" << std::endl; + std::chrono::duration_cast(timeDiff).count())) + << " msg/sec" << std::endl; receiver.Close(); } diff --git a/sdk/core/azure-core-amqp/samples/eventhub_sas_reader_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/eventhub_sas_reader_sample/CMakeLists.txt similarity index 55% rename from sdk/core/azure-core-amqp/samples/eventhub_sas_reader_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/eventhub_sas_reader_sample/CMakeLists.txt index e6bf7227fc..eaf963a3ae 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_sas_reader_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_sas_reader_sample/CMakeLists.txt @@ -10,8 +10,6 @@ project(eventhub_sas_reader_sample) add_executable(eventhub_sas_reader_sample eventhub_sas_reader_sample.cpp ) -add_dependencies(eventhub_sas_reader_sample azure-core-amqp) +add_dependencies(eventhub_sas_reader_sample Azure::azure-core-amqp) -target_include_directories(eventhub_sas_reader_sample PRIVATE ${azure-core-amqp_SOURCE_DIR}) - -target_link_libraries(eventhub_sas_reader_sample PRIVATE azure-core-amqp) +target_link_libraries(eventhub_sas_reader_sample PRIVATE Azure::azure-core-amqp get-env-helper) diff --git a/sdk/core/azure-core-amqp/samples/eventhub_sas_reader_sample/eventhub_sas_reader_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/eventhub_sas_reader_sample/eventhub_sas_reader_sample.cpp similarity index 59% rename from sdk/core/azure-core-amqp/samples/eventhub_sas_reader_sample/eventhub_sas_reader_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/eventhub_sas_reader_sample/eventhub_sas_reader_sample.cpp index 0c03d49174..346b2e09b7 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_sas_reader_sample/eventhub_sas_reader_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_sas_reader_sample/eventhub_sas_reader_sample.cpp @@ -1,42 +1,50 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT +#undef _CRT_SECURE_NO_WARNINGS +#include + #include #include #include + #include #include #include #include -#define EH_CONNECTION_STRING "<<>>" - int main() { + std::string eventhubConnectionString = GetEnvHelper::GetEnv("EVENTHUB_CONNECTION_STRING"); + auto credential = std::make_shared( - EH_CONNECTION_STRING); - std::string hostUrl = "amqps://" + credential->GetHostName() + "/" + credential->GetEntityPath() - + "/ConsumerGroups/$Default/Partitions/0"; - Azure::Core::Amqp::_internal::ConnectionOptions connectOptions; - connectOptions.ContainerId = "whatever"; - connectOptions.EnableTrace = true; - connectOptions.HostName = credential->GetHostName(); - Azure::Core::Amqp::_internal::Connection connection(hostUrl, connectOptions); + eventhubConnectionString); + std::string entityPath = credential->GetEntityPath(); + if (entityPath.empty()) + { + entityPath = GetEnvHelper::GetEnv("EVENTHUB_NAME"); + } - Azure::Core::Amqp::_internal::Session session(connection, nullptr); - session.SetIncomingWindow(100); + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.ContainerId = "whatever"; + connectionOptions.EnableTrace = true; + connectionOptions.Port = credential->GetPort(); + Azure::Core::Amqp::_internal::Connection connection(credential->GetHostName(), connectionOptions); + + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = 100; + Azure::Core::Amqp::_internal::Session session(connection, credential, sessionOptions); Azure::Core::Amqp::_internal::MessageReceiverOptions receiverOptions; receiverOptions.Name = "receiver-link"; - receiverOptions.TargetAddress = "ingress-rx"; + receiverOptions.MessageTarget = "ingress-rx"; receiverOptions.SettleMode = Azure::Core::Amqp::_internal::ReceiverSettleMode::First; receiverOptions.MaxMessageSize = std::numeric_limits::max(); receiverOptions.EnableTrace = true; Azure::Core::Amqp::_internal::MessageReceiver receiver( - session, credential, hostUrl, receiverOptions); - + session, entityPath + "/ConsumerGroups/$Default/Partitions/0", receiverOptions); // Open the connection to the remote. receiver.Open(); @@ -60,9 +68,8 @@ int main() << " milliseconds. " << (static_cast(messageReceiveCount) / static_cast( - std::chrono::duration_cast(timeDiff).count())) - * 1000 - << " msgs/sec" << std::endl; + std::chrono::duration_cast(timeDiff).count())) + << " msg/sec" << std::endl; receiver.Close(); } diff --git a/sdk/core/azure-core-amqp/samples/eventhub_sas_writer_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/eventhub_sas_writer_sample/CMakeLists.txt similarity index 55% rename from sdk/core/azure-core-amqp/samples/eventhub_sas_writer_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/eventhub_sas_writer_sample/CMakeLists.txt index 6f6e39ef5b..8cc626e3bf 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_sas_writer_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_sas_writer_sample/CMakeLists.txt @@ -10,8 +10,6 @@ project(eventhub_sas_writer_sample) add_executable(eventhub_sas_writer_sample eventhub_sas_writer_sample.cpp ) -add_dependencies(eventhub_sas_writer_sample azure-core-amqp) +add_dependencies(eventhub_sas_writer_sample Azure::azure-core-amqp) -target_include_directories(eventhub_sas_writer_sample PRIVATE ${azure-core-amqp_SOURCE_DIR}) - -target_link_libraries(eventhub_sas_writer_sample PRIVATE azure-core-amqp) +target_link_libraries(eventhub_sas_writer_sample PRIVATE Azure::azure-core-amqp get-env-helper) diff --git a/sdk/core/azure-core-amqp/samples/eventhub_sas_writer_sample/eventhub_sas_writer_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/eventhub_sas_writer_sample/eventhub_sas_writer_sample.cpp similarity index 59% rename from sdk/core/azure-core-amqp/samples/eventhub_sas_writer_sample/eventhub_sas_writer_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/eventhub_sas_writer_sample/eventhub_sas_writer_sample.cpp index d89c28a66f..41ed5d545b 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_sas_writer_sample/eventhub_sas_writer_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_sas_writer_sample/eventhub_sas_writer_sample.cpp @@ -1,33 +1,41 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT +#undef _CRT_SECURE_NO_WARNINGS +#include + #include #include #include + #include #include #include #include -// Note: The connection string provided must either have an "EntityPath" entry or the constructor -// for the SasConnectionStringCredential has to have an entity path provided. -#define EH_CONNECTION_STRING "<<>>" - int main() { + std::string eventhubConnectionString = GetEnvHelper::GetEnv("EVENTHUB_CONNECTION_STRING"); + auto credential{ std::make_shared( - EH_CONNECTION_STRING)}; - std::string eventUrl = "amqps://" + credential->GetHostName() + "/" + credential->GetEntityPath(); - Azure::Core::Amqp::_internal::ConnectionOptions connectOptions; - connectOptions.ContainerId = "some"; - connectOptions.EnableTrace = true; - connectOptions.HostName = credential->GetHostName(); - Azure::Core::Amqp::_internal::Connection connection(eventUrl, connectOptions); + eventhubConnectionString)}; + std::string entityPath = credential->GetEntityPath(); + if (entityPath.empty()) + { + entityPath = GetEnvHelper::GetEnv("EVENTHUB_NAME"); + } + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.ContainerId = "some"; + connectionOptions.EnableTrace = true; + connectionOptions.Port = credential->GetPort(); + Azure::Core::Amqp::_internal::Connection connection(credential->GetHostName(), connectionOptions); - Azure::Core::Amqp::_internal::Session session(connection, nullptr); - session.SetIncomingWindow(std::numeric_limits::max()); - session.SetOutgoingWindow(std::numeric_limits::max()); + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = std::numeric_limits::max(); + sessionOptions.InitialOutgoingWindowSize = std::numeric_limits::max(); + + Azure::Core::Amqp::_internal::Session session(connection, credential, sessionOptions); constexpr int maxMessageSendCount = 1000; Azure::Core::Amqp::Models::AmqpMessage message; @@ -36,12 +44,10 @@ int main() Azure::Core::Amqp::_internal::MessageSenderOptions senderOptions; senderOptions.EnableTrace = true; senderOptions.Name = "sender-link"; - senderOptions.SourceAddress = "ingress"; + senderOptions.MessageSource = "ingress"; senderOptions.SettleMode = Azure::Core::Amqp::_internal::SenderSettleMode::Settled; senderOptions.MaxMessageSize = std::numeric_limits::max(); - - Azure::Core::Amqp::_internal::MessageSender sender( - session, credential, eventUrl, senderOptions, nullptr); + Azure::Core::Amqp::_internal::MessageSender sender(session, entityPath, senderOptions, nullptr); // Open the connection to the remote. sender.Open(); @@ -67,9 +73,8 @@ int main() << " messages/millisecond. " << (static_cast(messageSendCount) / static_cast( - std::chrono::duration_cast(timeDiff).count())) - * 1000.0 - << " msgs/sec" << std::endl; + std::chrono::duration_cast(timeDiff).count())) + << " msg/sec" << std::endl; sender.Close(); } diff --git a/sdk/core/azure-core-amqp/samples/internal/eventhub_token_reader_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/eventhub_token_reader_sample/CMakeLists.txt new file mode 100644 index 0000000000..9f90830209 --- /dev/null +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_token_reader_sample/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright(c) Microsoft Corporation.All rights reserved. +# SPDX - License - Identifier : MIT + +cmake_minimum_required(VERSION 3.13) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +project(eventhub_token_reader_sample) + +add_executable(eventhub_token_reader_sample + eventhub_token_reader_sample.cpp +) +add_dependencies(eventhub_token_reader_sample azure-core-amqp) + +target_link_libraries(eventhub_token_reader_sample PRIVATE azure-core-amqp Azure::azure-identity get-env-helper) diff --git a/sdk/core/azure-core-amqp/samples/internal/eventhub_token_reader_sample/eventhub_token_reader_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/eventhub_token_reader_sample/eventhub_token_reader_sample.cpp new file mode 100644 index 0000000000..d4f6fb7449 --- /dev/null +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_token_reader_sample/eventhub_token_reader_sample.cpp @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-Licence-Identifier: MIT + +#undef _CRT_SECURE_NO_WARNINGS +#include + +#include +#include +#include + +#include +#include +#include +#include + +int main() +{ + std::string eventhubConnectionString = GetEnvHelper::GetEnv("EVENTHUB_CONNECTION_STRING"); + + auto credential + = std::make_shared( + eventhubConnectionString); + std::string entityPath = credential->GetEntityPath(); + if (entityPath.empty()) + { + entityPath = GetEnvHelper::GetEnv("EVENTHUB_NAME"); + } + + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.ContainerId = "whatever"; + connectionOptions.EnableTrace = true; + connectionOptions.Port = credential->GetPort(); + Azure::Core::Amqp::_internal::Connection connection(credential->GetHostName(), connectionOptions); + + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = 100; + Azure::Core::Amqp::_internal::Session session(connection, credential, sessionOptions); + + Azure::Core::Amqp::_internal::MessageReceiverOptions receiverOptions; + receiverOptions.Name = "receiver-link"; + receiverOptions.MessageTarget = "ingress-rx"; + receiverOptions.SettleMode = Azure::Core::Amqp::_internal::ReceiverSettleMode::First; + receiverOptions.MaxMessageSize = std::numeric_limits::max(); + receiverOptions.EnableTrace = true; + + Azure::Core::Amqp::_internal::MessageReceiver receiver( + session, entityPath + "/ConsumerGroups/$Default/Partitions/0", receiverOptions); + // Open the connection to the remote. + receiver.Open(); + + auto timeStart = std::chrono::high_resolution_clock::now(); + + constexpr int maxMessageReceiveCount = 1000; + + int messageReceiveCount = 0; + while (messageReceiveCount < maxMessageReceiveCount) + { + auto message = receiver.WaitForIncomingMessage(); + std::cout << "Received message: " << message << std::endl; + messageReceiveCount += 1; + } + + auto timeEnd = std::chrono::high_resolution_clock::now(); + std::chrono::nanoseconds timeDiff = timeEnd - timeStart; + + std::cout << "Received " << messageReceiveCount << " in " + << std::chrono::duration_cast(timeDiff).count() + << " milliseconds (" + << (static_cast(messageReceiveCount) + / static_cast( + std::chrono::duration_cast(timeDiff).count())) + << " msg/sec)." << std::endl; + + receiver.Close(); +} diff --git a/sdk/core/azure-core-amqp/samples/eventhub_token_writer_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/eventhub_token_writer_sample/CMakeLists.txt similarity index 51% rename from sdk/core/azure-core-amqp/samples/eventhub_token_writer_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/eventhub_token_writer_sample/CMakeLists.txt index 13e0dae88f..d7ca69776f 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_token_writer_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_token_writer_sample/CMakeLists.txt @@ -10,8 +10,6 @@ project(eventhub_sas_writer_sample) add_executable(eventhub_token_writer_sample eventhub_token_writer_sample.cpp ) -add_dependencies(eventhub_token_writer_sample azure-core-amqp) +add_dependencies(eventhub_token_writer_sample Azure::azure-core-amqp) -target_include_directories(eventhub_token_writer_sample PRIVATE ${azure-core-amqp_SOURCE_DIR} Azure::azure-identity) - -target_link_libraries(eventhub_token_writer_sample PRIVATE azure-core-amqp Azure::azure-identity) +target_link_libraries(eventhub_token_writer_sample PRIVATE Azure::azure-core-amqp Azure::azure-identity get-env-helper) diff --git a/sdk/core/azure-core-amqp/samples/eventhub_token_writer_sample/eventhub_token_writer_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/eventhub_token_writer_sample/eventhub_token_writer_sample.cpp similarity index 50% rename from sdk/core/azure-core-amqp/samples/eventhub_token_writer_sample/eventhub_token_writer_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/eventhub_token_writer_sample/eventhub_token_writer_sample.cpp index 6a588eb409..2cb50a67ce 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_token_writer_sample/eventhub_token_writer_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_token_writer_sample/eventhub_token_writer_sample.cpp @@ -1,56 +1,70 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT +#undef _CRT_SECURE_NO_WARNINGS +#include + #include #include #include #include -#include #include + #include #include #include #include -#define EH_HOST "<<>>" -#define EH_ENTITY "<<>>" - -#define EH_AUTHENTICATION_SCOPE "https://eventhubs.azure.net/.default" - -#define EH_ENTITY_URL "amqps://" EH_HOST "/" EH_ENTITY +constexpr const char* EH_AUTHENTICATION_SCOPE = "https://eventhubs.azure.net/.default"; int main() { + // Retrieve the eventhub connection string so we can extract the host name and entity name. We are + // NOT using the connection string to connect to the eventhub. + std::string eventhubConnectionString = GetEnvHelper::GetEnv("EVENTHUB_CONNECTION_STRING"); + Azure::Core::Amqp::_internal::ConnectionStringParser connectionStringCredential( + eventhubConnectionString); + std::string eventhubsHost = connectionStringCredential.GetHostName(); + std::string eventhubsEntity = connectionStringCredential.GetEntityPath(); + + // If the connection string does not specify an entity path, then look for the eventhub name in an + // environment variable. + if (eventhubsEntity.empty()) + { + eventhubsEntity = GetEnvHelper::GetEnv("EVENTHUB_NAME"); + } - Azure::Core::Amqp::_internal::ConnectionOptions connectOptions; - connectOptions.ContainerId = "some"; - connectOptions.EnableTrace = true; - connectOptions.HostName = EH_HOST; - Azure::Core::Amqp::_internal::Connection connection(EH_ENTITY_URL, connectOptions); + // Establish credentials for the eventhub client. + auto credential{std::make_shared( + GetEnvHelper::GetEnv("SAMPLES_TENANT_ID"), + GetEnvHelper::GetEnv("SAMPLES_CLIENT_ID"), + GetEnvHelper::GetEnv("SAMPLES_CLIENT_SECRET"))}; + + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.ContainerId = "some"; + connectionOptions.EnableTrace = true; + Azure::Core::Amqp::_internal::Connection connection(eventhubsHost, connectionOptions); + + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = std::numeric_limits::max(); + sessionOptions.InitialOutgoingWindowSize = std::numeric_limits::max(); + sessionOptions.AuthenticationScopes = {EH_AUTHENTICATION_SCOPE}; - Azure::Core::Amqp::_internal::Session session(connection, nullptr); - session.SetIncomingWindow(std::numeric_limits::max()); - session.SetOutgoingWindow(std::numeric_limits::max()); + Azure::Core::Amqp::_internal::Session session(connection, credential, sessionOptions); constexpr int maxMessageSendCount = 1000; Azure::Core::Amqp::Models::AmqpMessage message; message.SetBody(Azure::Core::Amqp::Models::AmqpValue{"Hello"}); - auto credential{std::make_shared( - Azure::Core::_internal::Environment::GetVariable("EVENTHUB_TENANT_ID"), - Azure::Core::_internal::Environment::GetVariable("EVENTHUB_CLIENT_ID"), - Azure::Core::_internal::Environment::GetVariable("EVENTHUB_CLIENT_SECRET"))}; - Azure::Core::Amqp::_internal::MessageSenderOptions senderOptions; - senderOptions.AuthenticationScopes = {EH_AUTHENTICATION_SCOPE}; senderOptions.MaxMessageSize = std::numeric_limits::max(); - senderOptions.SourceAddress = "ingress"; + senderOptions.MessageSource = "ingress"; senderOptions.Name = "sender-link"; senderOptions.SettleMode = Azure::Core::Amqp::_internal::SenderSettleMode::Settled; senderOptions.EnableTrace = true; Azure::Core::Amqp::_internal::MessageSender sender( - session, credential, EH_ENTITY_URL, senderOptions, nullptr); + session, eventhubsEntity, senderOptions, nullptr); // Open the connection to the remote. This will authenticate the client and connect to the server. sender.Open(); @@ -76,9 +90,8 @@ int main() << " messages/millisecond. " << (static_cast(messageSendCount) / static_cast( - std::chrono::duration_cast(timeDiff).count())) - * 1000.0 - << " msgs/sec" << std::endl; + std::chrono::duration_cast(timeDiff).count())) + << " msg/sec" << std::endl; sender.Close(); } diff --git a/sdk/core/azure-core-amqp/samples/eventhub_writer_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/eventhub_writer_sample/CMakeLists.txt similarity index 56% rename from sdk/core/azure-core-amqp/samples/eventhub_writer_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/eventhub_writer_sample/CMakeLists.txt index d3abae6036..8a96783800 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_writer_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_writer_sample/CMakeLists.txt @@ -10,8 +10,6 @@ project(eventhub_writer_sample) add_executable(eventhub_writer_sample eventhub_writer_sample.cpp ) -add_dependencies(eventhub_writer_sample azure-core-amqp) +add_dependencies(eventhub_writer_sample Azure::azure-core-amqp) -target_include_directories(eventhub_writer_sample PRIVATE ${azure-core-amqp_SOURCE_DIR}) - -target_link_libraries(eventhub_writer_sample PRIVATE azure-core-amqp) +target_link_libraries(eventhub_writer_sample PRIVATE Azure::azure-core-amqp) diff --git a/sdk/core/azure-core-amqp/samples/eventhub_writer_sample/eventhub_writer_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/eventhub_writer_sample/eventhub_writer_sample.cpp similarity index 69% rename from sdk/core/azure-core-amqp/samples/eventhub_writer_sample/eventhub_writer_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/eventhub_writer_sample/eventhub_writer_sample.cpp index 309fbf47ed..830fed2f59 100644 --- a/sdk/core/azure-core-amqp/samples/eventhub_writer_sample/eventhub_writer_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/eventhub_writer_sample/eventhub_writer_sample.cpp @@ -4,6 +4,7 @@ #include #include #include + #include #include #include @@ -16,16 +17,20 @@ int main() auto credentials = std::make_shared( EH_CONNECTION_STRING); - Azure::Core::Amqp::_internal::ConnectionOptions connectOptions; - connectOptions.ContainerId = "some"; - connectOptions.EnableTrace = true; + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.ContainerId = "some"; + connectionOptions.EnableTrace = true; std::string hostUrl = "amqps://" + credentials->GetHostName() + "/" + credentials->GetEntityPath(); - Azure::Core::Amqp::_internal::Connection connection(hostUrl, connectOptions); + connectionOptions.Port = credentials->GetPort(); + Azure::Core::Amqp::_internal::Connection connection( + credentials->GetHostName(), connectionOptions); + + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = std::numeric_limits::max(); + sessionOptions.InitialOutgoingWindowSize = std::numeric_limits::max(); - Azure::Core::Amqp::_internal::Session session(connection, nullptr); - session.SetIncomingWindow(std::numeric_limits::max()); - session.SetOutgoingWindow(std::numeric_limits::max()); + Azure::Core::Amqp::_internal::Session session(connection, credentials, sessionOptions); auto timeStart = std::chrono::high_resolution_clock::now(); @@ -36,11 +41,10 @@ int main() Azure::Core::Amqp::_internal::MessageSenderOptions senderOptions; senderOptions.Name = "sender-link"; - senderOptions.SourceAddress = "ingress"; + senderOptions.MessageSource = "ingress"; senderOptions.SettleMode = Azure::Core::Amqp::_internal::SenderSettleMode::Unsettled; senderOptions.MaxMessageSize = std::numeric_limits::max(); - Azure::Core::Amqp::_internal::MessageSender sender( - session, credentials, hostUrl, senderOptions, nullptr); + Azure::Core::Amqp::_internal::MessageSender sender(session, hostUrl, senderOptions, nullptr); // Open the connection to the remote. sender.Open(); @@ -64,9 +68,8 @@ int main() << " messages/millisecond. " << (static_cast(messageSendCount) / static_cast( - std::chrono::duration_cast(timeDiff).count())) - * 1000 - << " msgs/sec" << std::endl; + std::chrono::duration_cast(timeDiff).count())) + << " msg/sec" << std::endl; sender.Close(); } diff --git a/sdk/core/azure-core-amqp/samples/local_client_async_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/local_client_async_sample/CMakeLists.txt similarity index 55% rename from sdk/core/azure-core-amqp/samples/local_client_async_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/local_client_async_sample/CMakeLists.txt index c9af180e52..4c70c0fcc1 100644 --- a/sdk/core/azure-core-amqp/samples/local_client_async_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/local_client_async_sample/CMakeLists.txt @@ -10,8 +10,6 @@ project(local_client_async_sample) add_executable(local_client_async_sample local_client_async_sample.cpp ) -add_dependencies(local_client_async_sample azure-core-amqp) +add_dependencies(local_client_async_sample Azure::azure-core-amqp) -target_include_directories(local_client_async_sample PRIVATE ${azure-core-amqp_SOURCE_DIR}) - -target_link_libraries(local_client_async_sample PRIVATE azure-core-amqp) +target_link_libraries(local_client_async_sample PRIVATE Azure::azure-core-amqp) diff --git a/sdk/core/azure-core-amqp/samples/local_client_async_sample/local_client_async_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/local_client_async_sample/local_client_async_sample.cpp similarity index 73% rename from sdk/core/azure-core-amqp/samples/local_client_async_sample/local_client_async_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/local_client_async_sample/local_client_async_sample.cpp index 69d4149da3..374fc60613 100644 --- a/sdk/core/azure-core-amqp/samples/local_client_async_sample/local_client_async_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/local_client_async_sample/local_client_async_sample.cpp @@ -4,6 +4,7 @@ #include #include #include + #include #include #include @@ -11,18 +12,20 @@ int main() { - Azure::Core::Amqp::_internal ::ConnectionOptions connectOptions; - connectOptions.EnableTrace = true; - connectOptions.ContainerId = "some"; - Azure::Core::Amqp::_internal::Connection connection("amqp://localhost:5672", connectOptions); + Azure::Core::Amqp::_internal ::ConnectionOptions connectionOptions; + connectionOptions.EnableTrace = true; + connectionOptions.ContainerId = "some"; + Azure::Core::Amqp::_internal::Connection connection("localhost", connectionOptions); + + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = std::numeric_limits::max(); + sessionOptions.InitialOutgoingWindowSize = std::numeric_limits::max(); - Azure::Core::Amqp::_internal::Session session(connection, nullptr); - session.SetIncomingWindow(std::numeric_limits::max()); - session.SetOutgoingWindow(std::numeric_limits::max()); + Azure::Core::Amqp::_internal::Session session(connection, nullptr, sessionOptions); Azure::Core::Amqp::_internal::MessageSenderOptions senderOptions; senderOptions.Name = "sender-link"; - senderOptions.SourceAddress = "ingress"; + senderOptions.MessageSource = "ingress"; senderOptions.MaxMessageSize = std::numeric_limits::max(); Azure::Core::Amqp::_internal::MessageSender sender( session, "localhost/ingress", senderOptions, nullptr); diff --git a/sdk/core/azure-core-amqp/samples/local_client_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/local_client_sample/CMakeLists.txt similarity index 56% rename from sdk/core/azure-core-amqp/samples/local_client_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/local_client_sample/CMakeLists.txt index c446bb3023..b4ba111bb7 100644 --- a/sdk/core/azure-core-amqp/samples/local_client_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/local_client_sample/CMakeLists.txt @@ -10,8 +10,6 @@ project(local_client_sample) add_executable(local_client_sample local_client_sample.cpp ) -add_dependencies(local_client_sample azure-core-amqp) +add_dependencies(local_client_sample Azure::azure-core-amqp) -target_include_directories(local_client_sample PRIVATE ${azure-core-amqp_SOURCE_DIR}) - -target_link_libraries(local_client_sample PRIVATE azure-core-amqp) +target_link_libraries(local_client_sample PRIVATE Azure::azure-core-amqp) diff --git a/sdk/core/azure-core-amqp/samples/local_client_sample/local_client_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/local_client_sample/local_client_sample.cpp similarity index 73% rename from sdk/core/azure-core-amqp/samples/local_client_sample/local_client_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/local_client_sample/local_client_sample.cpp index 85ebc659d4..a48ec9fbe3 100644 --- a/sdk/core/azure-core-amqp/samples/local_client_sample/local_client_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/local_client_sample/local_client_sample.cpp @@ -3,6 +3,7 @@ #include #include + #include #include #include @@ -10,18 +11,20 @@ int main() { - Azure::Core::Amqp::_internal::ConnectionOptions connectOptions; - connectOptions.EnableTrace = false; - connectOptions.ContainerId = "some"; - Azure::Core::Amqp::_internal::Connection connection("amqp://localhost:5672", connectOptions); + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.EnableTrace = false; + connectionOptions.ContainerId = "some"; + Azure::Core::Amqp::_internal::Connection connection("localhost", connectionOptions); + + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = std::numeric_limits::max(); + sessionOptions.InitialOutgoingWindowSize = std::numeric_limits::max(); - Azure::Core::Amqp::_internal::Session session(connection, nullptr); - session.SetIncomingWindow(std::numeric_limits::max()); - session.SetOutgoingWindow(std::numeric_limits::max()); + Azure::Core::Amqp::_internal::Session session(connection, nullptr, sessionOptions); Azure::Core::Amqp::_internal::MessageSenderOptions senderOptions; senderOptions.Name = "sender-link"; - senderOptions.SourceAddress = "ingress"; + senderOptions.MessageSource = "ingress"; senderOptions.MaxMessageSize = std::numeric_limits::max(); Azure::Core::Amqp::_internal::MessageSender sender( session, "localhost/ingress", senderOptions, nullptr); diff --git a/sdk/core/azure-core-amqp/samples/local_server_sample/CMakeLists.txt b/sdk/core/azure-core-amqp/samples/internal/local_server_sample/CMakeLists.txt similarity index 56% rename from sdk/core/azure-core-amqp/samples/local_server_sample/CMakeLists.txt rename to sdk/core/azure-core-amqp/samples/internal/local_server_sample/CMakeLists.txt index 2aba967df2..861775fb5a 100644 --- a/sdk/core/azure-core-amqp/samples/local_server_sample/CMakeLists.txt +++ b/sdk/core/azure-core-amqp/samples/internal/local_server_sample/CMakeLists.txt @@ -10,8 +10,6 @@ project(local_server_sample) add_executable(local_server_sample local_server_sample.cpp ) -add_dependencies(local_server_sample azure-core-amqp) +add_dependencies(local_server_sample Azure::azure-core-amqp) -target_include_directories(local_server_sample PRIVATE ${azure-core-amqp_SOURCE_DIR}) - -target_link_libraries(local_server_sample PRIVATE azure-core-amqp) +target_link_libraries(local_server_sample PRIVATE Azure::azure-core-amqp) diff --git a/sdk/core/azure-core-amqp/samples/local_server_sample/local_server_sample.cpp b/sdk/core/azure-core-amqp/samples/internal/local_server_sample/local_server_sample.cpp similarity index 90% rename from sdk/core/azure-core-amqp/samples/local_server_sample/local_server_sample.cpp rename to sdk/core/azure-core-amqp/samples/internal/local_server_sample/local_server_sample.cpp index 45f209a3f9..32e90dc2da 100644 --- a/sdk/core/azure-core-amqp/samples/local_server_sample/local_server_sample.cpp +++ b/sdk/core/azure-core-amqp/samples/internal/local_server_sample/local_server_sample.cpp @@ -9,6 +9,7 @@ #include #include #include + #include #include @@ -85,19 +86,19 @@ class SampleEvents : public ConnectionEvents, std::unique_ptr WaitForIncomingConnection( Network::_internal::SocketListener& listener, - Azure::Core::Context context = {}) + Azure::Core::Context const& context = {}) { auto result = m_connectionQueue.WaitForPolledResult(context, listener); return std::move(std::get<0>(*result)); } - std::unique_ptr WaitForNewSession(Azure::Core::Context context = {}) + std::unique_ptr WaitForNewSession(Azure::Core::Context const& context = {}) { auto result = m_sessionQueue.WaitForPolledResult(context, *m_connection); return std::move(std::get<0>(*result)); } - std::unique_ptr WaitForMessageReceiver(Azure::Core::Context context = {}) + std::unique_ptr WaitForMessageReceiver(Azure::Core::Context const& context = {}) { auto result = m_messageReceiverQueue.WaitForPolledResult(context, *m_connection); return std::move(std::get<0>(*result)); @@ -107,7 +108,7 @@ class SampleEvents : public ConnectionEvents, // needs to wait on multiple waiters (both the connection and the transport). template Azure::Core::Amqp::Models::AmqpMessage WaitForIncomingMessage( - Azure::Core::Context context, + Azure::Core::Context const& context, Waiters&... waiters) { auto result = m_messageQueue.WaitForPolledResult(context, waiters...); @@ -127,11 +128,11 @@ class SampleEvents : public ConnectionEvents, // Create an AMQP filter transport - this will filter out all incoming messages that don't have // an AMQP header. - std::shared_ptr amqpTransport{ - std::make_shared(transport, nullptr)}; + auto amqpTransport{ + Network::_internal::AmqpHeaderDetectTransportFactory::Create(transport, nullptr)}; ConnectionOptions options; options.ContainerId = "some"; - options.HostName = "localhost"; + options.EnableTrace = true; auto newConnection{std::make_unique(amqpTransport, options, this)}; m_connection = newConnection.get(); m_connectionQueue.CompleteOperation(std::move(newConnection)); @@ -139,10 +140,13 @@ class SampleEvents : public ConnectionEvents, virtual bool OnNewEndpoint(Connection const& connection, Endpoint& endpoint) override { - std::unique_ptr newSession = std::make_unique(connection, endpoint, this); + SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = 10000; + + std::unique_ptr newSession + = std::make_unique(connection, endpoint, sessionOptions, this); // The new session *must* call `Begin` before returning from the OnNewEndpoint callback. - newSession->SetIncomingWindow(10000); newSession->Begin(); m_sessionQueue.CompleteOperation(std::move(newSession)); return true; @@ -163,9 +167,9 @@ class SampleEvents : public ConnectionEvents, LinkEndpoint& newLink, std::string const& name, Azure::Core::Amqp::_internal::SessionRole, - Azure::Core::Amqp::Models::AmqpValue source, - Azure::Core::Amqp::Models::AmqpValue target, - Azure::Core::Amqp::Models::AmqpValue) override + Azure::Core::Amqp::Models::AmqpValue const& source, + Azure::Core::Amqp::Models::AmqpValue const& target, + Azure::Core::Amqp::Models::AmqpValue const&) override { Azure::Core::Amqp::Models::_internal::MessageSource messageSource(source); Azure::Core::Amqp::Models::_internal::MessageTarget messageTarget(target); @@ -174,20 +178,19 @@ class SampleEvents : public ConnectionEvents, options.SettleMode = ReceiverSettleMode::First; options.EnableTrace = true; options.Name = name; - options.TargetAddress = static_cast(messageTarget.GetAddress()); + options.MessageTarget = messageTarget; auto newMessageReceiver = std::make_unique( sessionForLink, newLink, static_cast(messageSource.GetAddress()), options, this); - newMessageReceiver->SetTrace(true); newMessageReceiver->Open(); m_messageReceiverQueue.CompleteOperation(std::move(newMessageReceiver)); return true; } - virtual void OnIoError(Connection const&) override + virtual void OnIOError(Connection const&) override { std::cerr << "I/O error has occurred, connection is invalid." << std::endl; }; @@ -219,7 +222,6 @@ int main() listener.Start(); auto connection = sampleEvents.WaitForIncomingConnection(listener); - connection->SetTrace(true); connection->Listen(); auto session = sampleEvents.WaitForNewSession(); diff --git a/sdk/core/azure-core-amqp/samples/test-resources.json b/sdk/core/azure-core-amqp/samples/test-resources.json new file mode 100644 index 0000000000..2487e96ded --- /dev/null +++ b/sdk/core/azure-core-amqp/samples/test-resources.json @@ -0,0 +1,217 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "baseName": { + "type": "string", + "defaultValue": "[resourceGroup().name]", + "metadata": { + "description": "The base resource name." + } + }, + "subscriptionId": { + "type": "string", + "defaultValue": "[subscription().subscriptionId]", + "metadata": { + "description": "The subscription ID to which the application and resources belong." + } + }, + "tenantId": { + "type": "string", + "defaultValue": "[subscription().tenantId]", + "metadata": { + "description": "The tenant ID to which the application and resources belong." + } + }, + "testApplicationOid": { + "type": "string", + "metadata": { + "description": "The client OID to grant access to test resources." + } + }, + "testApplicationId": { + "type": "string", + "metadata": { + "description": "The application client ID used to run tests." + } + }, + "testApplicationSecret": { + "type": "string", + "metadata": { + "description": "The application client secret used to run tests." + } + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "The location of the resources. By default, this is the same as the resource group." + } + }, + "storageEndpointSuffix": { + "type": "string", + "defaultValue": "core.windows.net", + "metadata": { + "description": "The url suffix to use when creating storage connection strings." + } + }, + "perTestExecutionLimitMinutes": { + "type": "string", + "defaultValue": "15", + "metadata": { + "description": "The maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk for being hung." + } + } + }, + "variables": { + "contributorRoleId": "b24988ac-6180-42a0-ab88-20f7382dd24c", + "eventHubsDataOwnerRoleId": "f526a384-b230-433a-b45c-95f59c4a2dec", + "storageDataOwnerRoleId": "b7e6dc6d-f1e8-4753-8033-0f276bb0955b", + "eventHubsNamespace": "[concat('eh-', parameters('baseName'))]", + "eventHubName": "eventhub", + "eventHubNameFull": "[concat(variables('eventHubsNamespace'), '/eventhub')]", + "storageAccount": "[concat('blb', parameters('baseName'))]", + "defaultSASKeyName": "RootManageSharedAccessKey", + "eventHubsAuthRuleResourceId": "[resourceId('Microsoft.EventHub/namespaces/authorizationRules', variables('eventHubsNamespace'), variables('defaultSASKeyName'))]", + "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount'))]" + }, + "resources": [ + { + "type": "Microsoft.EventHub/Namespaces", + "apiVersion": "2015-08-01", + "name": "[variables('eventHubsNamespace')]", + "location": "[parameters('location')]", + "sku": { + "name": "Standard", + "tier": "Standard" + } + }, + { + "type": "Microsoft.EventHub/namespaces/eventhubs", + "apiVersion": "2015-08-01", + "name": "[variables('eventHubNameFull')]", + "location": "[parameters('location')]", + "dependsOn": [ "[resourceId('Microsoft.EventHub/namespaces', variables('eventHubsNamespace'))]" ], + "properties": { + "messageRetentionInDays": 1, + "partitionCount": 4 + } + }, + { + "type": "Microsoft.Storage/storageAccounts", + "apiVersion": "2019-04-01", + "name": "[variables('storageAccount')]", + "location": "[parameters('location')]", + "sku": { + "name": "Standard_LRS", + "tier": "Standard" + }, + "kind": "BlobStorage", + "properties": { + "networkAcls": { + "bypass": "AzureServices", + "virtualNetworkRules": [], + "ipRules": [], + "defaultAction": "Allow" + }, + "supportsHttpsTrafficOnly": true, + "encryption": { + "services": { + "file": { + "enabled": true + }, + "blob": { + "enabled": true + } + }, + "keySource": "Microsoft.Storage" + }, + "accessTier": "Hot" + } + }, + { + "type": "Microsoft.Storage/storageAccounts/blobServices", + "apiVersion": "2019-04-01", + "name": "[concat(variables('storageAccount'), '/default')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount'))]" + ], + "properties": { + "cors": { + "corsRules": [] + }, + "deleteRetentionPolicy": { + "enabled": false + } + } + }, + { + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "2019-04-01-preview", + "name": "[guid(resourceGroup().id, parameters('testApplicationOid'), variables('eventHubsDataOwnerRoleId'))]", + "dependsOn": [ + "[resourceId('Microsoft.EventHub/Namespaces', variables('eventHubsNamespace'))]", + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount'))]" + ], + "properties": { + "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('eventHubsDataOwnerRoleId'))]", + "principalId": "[parameters('testApplicationOid')]", + "scope": "[resourceGroup().id]" + } + }, + { + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "2019-04-01-preview", + "name": "[guid(resourceGroup().id, parameters('testApplicationOid'), variables('contributorRoleId'))]", + "dependsOn": [ + "[resourceId('Microsoft.EventHub/Namespaces', variables('eventHubsNamespace'))]", + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount'))]" + ], + "properties": { + "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('contributorRoleId'))]", + "principalId": "[parameters('testApplicationOid')]", + "scope": "[resourceGroup().id]" + } + }, + { + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "2019-04-01-preview", + "name": "[guid(resourceGroup().id, parameters('testApplicationOid'), variables('storageDataOwnerRoleId'))]", + "dependsOn": [ + "[resourceId('Microsoft.EventHub/Namespaces', variables('eventHubsNamespace'))]", + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount'))]" + ], + "properties": { + "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('storageDataOwnerRoleId'))]", + "principalId": "[parameters('testApplicationOid')]", + "scope": "[resourceGroup().id]" + } + } + ], + "outputs": { + "EVENTHUB_NAME": { + "type": "string", + "value": "[variables('eventHubName')]" + }, + "EVENTHUB_CONNECTION_STRING": { + "type": "string", + "value": "[listkeys(variables('eventHubsAuthRuleResourceId'), '2015-08-01').primaryConnectionString]" + }, + "EVENTHUB_STORAGE_ENDPOINT_SUFFIX": { + "type": "string", + "value": "[parameters('storageEndpointSuffix')]" + }, + "EVENTHUB_PER_TEST_LIMIT_MINUTES": { + "type": "string", + "value": "[parameters('perTestExecutionLimitMinutes')]" + }, + "EVENTHUB_NAMESPACE_CONNECTION_STRING": { + "type": "string", + "value": "[listkeys(variables('eventHubsAuthRuleResourceId'), '2015-08-01').primaryConnectionString]" + }, + "EVENTHUB_PROCESSOR_STORAGE_CONNECTION_STRING": { + "type": "string", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccount'), ';AccountKey=', listKeys(variables('storageAccountId'), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value, ';EndpointSuffix=', parameters('storageEndpointSuffix'))]" + } + } +} diff --git a/sdk/core/azure-core-amqp/src/amqp/cancellable.cpp b/sdk/core/azure-core-amqp/src/amqp/cancellable.cpp index 1becb809b5..b7a7861b65 100644 --- a/sdk/core/azure-core-amqp/src/amqp/cancellable.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/cancellable.cpp @@ -2,9 +2,10 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/cancellable.hpp" -#include #include + +#include #if 0 namespace Azure { namespace Core { namespace Amqp { namespace _internal { Cancellable::~Cancellable() diff --git a/sdk/core/azure-core-amqp/src/amqp/claim_based_security.cpp b/sdk/core/azure-core-amqp/src/amqp/claim_based_security.cpp index 7c93f083fd..a37d8b1b98 100644 --- a/sdk/core/azure-core-amqp/src/amqp/claim_based_security.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/claim_based_security.cpp @@ -6,7 +6,15 @@ #include "private/claims_based_security_impl.hpp" #include "private/connection_impl.hpp" #include "private/session_impl.hpp" + +#include +#include + #include +#include + +using namespace Azure::Core::Diagnostics::_internal; +using namespace Azure::Core::Diagnostics; void Azure::Core::_internal::UniqueHandleHelper::FreeAmqpCbs(CBS_HANDLE value) { @@ -19,23 +27,20 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { // The non-Impl types for CBS exist only for testing purposes. #if defined(TESTING_BUILD) ClaimsBasedSecurity::ClaimsBasedSecurity(Session const& session) - : m_impl{std::make_shared<_detail::ClaimsBasedSecurityImpl>(session.GetImpl())} + : m_impl{std::make_shared<_detail::ClaimsBasedSecurityImpl>(SessionFactory::GetImpl(session))} { } ClaimsBasedSecurity::~ClaimsBasedSecurity() noexcept {} - CbsOpenResult ClaimsBasedSecurity::Open(Azure::Core::Context context) - { - return m_impl->Open(context); - } + CbsOpenResult ClaimsBasedSecurity::Open(Context const& context) { return m_impl->Open(context); } void ClaimsBasedSecurity::Close() { m_impl->Close(); } std::tuple ClaimsBasedSecurity::PutToken( CbsTokenType tokenType, std::string const& audience, std::string const& token, - Azure::Core::Context context) + Context const& context) { return m_impl->PutToken(tokenType, audience, token, context); @@ -91,11 +96,34 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { (void)cbs; } + const char* OpenResultStringFromLowLevel(CBS_OPEN_COMPLETE_RESULT result) + { + switch (result) + { + case CBS_OPEN_OK: + return "CbsOpenResult::Ok"; + // LCOV_EXCL_START + case CBS_OPEN_CANCELLED: + return "CbsOpenResult::Cancelled"; + case CBS_OPEN_ERROR: + return "CbsOpenResult::Error"; + default: + throw std::logic_error("Unknown CBS Open result."); + // LCOV_EXCL_STOP + } + } + void ClaimsBasedSecurityImpl::OnCbsOpenCompleteFn( void* context, CBS_OPEN_COMPLETE_RESULT openCompleteResult) { auto cbs = static_cast(const_cast(context)); + if (cbs->m_traceEnabled) + { + std::stringstream ss; + ss << "OnCbsOpenComplete: " << OpenResultStringFromLowLevel(openCompleteResult); + Log::Write(Logger::Level::Informational, ss.str()); + } cbs->m_openResultQueue.CompleteOperation(CbsOpenResultStateFromLowLevel(openCompleteResult)); } @@ -103,18 +131,21 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { { switch (result) { - case CBS_OPERATION_RESULT_CBS_ERROR: // LCOV_EXCL_LINE - return "CbsOperationResult::Error"; // LCOV_EXCL_LINE - case CBS_OPERATION_RESULT_INSTANCE_CLOSED: // LCOV_EXCL_LINE - return "CbsOperationResult::InstanceClosed"; // LCOV_EXCL_LINE - case CBS_OPERATION_RESULT_INVALID: // LCOV_EXCL_LINE - return "CbsOperationResult::Invalid"; // LCOV_EXCL_LINE case CBS_OPERATION_RESULT_OK: return "CbsOperationResult::Ok"; - case CBS_OPERATION_RESULT_OPERATION_FAILED: // LCOV_EXCL_LINE - return "CbsOperationResult::Failed"; // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - throw std::logic_error("Unknown CBS Operation result."); // LCOV_EXCL_LINE + + // LCOV_EXCL_START + case CBS_OPERATION_RESULT_CBS_ERROR: + return "CbsOperationResult::Error"; + case CBS_OPERATION_RESULT_INSTANCE_CLOSED: + return "CbsOperationResult::InstanceClosed"; + case CBS_OPERATION_RESULT_INVALID: + return "CbsOperationResult::Invalid"; + case CBS_OPERATION_RESULT_OPERATION_FAILED: + return "CbsOperationResult::Failed"; + default: + throw std::logic_error("Unknown CBS Operation result."); + // LCOV_EXCL_STOP } } @@ -125,42 +156,58 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { const char* statusDescription) { auto cbs = static_cast(const_cast(context)); - std::cout << "OnCbsOperationComplete: " - << OperationResultStringFromLowLevel(operationCompleteResult) - << " StatusCode: " << statusCode << " StatusDescription: " - << (statusDescription ? std::string(statusDescription) : "(NULL)") << std::endl; + if (cbs->m_traceEnabled) + { + std::stringstream ss; + ss << "OnCbsOperationComplete: " << OperationResultStringFromLowLevel(operationCompleteResult) + << " StatusCode: " << statusCode << " StatusDescription: " + << (statusDescription ? std::string(statusDescription) : "(NULL)"); + Log::Write(Logger::Level::Informational, ss.str()); + } + cbs->m_operationResultQueue.CompleteOperation( CbsOperationResultStateFromLowLevel(operationCompleteResult), statusCode, statusDescription ? statusDescription : std::string()); } - CbsOpenResult ClaimsBasedSecurityImpl::Open(Azure::Core::Context context) + CbsOpenResult ClaimsBasedSecurityImpl::Open(Context const& context) { if (cbs_open_async( m_cbs.get(), ClaimsBasedSecurityImpl::OnCbsOpenCompleteFn, this, OnCbsErrorFn, this)) { return CbsOpenResult::Error; } - auto result = m_openResultQueue.WaitForPolledResult(context, *m_session->GetConnectionToPoll()); + auto result = m_openResultQueue.WaitForPolledResult(context, *m_session->GetConnection()); + if (result && std::get<0>(*result) == CbsOpenResult::Ok) + { + m_cbsOpen = true; + } return std::get<0>(*result); } void ClaimsBasedSecurityImpl::Close() { - if (cbs_close(m_cbs.get())) + if (m_cbsOpen) { - throw std::runtime_error("Could not close cbs"); // LCOV_EXCL_LINE + if (cbs_close(m_cbs.get())) + { + throw std::runtime_error("Could not close cbs"); // LCOV_EXCL_LINE + } } } - void ClaimsBasedSecurityImpl::SetTrace(bool traceOn) { cbs_set_trace(m_cbs.get(), traceOn); } + void ClaimsBasedSecurityImpl::SetTrace(bool traceOn) + { + cbs_set_trace(m_cbs.get(), traceOn); + m_traceEnabled = traceOn; + } std::tuple ClaimsBasedSecurityImpl::PutToken( CbsTokenType tokenType, std::string const& audience, std::string const& token, - Azure::Core::Context context) + Context const& context) { if (cbs_put_token_async( m_cbs.get(), @@ -173,8 +220,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { { throw std::runtime_error("Could not put CBS token."); // LCOV_EXCL_LINE } - auto result - = m_operationResultQueue.WaitForPolledResult(context, *m_session->GetConnectionToPoll()); + auto result = m_operationResultQueue.WaitForPolledResult(context, *m_session->GetConnection()); // Throw an error if we failed to authenticate with the server. if (std::get<0>(*result) != CbsOperationResult::Ok) diff --git a/sdk/core/azure-core-amqp/src/amqp/connection.cpp b/sdk/core/azure-core-amqp/src/amqp/connection.cpp index bf71eecdb6..cfafc6cb07 100644 --- a/sdk/core/azure-core-amqp/src/amqp/connection.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/connection.cpp @@ -2,16 +2,22 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/connection.hpp" + #include "../network/private/transport_impl.hpp" #include "azure/core/amqp/common/global_state.hpp" +#include "azure/core/amqp/models/amqp_value.hpp" #include "azure/core/amqp/network/socket_transport.hpp" #include "azure/core/amqp/network/tls_transport.hpp" +#include "private/claims_based_security_impl.hpp" #include "private/connection_impl.hpp" + #include #include #include #include + #include + #include void Azure::Core::_internal::UniqueHandleHelper::FreeAmqpConnection( @@ -27,132 +33,103 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { // Create a connection with an existing networking Transport. Connection::Connection( - std::shared_ptr transport, + Network::_internal::Transport const& transport, ConnectionOptions const& options, ConnectionEvents* eventHandler) - : m_impl{std::make_shared( - transport->GetImpl(), - options, - eventHandler)} + : m_impl{ + std::make_shared<_detail::ConnectionImpl>(transport.GetImpl(), options, eventHandler)} { m_impl->FinishConstruction(); } // Create a connection with a request URI and options. Connection::Connection( - std::string const& requestUri, + std::string const& hostName, ConnectionOptions const& options, ConnectionEvents* eventHandler) - : m_impl{std::make_shared( - requestUri, - options, - eventHandler)} + : m_impl{std::make_shared<_detail::ConnectionImpl>(hostName, options, eventHandler)} { m_impl->FinishConstruction(); } Connection::~Connection() {} - void Connection::Poll() const { m_impl->Poll(); } + void Connection::Poll() { m_impl->Poll(); } void Connection::Listen() { m_impl->Listen(); } - void Connection::SetTrace(bool enableTrace) { m_impl->SetTrace(enableTrace); } void Connection::Open() { m_impl->Open(); } void Connection::Close( std::string const& condition, std::string const& description, - Azure::Core::Amqp::Models::AmqpValue value) + Models::AmqpValue value) { m_impl->Close(condition, description, value); } uint32_t Connection::GetMaxFrameSize() const { return m_impl->GetMaxFrameSize(); } - void Connection::SetMaxFrameSize(uint32_t maxFrameSize) { m_impl->SetMaxFrameSize(maxFrameSize); } uint32_t Connection::GetRemoteMaxFrameSize() const { return m_impl->GetRemoteMaxFrameSize(); } uint16_t Connection::GetMaxChannel() const { return m_impl->GetMaxChannel(); } - void Connection::SetMaxChannel(uint16_t channel) { m_impl->SetMaxChannel(channel); } + std::string Connection::GetHost() const { return m_impl->GetHost(); } + uint16_t Connection::GetPort() const { return m_impl->GetPort(); } std::chrono::milliseconds Connection::GetIdleTimeout() const { return m_impl->GetIdleTimeout(); } - void Connection::SetIdleTimeout(std::chrono::milliseconds timeout) - { - m_impl->SetIdleTimeout(timeout); - } - void Connection::SetRemoteIdleTimeoutEmptyFrameSendRatio(double idleTimeoutEmptyFrameSendRatio) - { - return m_impl->SetRemoteIdleTimeoutEmptyFrameSendRatio(idleTimeoutEmptyFrameSendRatio); - } - - void Connection::SetProperties(Azure::Core::Amqp::Models::AmqpValue properties) + Models::AmqpMap Connection::GetProperties() const { return m_impl->GetProperties(); } + void Connection::SetIdleEmptyFrameSendPercentage(double ratio) { - m_impl->SetProperties(properties); - } - Azure::Core::Amqp::Models::AmqpValue Connection::GetProperties() const - { - return m_impl->GetProperties(); + m_impl->SetIdleEmptyFrameSendPercentage(ratio); } }}}} // namespace Azure::Core::Amqp::_internal +namespace { +void EnsureGlobalStateInitialized() +{ + // Force the global instance to exist. This is required to ensure that uAMQP and + // azure-c-shared-utility is + auto globalInstance + = Azure::Core::Amqp::Common::_detail::GlobalStateHolder::GlobalStateInstance(); + (void)globalInstance; +} +} // namespace + namespace Azure { namespace Core { namespace Amqp { namespace _detail { - namespace { - void EnsureGlobalStateInitialized() - { - // Force the global instance to exist. This is required to ensure that uAMQP and - // azure-c-shared-utility is - auto globalInstance - = Azure::Core::Amqp::Common::_detail::GlobalStateHolder::GlobalStateInstance(); - (void)globalInstance; - } - } // namespace // Create a connection with an existing networking Transport. ConnectionImpl::ConnectionImpl( std::shared_ptr transport, _internal::ConnectionOptions const& options, _internal::ConnectionEvents* eventHandler) - : m_hostName{options.HostName}, m_options{options}, m_eventHandler{eventHandler} + : m_hostName{"localhost"}, m_options{options}, m_eventHandler{eventHandler} { - if (options.SaslCredentials) - { - throw std::runtime_error("Sasl Credentials should not be provided with a transport."); - } EnsureGlobalStateInitialized(); m_transport = transport; } // Create a connection with a request URI and options. ConnectionImpl::ConnectionImpl( - std::string const& requestUri, + std::string const& hostName, _internal::ConnectionOptions const& options, _internal::ConnectionEvents* eventHandler) - : m_options{options}, m_eventHandler{eventHandler} + : m_hostName{hostName}, m_port{options.Port}, m_options{options}, m_eventHandler{eventHandler} { EnsureGlobalStateInitialized(); - if (options.SaslCredentials) - { - throw std::runtime_error("Sasl Credentials should not be provided with a request URI."); - } - Azure::Core::Url requestUrl(requestUri); - std::shared_ptr requestTransport; - if (requestUrl.GetScheme() == "amqp") + if (options.Port == _internal::AmqpPort) { Log::Write(Logger::Level::Informational, "Creating socket connection transport."); - Azure::Core::Amqp::Network::_internal::SocketTransport transport{ - requestUrl.GetHost(), - requestUrl.GetPort() ? requestUrl.GetPort() : static_cast(AmqpPort)}; - m_transport = transport.GetImpl(); + m_transport + = Network::_internal::SocketTransportFactory::Create(m_hostName, m_port).GetImpl(); } - else if (requestUrl.GetScheme() == "amqps") + else if (options.Port == _internal::AmqpTlsPort) { Log::Write(Logger::Level::Informational, "Creating TLS socket connection transport."); - Azure::Core::Amqp::Network::_internal::TlsTransport transport{ - requestUrl.GetHost(), - requestUrl.GetPort() ? requestUrl.GetPort() : static_cast(AmqpsPort)}; - m_transport = transport.GetImpl(); + m_transport = Network::_internal::TlsTransportFactory::Create(m_hostName, m_port).GetImpl(); } else { - throw std::runtime_error("Unknown connection scheme: " + requestUrl.GetScheme() + "."); + Log::Write( + Logger::Level::Informational, + "Unknown port specified, assuming socket connection transport."); + m_transport + = Network::_internal::SocketTransportFactory::Create(m_hostName, m_port).GetImpl(); } - m_hostName = requestUrl.GetHost(); } ConnectionImpl::~ConnectionImpl() @@ -180,21 +157,40 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { this, OnConnectionStateChangedFn, this, - OnIoErrorFn, + OnIOErrorFn, this)); - SetTrace(m_options.EnableTrace); - // SetIdleTimeout(options.IdleTimeout); - - // SetMaxFrameSize(options.MaxFrameSize); - // SetMaxChannel(options.MaxSessions); - // SetProperties(options.Properties); - - // std::string SASLType; // Not a string - fill in later. - // std::chrono::seconds Timeout{0}; + if (m_options.EnableTrace) + { + connection_set_trace(m_connection.get(), m_options.EnableTrace); + } + if (connection_set_idle_timeout( + m_connection.get(), static_cast(m_options.IdleTimeout.count()))) + { + throw std::runtime_error("Failed to set idle timeout."); + } + if (connection_set_channel_max(m_connection.get(), m_options.MaxChannelCount)) + { + throw std::runtime_error("Failed to set max channel count."); + } + if (connection_set_max_frame_size(m_connection.get(), m_options.MaxFrameSize)) + { + throw std::runtime_error("Failed to set max frame size."); + } + if (connection_set_properties( + m_connection.get(), + static_cast(m_options.Properties).get())) + { + throw std::runtime_error("Failed to set connection properties."); + } } - void ConnectionImpl::Poll() const + void ConnectionImpl::Poll() { + if (m_connectionState == _internal::ConnectionState::Error + || m_connectionState == _internal::ConnectionState::End) + { + throw std::runtime_error("Connection cannot be polled in the current state."); + } if (m_connection) { connection_dowork(m_connection.get()); @@ -243,31 +239,36 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { if (connection->m_eventHandler) { connection->m_eventHandler->OnConnectionStateChanged( - connection->shared_from_this(), + ConnectionFactory::CreateFromInternal(connection->shared_from_this()), ConnectionStateFromCONNECTION_STATE(newState), ConnectionStateFromCONNECTION_STATE(oldState)); } + connection->SetState(ConnectionStateFromCONNECTION_STATE(newState)); } bool ConnectionImpl::OnNewEndpointFn(void* context, ENDPOINT_HANDLE newEndpoint) { ConnectionImpl* cn = static_cast(context); - _internal::Endpoint endpoint(newEndpoint); + _internal::Endpoint endpoint(EndpointFactory::CreateEndpoint(newEndpoint)); if (cn->m_eventHandler) { - return cn->m_eventHandler->OnNewEndpoint(cn->shared_from_this(), endpoint); + return cn->m_eventHandler->OnNewEndpoint( + ConnectionFactory::CreateFromInternal(cn->shared_from_this()), endpoint); } return false; // LCOV_EXCL_LINE } - void ConnectionImpl::OnIoErrorFn(void* context) // LCOV_EXCL_LINE - { // LCOV_EXCL_LINE - ConnectionImpl* cn = static_cast(context); // LCOV_EXCL_LINE - if (cn->m_eventHandler) // LCOV_EXCL_LINE - { // LCOV_EXCL_LINE - return cn->m_eventHandler->OnIoError(cn->shared_from_this()); // LCOV_EXCL_LINE - } // LCOV_EXCL_LINE - } // LCOV_EXCL_LINE + // LCOV_EXCL_START + void ConnectionImpl::OnIOErrorFn(void* context) + { + ConnectionImpl* cn = static_cast(context); + if (cn->m_eventHandler) + { + return cn->m_eventHandler->OnIOError( + ConnectionFactory::CreateFromInternal(cn->shared_from_this())); + } + } + // LCOV_EXCL_STOP void ConnectionImpl::Open() { @@ -285,15 +286,10 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { } } - void ConnectionImpl::SetTrace(bool setTrace) - { - connection_set_trace(m_connection.get(), setTrace); - } - void ConnectionImpl::Close( const std::string& condition, const std::string& description, - Azure::Core::Amqp::Models::AmqpValue info) + Models::AmqpValue info) { if (!m_connection) { @@ -310,13 +306,6 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { } } - void ConnectionImpl::SetMaxFrameSize(uint32_t maxSize) - { - if (connection_set_max_frame_size(m_connection.get(), maxSize)) - { - throw std::runtime_error("COuld not set max frame size."); // LCOV_EXCL_LINE - } - } uint32_t ConnectionImpl::GetMaxFrameSize() const { uint32_t maxSize; @@ -327,13 +316,6 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { return maxSize; } - void ConnectionImpl::SetMaxChannel(uint16_t maxChannel) - { - if (connection_set_channel_max(m_connection.get(), maxChannel)) - { - throw std::runtime_error("COuld not set channel max."); // LCOV_EXCL_LINE - } - } uint16_t ConnectionImpl::GetMaxChannel() const { uint16_t maxChannel; @@ -344,14 +326,6 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { return maxChannel; } - void ConnectionImpl::SetIdleTimeout(std::chrono::milliseconds idleTimeout) - { - if (connection_set_idle_timeout( - m_connection.get(), static_cast(idleTimeout.count()))) - { - throw std::runtime_error("COuld not set idle timeout."); // LCOV_EXCL_LINE - } - } std::chrono::milliseconds ConnectionImpl::GetIdleTimeout() const { milliseconds ms; @@ -363,21 +337,14 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { return std::chrono::milliseconds(ms); } - void ConnectionImpl::SetProperties(Azure::Core::Amqp::Models::AmqpValue value) - { - if (connection_set_properties(m_connection.get(), value)) - { - throw std::runtime_error("COuld not set properties."); // LCOV_EXCL_LINE - } - } - Azure::Core::Amqp::Models::AmqpValue ConnectionImpl::GetProperties() const + Models::AmqpMap ConnectionImpl::GetProperties() const { AMQP_VALUE value; if (connection_get_properties(m_connection.get(), &value)) { throw std::runtime_error("COuld not get properties."); // LCOV_EXCL_LINE } - return value; + return Models::AmqpValue{value}.AsMap(); } uint32_t ConnectionImpl::GetRemoteMaxFrameSize() const @@ -389,7 +356,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { } return maxFrameSize; } - void ConnectionImpl::SetRemoteIdleTimeoutEmptyFrameSendRatio(double ratio) + + void ConnectionImpl::SetIdleEmptyFrameSendPercentage(double ratio) { if (connection_set_remote_idle_timeout_empty_frame_send_ratio(m_connection.get(), ratio)) { @@ -397,5 +365,4 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { "Could not set remote idle timeout send frame ratio."); // LCOV_EXCL_LINE } } - }}}} // namespace Azure::Core::Amqp::_detail diff --git a/sdk/core/azure-core-amqp/src/amqp/connection_string_credential.cpp b/sdk/core/azure-core-amqp/src/amqp/connection_string_credential.cpp index 88309e9916..c4fe4dd0bc 100644 --- a/sdk/core/azure-core-amqp/src/amqp/connection_string_credential.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/connection_string_credential.cpp @@ -2,16 +2,21 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/connection_string_credential.hpp" + +#include "azure/core/amqp/connection.hpp" #include "azure/core/amqp/models/amqp_protocol.hpp" #include "azure/core/amqp/network/socket_transport.hpp" -#include + #include #include + #include #include #include #include #include + +#include #include #include #include @@ -42,27 +47,6 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { return result; } - SaslPlainConnectionStringCredential::SaslPlainConnectionStringCredential( - const std::string& connectionString) - : ConnectionStringCredential(connectionString, CredentialType::SaslPlain) - { - Azure::Core::Url endpointUrl{GetEndpoint()}; - } - - std::shared_ptr SaslPlainConnectionStringCredential::GetTransport() - const - { - return std::make_shared( - GetSharedAccessKeyName(), GetSharedAccessKey(), GetHostName(), GetPort()); - } - - std::shared_ptr - ServiceBusSasConnectionStringCredential::GetTransport() const - { - // // Construct a SASL Anonymous transport - // return std::make_shared(GetHostName(), GetPort()); - return std::make_shared(GetHostName(), GetPort()); - } // // A ServiceBus connection string has the following format: // "Endpoint=sb://.servicebus.windows.net/;SharedAccessKeyName=;SharedAccessKey=;EntityPath=" @@ -72,7 +56,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { // access key name and shared access key are required if the endpoint is not a local endpoint. // The endpoint is formatted as a URL, extract the host and port from the endpoint and use them // when constructing the SaslAnonymous transport. - void ConnectionStringCredential::ParseConnectionString(const std::string& connectionString) + void ConnectionStringParser::ParseConnectionString(const std::string& connectionString) { std::unordered_map elements; // Split the connection string into separate components. @@ -105,7 +89,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { Azure::Core::Url endpointUrl{m_endpoint}; m_hostName = endpointUrl.GetHost(); m_port = endpointUrl.GetPort() != 0 ? endpointUrl.GetPort() - : static_cast(_detail::AmqpsPort); + : Azure::Core::Amqp::_internal::AmqpTlsPort; } else { @@ -135,6 +119,36 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { } } + std::shared_ptr + ServiceBusSasConnectionStringCredential::GetTransport() const + { + // // Construct a SASL Anonymous transport + // return std::make_shared(GetHostName(), GetPort()); + return std::make_shared( + Network::_internal::SocketTransportFactory::Create(GetHostName(), GetPort())); + } + + /** + * @brief Gets an authentication token. + * + * @param tokenRequestContext A context to get the token in. + * @param context A context to control the request lifetime. + * + * @return Authentication token. + * + * @throw Credentials::AuthenticationException Authentication error occurred. + */ + Credentials::AccessToken ServiceBusSasConnectionStringCredential::GetToken( + Credentials::TokenRequestContext const& tokenRequestContext, + Context const& context) const + { + Credentials::AccessToken rv; + rv.ExpiresOn = Azure::DateTime::clock::now() + tokenRequestContext.MinimumExpiration; + rv.Token = GenerateSasToken(static_cast(rv.ExpiresOn)); + (void)context; + return rv; + } + // Generate a Shared Access Signature token for a ServiceBus client. // // The spec for a SharedAccessSignature is here: diff --git a/sdk/core/azure-core-amqp/src/amqp/link.cpp b/sdk/core/azure-core-amqp/src/amqp/link.cpp index 9244162d1d..848d9b3bd8 100644 --- a/sdk/core/azure-core-amqp/src/amqp/link.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/link.cpp @@ -2,8 +2,11 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/link.hpp" + #include "azure/core/amqp/message_receiver.hpp" #include "azure/core/amqp/message_sender.hpp" +#include "azure/core/amqp/models/message_source.hpp" +#include "azure/core/amqp/models/message_target.hpp" #include "azure/core/amqp/models/messaging_values.hpp" #include "private/link_impl.hpp" #include "private/session_impl.hpp" @@ -14,14 +17,15 @@ #include namespace Azure { namespace Core { namespace Amqp { namespace _detail { - +#if defined(TESTING_BUILD) Link::Link( _internal::Session const& session, std::string const& name, Azure::Core::Amqp::_internal::SessionRole role, - std::string const& source, - std::string const& target) - : m_impl{std::make_shared(session.GetImpl(), name, role, source, target)} + Models::_internal::MessageSource const& source, + Models::_internal::MessageTarget const& target) + : m_impl{ + std::make_shared(SessionFactory::GetImpl(session), name, role, source, target)} { } @@ -30,18 +34,17 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { _internal::LinkEndpoint& linkEndpoint, std::string const& name, _internal::SessionRole role, - std::string const& source, - std::string const& target) - : m_impl{ - std::make_shared(session.GetImpl(), linkEndpoint, name, role, source, target)} + Models::_internal::MessageSource const& source, + Models::_internal::MessageTarget const& target) + : m_impl{std::make_shared< + LinkImpl>(SessionFactory::GetImpl(session), linkEndpoint, name, role, source, target)} { } Link::~Link() noexcept {} - Link::operator LINK_HANDLE() const { return m_impl->operator LINK_HANDLE(); } - std::string const& Link::GetSource() const { return m_impl->GetSource(); } - std::string const& Link::GetTarget() const { return m_impl->GetTarget(); } + Models::_internal::MessageSource const& Link::GetSource() const { return m_impl->GetSource(); } + Models::_internal::MessageTarget const& Link::GetTarget() const { return m_impl->GetTarget(); } _internal::SenderSettleMode Link::GetSenderSettleMode() const { return m_impl->GetSenderSettleMode(); @@ -69,7 +72,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { } uint64_t Link::GetMaxMessageSize() const { return m_impl->GetMaxMessageSize(); } uint64_t Link::GetPeerMaxMessageSize() const { return m_impl->GetPeerMaxMessageSize(); } - void Link::SetAttachProperties(Azure::Core::Amqp::Models::AmqpValue attachProperties) + void Link::SetAttachProperties(Models::AmqpValue attachProperties) { m_impl->SetAttachProperties(attachProperties); } @@ -84,10 +87,11 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { bool close, std::string const& errorCondition, std::string const& errorDescription, - Azure::Core::Amqp::Models::AmqpValue& info) + Models::AmqpValue& info) { return m_impl->Detach(close, errorCondition, errorDescription, info); } +#endif /****/ /* LINK Implementation */ @@ -96,16 +100,18 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { std::shared_ptr<_detail::SessionImpl> session, std::string const& name, _internal::SessionRole role, - std::string const& source, - std::string const& target) + Models::_internal::MessageSource const& source, + Models::_internal::MessageTarget const& target) : m_session{session}, m_source(source), m_target(target) { + Models::AmqpValue sourceValue{source.AsAmqpValue()}; + Models::AmqpValue targetValue(target.AsAmqpValue()); m_link = link_create( *session, name.c_str(), role == _internal::SessionRole::Sender ? role_sender : role_receiver, - Azure::Core::Amqp::Models::_internal::Messaging::CreateSource(source), - Azure::Core::Amqp::Models::_internal::Messaging::CreateTarget(target)); + sourceValue, + targetValue); } LinkImpl::LinkImpl( @@ -113,17 +119,19 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { _internal::LinkEndpoint& linkEndpoint, std::string const& name, _internal::SessionRole role, - std::string const& source, - std::string const& target) + Models::_internal::MessageSource const& source, + Models::_internal::MessageTarget const& target) : m_session{session}, m_source(source), m_target(target) { + Models::AmqpValue sourceValue(source.AsAmqpValue()); + Models::AmqpValue targetValue(target.AsAmqpValue()); m_link = link_create_from_endpoint( *session, - linkEndpoint.Release(), + LinkEndpointFactory::Release(linkEndpoint), name.c_str(), role == _internal::SessionRole::Sender ? role_sender : role_receiver, - Azure::Core::Amqp::Models::_internal::Messaging::CreateSource(source), - Azure::Core::Amqp::Models::_internal::Messaging::CreateTarget(target)); + sourceValue, + targetValue); } LinkImpl::~LinkImpl() noexcept @@ -135,8 +143,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { } } - std::string const& LinkImpl::GetSource() const { return m_source; } - std::string const& LinkImpl::GetTarget() const { return m_target; } + Models::_internal::MessageSource const& LinkImpl::GetSource() const { return m_source; } + Models::_internal::MessageTarget const& LinkImpl::GetTarget() const { return m_target; } void LinkImpl::SetMaxMessageSize(uint64_t size) { @@ -280,7 +288,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { throw std::runtime_error("Could not set initial delivery count."); // LCOV_EXCL_LINE } } - void LinkImpl::SetAttachProperties(Azure::Core::Amqp::Models::AmqpValue properties) + void LinkImpl::SetAttachProperties(Models::AmqpValue properties) { if (link_set_attach_properties(m_link, properties)) { @@ -306,7 +314,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { bool close, std::string const& condition, std::string const& description, - Azure::Core::Amqp::Models::AmqpValue& info) + Models::AmqpValue& info) { if (link_detach( m_link, diff --git a/sdk/core/azure-core-amqp/src/amqp/management.cpp b/sdk/core/azure-core-amqp/src/amqp/management.cpp index 2f0fa4e3af..8d5cf31c5e 100644 --- a/sdk/core/azure-core-amqp/src/amqp/management.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/management.cpp @@ -2,15 +2,19 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/management.hpp" + #include "azure/core/amqp/connection.hpp" #include "azure/core/amqp/models/amqp_message.hpp" #include "azure/core/amqp/session.hpp" #include "private/connection_impl.hpp" #include "private/management_impl.hpp" + #include #include #include + #include + #include #include #include @@ -31,18 +35,18 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { * @brief Create a new Management object instance. * * @param session - the session on which to create the instance. - * @param managementNodeName - the name of the message source and target. + * @param managementEntityPath - the name of the AMQP instance. * @param options - additional options for the Management object. * @param managementEvents - events associated with the management object. */ Management::Management( Session const& session, - std::string const& managementNodeName, + std::string const& managementEntityPath, ManagementOptions const& options, ManagementEvents* managementEvents) : m_impl{std::make_shared<_detail::ManagementImpl>( - session.GetImpl(), - managementNodeName, + _detail::SessionFactory::GetImpl(session), + managementEntityPath, options, managementEvents)} { @@ -54,10 +58,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { * @returns A tuple consisting of the status code for the open and the description of the * status. */ - ManagementOpenStatus Management::Open(Azure::Core::Context const& context) - { - return m_impl->Open(context); - } + ManagementOpenStatus Management::Open(Context const& context) { return m_impl->Open(context); } /** * @brief Close the management instance. @@ -68,8 +69,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { std::string const& operationToPerform, std::string const& typeOfOperation, std::string const& locales, - Azure::Core::Amqp::Models::AmqpMessage const& messageToSend, - Azure::Core::Context context) + Models::AmqpMessage messageToSend, + Context const& context) { return m_impl->ExecuteOperation( operationToPerform, typeOfOperation, locales, messageToSend, context); @@ -79,12 +80,15 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal { namespace Azure { namespace Core { namespace Amqp { namespace _detail { ManagementImpl::ManagementImpl( std::shared_ptr session, - std::string const& managementNodeName, + std::string const& managementEntityPath, Azure::Core::Amqp::_internal::ManagementOptions const& options, Azure::Core::Amqp::_internal::ManagementEvents* managementEvents) - : m_management{amqp_management_create(*session, managementNodeName.c_str())}, - m_options{options}, m_session{session}, m_eventHandler{managementEvents} + : m_options{options}, m_session{session}, m_eventHandler{managementEvents} { + /** Authentication needs to happen *before* the management object is created. */ + m_session->AuthenticateIfNeeded(managementEntityPath + "/" + m_options.ManagementNodeName, {}); + + m_management.reset(amqp_management_create(*session, m_options.ManagementNodeName.c_str())); if (options.EnableTrace) { amqp_management_set_trace(m_management.get(), options.EnableTrace); @@ -102,7 +106,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { } ManagementImpl::~ManagementImpl() noexcept { m_eventHandler = nullptr; } - _internal::ManagementOpenStatus ManagementImpl::Open(Azure::Core::Context const& context) + _internal::ManagementOpenStatus ManagementImpl::Open(Context const& context) { if (amqp_management_open_async( m_management.get(), @@ -113,8 +117,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { { throw std::runtime_error("Could not open management object."); } - auto result - = m_openCompleteQueue.WaitForPolledResult(context, *m_session->GetConnectionToPoll()); + auto result = m_openCompleteQueue.WaitForPolledResult(context, *m_session->GetConnection()); if (result) { switch (std::get<0>(*result)) @@ -136,14 +139,19 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { std::string const& operationToPerform, std::string const& typeOfOperation, std::string const& locales, - Azure::Core::Amqp::Models::AmqpMessage const& messageToSend, - Azure::Core::Context context) + Models::AmqpMessage messageToSend, + Context const& context) { + auto token = m_session->GetSecurityToken(m_managementNodeName); + if (!token.empty()) + { + messageToSend.ApplicationProperties["security_token"] = Models::AmqpValue{token}; + } if (!amqp_management_execute_operation_async( m_management.get(), operationToPerform.c_str(), typeOfOperation.c_str(), - locales.c_str(), + (locales.empty() ? nullptr : locales.c_str()), Models::_internal::AmqpMessageFactory::ToUamqp(messageToSend).get(), ManagementImpl::OnExecuteOperationCompleteFn, this)) @@ -151,7 +159,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { throw std::runtime_error("Could not execute operation."); // LCOV_EXCL_LINE } - auto result = m_messageQueue.WaitForPolledResult(context, *m_session->GetConnectionToPoll()); + auto result = m_messageQueue.WaitForPolledResult(context, *m_session->GetConnection()); if (result) { _internal::ManagementOperationResult rv; @@ -172,15 +180,21 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { void ManagementImpl::OnOpenCompleteFn(void* context, AMQP_MANAGEMENT_OPEN_RESULT openResult) { ManagementImpl* management = static_cast(context); - Log::Write( - Logger::Level::Informational, "OnManagementOpenComplete: " + std::to_string(openResult)); + if (management->m_options.EnableTrace) + { + Log::Write( + Logger::Level::Informational, "OnManagementOpenComplete: " + std::to_string(openResult)); + } management->m_openCompleteQueue.CompleteOperation(openResult); } void ManagementImpl::OnManagementErrorFn(void* context) { - Log::Write(Logger::Level::Error, "Error processing management operation."); ManagementImpl* management = static_cast(context); + if (management->m_options.EnableTrace) + { + Log::Write(Logger::Level::Error, "Error processing management operation."); + } if (management->m_eventHandler) { management->m_eventHandler->OnError(); diff --git a/sdk/core/azure-core-amqp/src/amqp/message_receiver.cpp b/sdk/core/azure-core-amqp/src/amqp/message_receiver.cpp index ac331de96d..807cec25a2 100644 --- a/sdk/core/azure-core-amqp/src/amqp/message_receiver.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/message_receiver.cpp @@ -2,6 +2,7 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/message_receiver.hpp" + #include "azure/core/amqp/connection.hpp" #include "azure/core/amqp/connection_string_credential.hpp" #include "azure/core/amqp/link.hpp" @@ -9,10 +10,13 @@ #include "azure/core/amqp/models/messaging_values.hpp" #include "azure/core/amqp/session.hpp" #include "private/message_receiver_impl.hpp" + #include #include #include + #include + #include #include #include @@ -20,372 +24,262 @@ using namespace Azure::Core::Diagnostics::_internal; using namespace Azure::Core::Diagnostics; -namespace Azure { namespace Core { namespace Amqp { - using namespace Azure::Core::Amqp::_internal; - namespace _internal { - /** Configure the MessageReceiver for receiving messages from a service instance. - */ - MessageReceiver::MessageReceiver( - Session& session, - std::shared_ptr credential, - std::string const& source, - MessageReceiverOptions const& options, - MessageReceiverEvents* eventHandler) - : m_impl{std::make_shared<_detail::MessageReceiverImpl>( - session.GetImpl(), - credential, - source, - options, - eventHandler)} - { - } - MessageReceiver::MessageReceiver( - Session& session, - std::shared_ptr credential, - std::string const& source, - MessageReceiverOptions const& options, - MessageReceiverEvents* eventHandler) - : m_impl{std::make_shared<_detail::MessageReceiverImpl>( - session.GetImpl(), - credential, - source, - options, - eventHandler)} - { - } - MessageReceiver::MessageReceiver( - Session& session, - std::string const& source, - MessageReceiverOptions const& options, - MessageReceiverEvents* eventHandler) - : m_impl{std::make_shared<_detail::MessageReceiverImpl>( - session.GetImpl(), - source, - options, - eventHandler)} - { - } +void Azure::Core::_internal::UniqueHandleHelper::FreeMessageReceiver( + MESSAGE_RECEIVER_HANDLE value) +{ + messagereceiver_destroy(value); +} - /** Configure the MessageReceiver for receiving messages from a network listener. - */ - MessageReceiver::MessageReceiver( - Session const& session, - LinkEndpoint& linkEndpoint, - std::string const& source, - MessageReceiverOptions const& options, - MessageReceiverEvents* eventHandler) - : m_impl{std::make_shared<_detail::MessageReceiverImpl>( - session.GetImpl(), - linkEndpoint, - source, - options, - eventHandler)} - { - } +using namespace Azure::Core::Amqp::_internal; +namespace Azure { namespace Core { namespace Amqp { namespace _internal { + /** Configure the MessageReceiver for receiving messages from a service instance. + */ + MessageReceiver::MessageReceiver( + Session& session, + Models::_internal::MessageSource const& source, + MessageReceiverOptions const& options, + MessageReceiverEvents* eventHandler) + : m_impl{std::make_shared<_detail::MessageReceiverImpl>( + _detail::SessionFactory::GetImpl(session), + source, + options, + eventHandler)} + { + } - MessageReceiver::~MessageReceiver() noexcept {} + /** Configure the MessageReceiver for receiving messages from a network listener. + */ + MessageReceiver::MessageReceiver( + Session const& session, + LinkEndpoint& linkEndpoint, + Models::_internal::MessageSource const& source, + MessageReceiverOptions const& options, + MessageReceiverEvents* eventHandler) + : m_impl{std::make_shared<_detail::MessageReceiverImpl>( + _detail::SessionFactory::GetImpl(session), + linkEndpoint, + source, + options, + eventHandler)} + { + } - MessageReceiver::operator bool() const { return m_impl.operator bool(); } + MessageReceiver::~MessageReceiver() noexcept {} - void MessageReceiver::Open(Azure::Core::Context const& context) { m_impl->Open(context); } - void MessageReceiver::Close() { m_impl->Close(); } - void MessageReceiver::SetTrace(bool traceEnabled) { m_impl->SetTrace(traceEnabled); } - std::string MessageReceiver::GetSourceName() const { return m_impl->GetSourceName(); } - Azure::Core::Amqp::Models::AmqpMessage MessageReceiver::WaitForIncomingMessage( - Azure::Core::Context context) - { - return m_impl->WaitForIncomingMessage(context); - } - std::string MessageReceiver::GetLinkName() const { return m_impl->GetLinkName(); } - } // namespace _internal - namespace _detail { - - /** Configure the MessageReceiver for receiving messages from a service instance. - */ - MessageReceiverImpl::MessageReceiverImpl( - std::shared_ptr<_detail::SessionImpl> session, - std::shared_ptr credential, - std::string const& source, - MessageReceiverOptions const& options, - MessageReceiverEvents* eventHandler) - : m_options{options}, m_source{source}, m_session{session}, - m_connectionCredential{credential}, m_eventHandler(eventHandler) + MessageReceiver::operator bool() const { return m_impl.operator bool(); } + + void MessageReceiver::Open(Azure::Core::Context const& context) { m_impl->Open(context); } + void MessageReceiver::Close() { m_impl->Close(); } + std::string MessageReceiver::GetSourceName() const { return m_impl->GetSourceName(); } + Models::AmqpMessage MessageReceiver::WaitForIncomingMessage(Azure::Core::Context const& context) + { + return m_impl->WaitForIncomingMessage(context); + } + std::string MessageReceiver::GetLinkName() const { return m_impl->GetLinkName(); } +}}}} // namespace Azure::Core::Amqp::_internal + +namespace Azure { namespace Core { namespace Amqp { namespace _detail { + + /** Configure the MessageReceiver for receiving messages from a service instance. + */ + MessageReceiverImpl::MessageReceiverImpl( + std::shared_ptr<_detail::SessionImpl> session, + Models::_internal::MessageSource const& source, + MessageReceiverOptions const& options, + MessageReceiverEvents* eventHandler) + : m_options{options}, m_source{source}, m_session{session}, m_eventHandler(eventHandler) + { + } + + /** Configure the MessageReceiverImpl for receiving messages from a network listener. + */ + MessageReceiverImpl::MessageReceiverImpl( + std::shared_ptr<_detail::SessionImpl> session, + LinkEndpoint& linkEndpoint, + Models::_internal::MessageSource const& source, + MessageReceiverOptions const& options, + MessageReceiverEvents* eventHandler) + : m_options{options}, m_source{source}, m_session{session}, m_eventHandler(eventHandler) + { + CreateLink(linkEndpoint); + + m_messageReceiver.reset(messagereceiver_create( + *m_link, MessageReceiverImpl::OnMessageReceiverStateChangedFn, this)); + + messagereceiver_set_trace(m_messageReceiver.get(), options.EnableTrace); + } + + void MessageReceiverImpl::CreateLink(LinkEndpoint& endpoint) + { + // The endpoint version of CreateLink is creating a message receiver for a sender, not for a + // receiver. + m_link = std::make_shared<_detail::LinkImpl>( + m_session, + endpoint, + m_options.Name, + SessionRole::Sender, // This is the role of the link, not the endpoint. + m_source, + m_options.MessageTarget); + PopulateLinkProperties(); + } + + void MessageReceiverImpl::CreateLink() + { + m_link = std::make_shared<_detail::LinkImpl>( + m_session, m_options.Name, SessionRole::Receiver, m_source, m_options.MessageTarget); + PopulateLinkProperties(); + } + + void MessageReceiverImpl::PopulateLinkProperties() + { + if (m_options.InitialDeliveryCount.HasValue()) { + m_link->SetInitialDeliveryCount(m_options.InitialDeliveryCount.Value()); } - MessageReceiverImpl::MessageReceiverImpl( - std::shared_ptr<_detail::SessionImpl> session, - std::shared_ptr credential, - std::string const& source, - MessageReceiverOptions const& options, - MessageReceiverEvents* eventHandler) - : m_options{options}, m_source{source}, m_session{session}, m_tokenCredential{credential}, - m_eventHandler(eventHandler) + if (m_options.MaxMessageSize.HasValue()) { + m_link->SetMaxMessageSize(m_options.MaxMessageSize.Value()); } - MessageReceiverImpl::MessageReceiverImpl( - std::shared_ptr<_detail::SessionImpl> session, - std::string const& source, - MessageReceiverOptions const& options, - MessageReceiverEvents* eventHandler) - : m_options{options}, m_source{source}, m_session{session}, m_eventHandler(eventHandler) + else { + m_link->SetMaxMessageSize(std::numeric_limits::max()); } + } - /** Configure the MessageReceiverImpl for receiving messages from a network listener. - */ - MessageReceiverImpl::MessageReceiverImpl( - std::shared_ptr<_detail::SessionImpl> session, - LinkEndpoint& linkEndpoint, - std::string const& source, - MessageReceiverOptions const& options, - MessageReceiverEvents* eventHandler) - : m_options{options}, m_source{source}, m_session{session}, m_eventHandler(eventHandler) - { - CreateLink(linkEndpoint); + AMQP_VALUE MessageReceiverImpl::OnMessageReceivedFn(const void* context, MESSAGE_HANDLE message) + { + MessageReceiverImpl* receiver = static_cast(const_cast(context)); - m_messageReceiver = messagereceiver_create( - *m_link, MessageReceiverImpl::OnMessageReceiverStateChangedFn, this); - } - - void MessageReceiverImpl::CreateLink(LinkEndpoint& endpoint) + auto incomingMessage(Models::_internal::AmqpMessageFactory::FromUamqp(message)); + Models::AmqpValue rv; + if (receiver->m_eventHandler) { - // The endpoint version of CreateLink is creating a message receiver for a sender, not for a - // receiver. - m_link = std::make_unique<_detail::Link>( - m_session, - endpoint, - m_options.Name, - SessionRole::Sender, // This is the role of the link, not the endpoint. - m_source, - m_options.TargetAddress); - PopulateLinkProperties(); + rv = receiver->m_eventHandler->OnMessageReceived( + MessageReceiverFactory::CreateFromInternal(receiver->shared_from_this()), + incomingMessage); } - - void MessageReceiverImpl::CreateLink() + else { - m_link = std::make_unique<_detail::Link>( - m_session, m_options.Name, SessionRole::Receiver, m_source, m_options.TargetAddress); - PopulateLinkProperties(); + rv = receiver->OnMessageReceived(incomingMessage); } + return amqpvalue_clone(rv); + } - void MessageReceiverImpl::PopulateLinkProperties() - { - if (m_options.InitialDeliveryCount.HasValue()) - { - m_link->SetInitialDeliveryCount(m_options.InitialDeliveryCount.Value()); - } - if (m_options.MaxMessageSize.HasValue()) - { - m_link->SetMaxMessageSize(m_options.MaxMessageSize.Value()); - } - else - { - m_link->SetMaxMessageSize(std::numeric_limits::max()); - } - } + Models::AmqpValue MessageReceiverImpl::OnMessageReceived(Models::AmqpMessage message) + { + m_messageQueue.CompleteOperation(message); + return Models::_internal::Messaging::DeliveryAccepted(); + } - AMQP_VALUE MessageReceiverImpl::OnMessageReceivedFn(const void* context, MESSAGE_HANDLE message) + MessageReceiverImpl::~MessageReceiverImpl() noexcept + { + // If we're registered for events, null out the event handler, so we don't get called back + // during the destroy. + if (m_eventHandler) { - MessageReceiverImpl* receiver = static_cast(const_cast(context)); - - auto incomingMessage( - Azure::Core::Amqp::Models::_internal::AmqpMessageFactory::FromUamqp(message)); - Azure::Core::Amqp::Models::AmqpValue rv; - if (receiver->m_eventHandler) - { - rv = receiver->m_eventHandler->OnMessageReceived( - receiver->shared_from_this(), incomingMessage); - } - else - { - rv = receiver->OnMessageReceived(incomingMessage); - } - return amqpvalue_clone(rv); + m_eventHandler = nullptr; } + } - Azure::Core::Amqp::Models::AmqpValue MessageReceiverImpl::OnMessageReceived( - Azure::Core::Amqp::Models::AmqpMessage message) + MessageReceiverState MessageReceiverStateFromLowLevel(MESSAGE_RECEIVER_STATE lowLevel) + { + switch (lowLevel) { - m_messageQueue.CompleteOperation(message); - return Azure::Core::Amqp::Models::_internal::Messaging::DeliveryAccepted(); + case MESSAGE_RECEIVER_STATE_CLOSING: + return MessageReceiverState::Closing; + case MESSAGE_RECEIVER_STATE_ERROR: // LCOV_EXCL_LINE + return MessageReceiverState::Error; // LCOV_EXCL_LINE + case MESSAGE_RECEIVER_STATE_IDLE: + return MessageReceiverState::Idle; + case MESSAGE_RECEIVER_STATE_INVALID: // LCOV_EXCL_LINE + return MessageReceiverState::Invalid; // LCOV_EXCL_LINE + case MESSAGE_RECEIVER_STATE_OPEN: + return MessageReceiverState::Open; + case MESSAGE_RECEIVER_STATE_OPENING: + return MessageReceiverState::Opening; + default: // LCOV_EXCL_LINE + throw std::logic_error("Unknown message receiver state."); // LCOV_EXCL_LINE } + } - MessageReceiverImpl::~MessageReceiverImpl() noexcept - { - // If we're registered for events, null out the event handler, so we don't get called back - // during the destroy. - if (m_eventHandler) - { - m_eventHandler = nullptr; - } - if (m_claimsBasedSecurity && m_cbsOpen) - { - Log::Write(Logger::Level::Verbose, "Close CBS object."); - m_claimsBasedSecurity->Close(); - } - if (m_messageReceiver) - { - messagereceiver_destroy(m_messageReceiver); - m_messageReceiver = nullptr; - } - } + const char* MESSAGE_RECEIVER_STATEStrings[] = { + "MESSAGE_RECEIVER_STATE_INVALID", + "MESSAGE_RECEIVER_STATE_IDLE", + "MESSAGE_RECEIVER_STATE_OPENING", + "MESSAGE_RECEIVER_STATE_OPEN", + "MESSAGE_RECEIVER_STATE_CLOSING", + "MESSAGE_RECEIVER_STATE_ERROR", + }; - MessageReceiverState MessageReceiverStateFromLowLevel(MESSAGE_RECEIVER_STATE lowLevel) + void MessageReceiverImpl::OnMessageReceiverStateChangedFn( + void const* context, + MESSAGE_RECEIVER_STATE newState, + MESSAGE_RECEIVER_STATE oldState) + { + auto receiver = static_cast(const_cast(context)); + + if (receiver->m_eventHandler) { - switch (lowLevel) - { - case MESSAGE_RECEIVER_STATE_CLOSING: - return MessageReceiverState::Closing; - case MESSAGE_RECEIVER_STATE_ERROR: // LCOV_EXCL_LINE - return MessageReceiverState::Error; // LCOV_EXCL_LINE - case MESSAGE_RECEIVER_STATE_IDLE: - return MessageReceiverState::Idle; - case MESSAGE_RECEIVER_STATE_INVALID: // LCOV_EXCL_LINE - return MessageReceiverState::Invalid; // LCOV_EXCL_LINE - case MESSAGE_RECEIVER_STATE_OPEN: - return MessageReceiverState::Open; - case MESSAGE_RECEIVER_STATE_OPENING: - return MessageReceiverState::Opening; - default: // LCOV_EXCL_LINE - throw std::logic_error("Unknown message receiver state."); // LCOV_EXCL_LINE - } + receiver->m_eventHandler->OnMessageReceiverStateChanged( + MessageReceiverFactory::CreateFromInternal(receiver->shared_from_this()), + MessageReceiverStateFromLowLevel(newState), + MessageReceiverStateFromLowLevel(oldState)); } - - const char* MESSAGE_RECEIVER_STATEStrings[] = { - "MESSAGE_RECEIVER_STATE_INVALID", - "MESSAGE_RECEIVER_STATE_IDLE", - "MESSAGE_RECEIVER_STATE_OPENING", - "MESSAGE_RECEIVER_STATE_OPEN", - "MESSAGE_RECEIVER_STATE_CLOSING", - "MESSAGE_RECEIVER_STATE_ERROR", - }; - - void MessageReceiverImpl::OnMessageReceiverStateChangedFn( - void const* context, - MESSAGE_RECEIVER_STATE newState, - MESSAGE_RECEIVER_STATE oldState) + else { - auto receiver = static_cast(const_cast(context)); - - if (receiver->m_eventHandler) - { - receiver->m_eventHandler->OnMessageReceiverStateChanged( - receiver->shared_from_this(), - MessageReceiverStateFromLowLevel(newState), - MessageReceiverStateFromLowLevel(oldState)); - } - else - { - std::stringstream ss; - ss << "Message receiver changed state. New: " << MESSAGE_RECEIVER_STATEStrings[newState] - << " Old: " << MESSAGE_RECEIVER_STATEStrings[oldState] << std::endl; - Log::Write(Logger::Level::Verbose, ss.str()); - } + std::stringstream ss; + ss << "Message receiver changed state. New: " << MESSAGE_RECEIVER_STATEStrings[newState] + << " Old: " << MESSAGE_RECEIVER_STATEStrings[oldState] << std::endl; + Log::Write(Logger::Level::Verbose, ss.str()); } + } - void MessageReceiverImpl::Authenticate( - CredentialType type, - std::string const& audience, - std::string const& token, - Azure::Core::Context const& context) + void MessageReceiverImpl::Open(Azure::Core::Context const& context) + { + m_session->AuthenticateIfNeeded(static_cast(m_source.GetAddress()), context); + + // Once we've authenticated the connection, establish the link and receiver. + // We cannot do this before authenticating the client. + if (!m_link) { - Log::Write(Logger::Level::Verbose, "Authenticate token with audience " + audience); - m_claimsBasedSecurity = std::make_unique(m_session); - // Propagate our SetTrace settings to the CBS instance. - m_claimsBasedSecurity->SetTrace(m_options.EnableTrace); - auto openResult = m_claimsBasedSecurity->Open(context); - if (openResult == CbsOpenResult::Ok) - { - m_cbsOpen = true; - Log::Write(Logger::Level::Verbose, "CBS is open, put the token"); - - auto result = m_claimsBasedSecurity->PutToken( - (type == CredentialType::BearerToken ? CbsTokenType::Jwt : CbsTokenType::Sas), - audience, - token, - context); - } - else - { - Log::Write( - Logger::Level::Error, - "Could not open Claims Based Security object. OpenResult: " - + std::to_string(static_cast(openResult))); - throw std::runtime_error("Could not open Claims Based Security."); // LCOV_EXCL_LINE - } + CreateLink(); } - - void MessageReceiverImpl::Open(Azure::Core::Context const& context) + if (m_messageReceiver == nullptr) { - // If we need to authenticate with either ServiceBus or BearerToken, now is the time to do it. - if (m_connectionCredential) - { - auto sasCredential{std::static_pointer_cast< - Azure::Core::Amqp::_internal::ServiceBusSasConnectionStringCredential>( - m_connectionCredential)}; - Authenticate( - CredentialType::ServiceBusSas, - sasCredential->GetEndpoint() + sasCredential->GetEntityPath(), - sasCredential->GenerateSasToken( - std::chrono::system_clock::now() + std::chrono::minutes(60)), - context); - } - else if (m_tokenCredential) - { - Azure::Core::Credentials::TokenRequestContext requestContext; - requestContext.Scopes = m_options.AuthenticationScopes; - - Authenticate( - CredentialType::BearerToken, - m_source, - m_tokenCredential->GetToken(requestContext, context).Token, - context); - } - - // Once we've authenticated the connection, establish the link and receiver. - // We cannot do this before authenticating the client. - if (!m_link) - { - CreateLink(); - } - if (m_messageReceiver == nullptr) - { - m_messageReceiver = messagereceiver_create( - *m_link, MessageReceiverImpl::OnMessageReceiverStateChangedFn, this); - } - - if (messagereceiver_open(m_messageReceiver, MessageReceiverImpl::OnMessageReceivedFn, this)) - { - auto err = errno; // LCOV_EXCL_LINE - throw std::runtime_error( // LCOV_EXCL_LINE - "Could not open message receiver. errno=" + std::to_string(err) // LCOV_EXCL_LINE - + ", \"" // LCOV_EXCL_LINE - + strerror(err) // LCOV_EXCL_LINE - + "\"."); // LCOV_EXCL_LINE - } + m_messageReceiver.reset(messagereceiver_create( + *m_link, MessageReceiverImpl::OnMessageReceiverStateChangedFn, this)); } - void MessageReceiverImpl::Close() + messagereceiver_set_trace(m_messageReceiver.get(), m_options.EnableTrace); + + if (messagereceiver_open( + m_messageReceiver.get(), MessageReceiverImpl::OnMessageReceivedFn, this)) { - if (messagereceiver_close(m_messageReceiver)) - { - throw std::runtime_error("Could not close message receiver"); // LCOV_EXCL_LINE - } + // LCOV_EXCL_START + auto err = errno; + throw std::runtime_error( + "Could not open message receiver. errno=" + std::to_string(err) + ", \"" + strerror(err) + + "\"."); + // LCOV_EXCL_STOP } + } - std::string MessageReceiverImpl::GetLinkName() const + void MessageReceiverImpl::Close() + { + if (messagereceiver_close(m_messageReceiver.get())) { - const char* linkName; - if (messagereceiver_get_link_name(m_messageReceiver, &linkName)) - { - throw std::runtime_error("Could not get link name"); - } - return std::string(linkName); + throw std::runtime_error("Could not close message receiver"); // LCOV_EXCL_LINE } + } - void MessageReceiverImpl::SetTrace(bool traceEnabled) + std::string MessageReceiverImpl::GetLinkName() const + { + const char* linkName; + if (messagereceiver_get_link_name(m_messageReceiver.get(), &linkName)) { - messagereceiver_set_trace(m_messageReceiver, traceEnabled); + throw std::runtime_error("Could not get link name"); } - } // namespace _detail -}}} // namespace Azure::Core::Amqp + return std::string(linkName); + } + +}}}} // namespace Azure::Core::Amqp::_detail diff --git a/sdk/core/azure-core-amqp/src/amqp/message_sender.cpp b/sdk/core/azure-core-amqp/src/amqp/message_sender.cpp index b7738834b1..e55d1052e1 100644 --- a/sdk/core/azure-core-amqp/src/amqp/message_sender.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/message_sender.cpp @@ -9,83 +9,68 @@ #include "private/connection_impl.hpp" #include "private/message_sender_impl.hpp" #include "private/session_impl.hpp" + #include +#include +#include #include + #include -namespace Azure { namespace Core { namespace Amqp { namespace _internal { +using namespace Azure::Core::Diagnostics; +using namespace Azure::Core::Diagnostics::_internal; - MessageSender::MessageSender( - Session const& session, - std::string const& target, - MessageSenderOptions const& options, - MessageSenderEvents* events) - : m_impl{ - std::make_shared<_detail::MessageSenderImpl>(session.GetImpl(), target, options, events)} - { - } - MessageSender::MessageSender( - Session const& session, - LinkEndpoint& endpoint, - std::string const& target, - MessageSenderOptions const& options, - MessageSenderEvents* events) - : m_impl{std::make_shared<_detail::MessageSenderImpl>( - session.GetImpl(), - endpoint, - target, - options, - events)} - { - } +void Azure::Core::_internal::UniqueHandleHelper::FreeMessageSender( + MESSAGE_SENDER_HANDLE value) +{ + messagesender_destroy(value); +} + +namespace Azure { namespace Core { namespace Amqp { namespace _internal { MessageSender::MessageSender( Session const& session, - std::shared_ptr credential, - std::string const& target, + Models::_internal::MessageTarget const& target, MessageSenderOptions const& options, MessageSenderEvents* events) : m_impl{std::make_shared<_detail::MessageSenderImpl>( - session.GetImpl(), - credential, + _detail::SessionFactory::GetImpl(session), target, options, events)} { } - MessageSender::MessageSender( Session const& session, - std::shared_ptr credential, - std::string const& target, + LinkEndpoint& endpoint, + Models::_internal::MessageTarget const& target, MessageSenderOptions const& options, MessageSenderEvents* events) : m_impl{std::make_shared<_detail::MessageSenderImpl>( - session.GetImpl(), - credential, + _detail::SessionFactory::GetImpl(session), + endpoint, target, options, events)} { } - void MessageSender::Open(Azure::Core::Context const& context) { m_impl->Open(context); } + void MessageSender::Open(Context const& context) { m_impl->Open(context); } void MessageSender::Close() { m_impl->Close(); } - std::tuple MessageSender::Send( - Azure::Core::Amqp::Models::AmqpMessage const& message, - Azure::Core::Context context) + std::tuple MessageSender::Send( + Models::AmqpMessage const& message, + Context const& context) { return m_impl->Send(message, context); } void MessageSender::QueueSend( - Azure::Core::Amqp::Models::AmqpMessage const& message, + Models::AmqpMessage const& message, MessageSendCompleteCallback onSendComplete, - Azure::Core::Context context) + Context const& context) { return m_impl->QueueSend(message, onSendComplete, context); } - void MessageSender::SetTrace(bool traceEnabled) { m_impl->SetTrace(traceEnabled); } MessageSender::~MessageSender() noexcept {} }}}} // namespace Azure::Core::Amqp::_internal @@ -94,7 +79,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { MessageSenderImpl::MessageSenderImpl( std::shared_ptr session, - std::string const& target, + Models::_internal::MessageTarget const& target, _internal::MessageSenderOptions const& options, _internal::MessageSenderEvents* events) : m_events{events}, m_session{session}, m_target{target}, m_options{options} @@ -104,39 +89,16 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { MessageSenderImpl::MessageSenderImpl( std::shared_ptr session, _internal::LinkEndpoint& endpoint, - std::string const& target, + Models::_internal::MessageTarget const& target, _internal::MessageSenderOptions const& options, _internal::MessageSenderEvents* events) : m_events{events}, m_session{session}, m_target{target}, m_options{options} { CreateLink(endpoint); - m_messageSender - = messagesender_create(*m_link, MessageSenderImpl::OnMessageSenderStateChangedFn, this); + m_messageSender.reset( + messagesender_create(*m_link, MessageSenderImpl::OnMessageSenderStateChangedFn, this)); - SetTrace(options.EnableTrace); - } - - MessageSenderImpl::MessageSenderImpl( - std::shared_ptr session, - std::shared_ptr<_internal::ServiceBusSasConnectionStringCredential> credential, - std::string const& target, - _internal::MessageSenderOptions const& options, - _internal::MessageSenderEvents* events) - : m_events{events}, m_session{session}, - m_connectionCredential{credential}, m_target{target}, m_options{options} - - { - } - - MessageSenderImpl::MessageSenderImpl( - std::shared_ptr session, - std::shared_ptr credential, - std::string const& target, - _internal::MessageSenderOptions const& options, - _internal::MessageSenderEvents* events) - : m_events{events}, m_session{session}, - m_tokenCredential{credential}, m_target{target}, m_options{options} - { + messagesender_set_trace(m_messageSender.get(), m_options.EnableTrace); } MessageSenderImpl::~MessageSenderImpl() noexcept @@ -147,38 +109,26 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { { m_events = nullptr; } - if (m_claimsBasedSecurity) - { - if (m_cbsOpen) - { - m_claimsBasedSecurity->Close(); - } - } - if (m_messageSender) - { - messagesender_destroy(m_messageSender); - m_messageSender = nullptr; - } } void MessageSenderImpl::CreateLink(_internal::LinkEndpoint& endpoint) { - m_link = std::make_unique<_detail::Link>( + m_link = std::make_shared<_detail::LinkImpl>( m_session, endpoint, m_options.Name, _internal::SessionRole::Receiver, // This is the role of the link, not the endpoint. - m_options.SourceAddress, + m_options.MessageSource, m_target); PopulateLinkProperties(); } void MessageSenderImpl::CreateLink() { - m_link = std::make_unique<_detail::Link>( + m_link = std::make_shared<_detail::LinkImpl>( m_session, m_options.Name, _internal::SessionRole::Sender, // This is the role of the link, not the endpoint. - m_options.SourceAddress, + m_options.MessageSource, m_target); PopulateLinkProperties(); } @@ -202,11 +152,6 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { m_link->SetSenderSettleMode(m_options.SettleMode); } - void MessageSenderImpl::SetTrace(bool traceEnabled) - { - messagesender_set_trace(m_messageSender, traceEnabled); - } - _internal::MessageSenderState MessageSenderStateFromLowLevel(MESSAGE_SENDER_STATE lowLevel) { switch (lowLevel) @@ -237,61 +182,17 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { if (sender->m_events) { sender->m_events->OnMessageSenderStateChanged( - sender->shared_from_this(), + MessageSenderFactory::CreateFromInternal(sender->shared_from_this()), MessageSenderStateFromLowLevel(newState), MessageSenderStateFromLowLevel(oldState)); } } - void MessageSenderImpl::Authenticate( - _internal::CredentialType type, - std::string const& audience, - std::string const& token, - Azure::Core::Context const& context) - { - m_claimsBasedSecurity = std::make_unique(m_session); - if (m_claimsBasedSecurity->Open(context) == CbsOpenResult::Ok) - { - m_cbsOpen = true; - auto result = m_claimsBasedSecurity->PutToken( - (type == _internal::CredentialType::BearerToken ? CbsTokenType::Jwt : CbsTokenType::Sas), - audience, - token, - context); - } - else - { - throw std::runtime_error("Could not put Claims Based Security token."); // LCOV_EXCL_LINE - } - } - - void MessageSenderImpl::Open(Azure::Core::Context const& context) + void MessageSenderImpl::Open(Context const& context) { // If we need to authenticate with either ServiceBus or BearerToken, now is the time to do // it. - if (m_connectionCredential) - { - auto sasCredential{std::static_pointer_cast< - Azure::Core::Amqp::_internal::ServiceBusSasConnectionStringCredential>( - m_connectionCredential)}; - Authenticate( - sasCredential->GetCredentialType(), - sasCredential->GetEndpoint() + sasCredential->GetEntityPath(), - sasCredential->GenerateSasToken( - std::chrono::system_clock::now() + std::chrono::minutes(60)), - context); - } - else if (m_tokenCredential) - { - Azure::Core::Credentials::TokenRequestContext requestContext; - requestContext.Scopes = m_options.AuthenticationScopes; - - Authenticate( - _internal::CredentialType::BearerToken, - m_target, - m_tokenCredential->GetToken(requestContext, context).Token, - context); - } + m_session->AuthenticateIfNeeded(static_cast(m_target.GetAddress()), context); if (m_link == nullptr) { @@ -300,10 +201,10 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { if (m_messageSender == nullptr) { - m_messageSender - = messagesender_create(*m_link, MessageSenderImpl::OnMessageSenderStateChangedFn, this); + m_messageSender.reset( + messagesender_create(*m_link, MessageSenderImpl::OnMessageSenderStateChangedFn, this)); } - if (messagesender_open(m_messageSender)) + if (messagesender_open(m_messageSender.get())) { auto err = errno; // LCOV_EXCL_LINE throw std::runtime_error( // LCOV_EXCL_LINE @@ -314,7 +215,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { } void MessageSenderImpl::Close() { - if (messagesender_close(m_messageSender)) + if (messagesender_close(m_messageSender.get())) { throw std::runtime_error("Could not close message sender"); // LCOV_EXCL_LINE } @@ -327,23 +228,23 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { MESSAGE_SEND_RESULT sendResult, AMQP_VALUE disposition) { - _internal::MessageSendResult result{_internal::MessageSendResult::Ok}; + _internal::MessageSendStatus result{_internal::MessageSendStatus::Ok}; switch (sendResult) { case MESSAGE_SEND_RESULT_INVALID: // LCOV_EXCL_LINE - result = _internal::MessageSendResult::Invalid; // LCOV_EXCL_LINE + result = _internal::MessageSendStatus::Invalid; // LCOV_EXCL_LINE break; // LCOV_EXCL_LINE case MESSAGE_SEND_OK: - result = _internal::MessageSendResult::Ok; + result = _internal::MessageSendStatus::Ok; break; case MESSAGE_SEND_CANCELLED: // LCOV_EXCL_LINE - result = _internal::MessageSendResult::Cancelled; // LCOV_EXCL_LINE + result = _internal::MessageSendStatus::Cancelled; // LCOV_EXCL_LINE break; // LCOV_EXCL_LINE case MESSAGE_SEND_ERROR: // LCOV_EXCL_LINE - result = _internal::MessageSendResult::Error; // LCOV_EXCL_LINE + result = _internal::MessageSendStatus::Error; // LCOV_EXCL_LINE break; // LCOV_EXCL_LINE case MESSAGE_SEND_TIMEOUT: // LCOV_EXCL_LINE - result = _internal::MessageSendResult::Timeout; // LCOV_EXCL_LINE + result = _internal::MessageSendStatus::Timeout; // LCOV_EXCL_LINE break; // LCOV_EXCL_LINE } onComplete(result, disposition); @@ -351,16 +252,16 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { }; void MessageSenderImpl::QueueSend( - Azure::Core::Amqp::Models::AmqpMessage const& message, + Models::AmqpMessage const& message, Azure::Core::Amqp::_internal::MessageSender::MessageSendCompleteCallback onSendComplete, - Azure::Core::Context context) + Context const& context) { auto operation(std::make_unique>>(onSendComplete)); auto result = messagesender_send_async( - m_messageSender, - Azure::Core::Amqp::Models::_internal::AmqpMessageFactory::ToUamqp(message).get(), + m_messageSender.get(), + Models::_internal::AmqpMessageFactory::ToUamqp(message).get(), std::remove_pointer::type::OnOperationFn, operation.release(), 0 /*timeout*/); @@ -371,22 +272,22 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { (void)context; } - std::tuple<_internal::MessageSendResult, Azure::Core::Amqp::Models::AmqpValue> MessageSenderImpl:: - Send(Azure::Core::Amqp::Models::AmqpMessage const& message, Azure::Core::Context context) + std::tuple<_internal::MessageSendStatus, Models::AmqpValue> MessageSenderImpl::Send( + Models::AmqpMessage const& message, + Context const& context) { - Azure::Core::Amqp::Common::_internal::AsyncOperationQueue< - Azure::Core::Amqp::_internal::MessageSendResult, - Azure::Core::Amqp::Models::AmqpValue> - sendCompleteQueue; + Azure::Core::Amqp::Common::_internal:: + AsyncOperationQueue + sendCompleteQueue; QueueSend( message, - [&](Azure::Core::Amqp::_internal::MessageSendResult sendResult, - Azure::Core::Amqp::Models::AmqpValue deliveryStatus) { + [&](Azure::Core::Amqp::_internal::MessageSendStatus sendResult, + Models::AmqpValue deliveryStatus) { sendCompleteQueue.CompleteOperation(sendResult, deliveryStatus); }, context); - auto result = sendCompleteQueue.WaitForPolledResult(context, *m_session->GetConnectionToPoll()); + auto result = sendCompleteQueue.WaitForPolledResult(context, *m_session->GetConnection()); if (result) { return std::move(*result); diff --git a/sdk/core/azure-core-amqp/src/amqp/private/claims_based_security_impl.hpp b/sdk/core/azure-core-amqp/src/amqp/private/claims_based_security_impl.hpp index 20faa7b0bf..43eecb3a4d 100644 --- a/sdk/core/azure-core-amqp/src/amqp/private/claims_based_security_impl.hpp +++ b/sdk/core/azure-core-amqp/src/amqp/private/claims_based_security_impl.hpp @@ -3,6 +3,7 @@ #pragma once #include "azure/core/amqp/claims_based_security.hpp" + #include struct CBS_INSTANCE_TAG; @@ -17,10 +18,10 @@ template <> struct Azure::Core::_internal::UniqueHandleHelper using UniqueAmqpCbsHandle = Azure::Core::_internal::UniqueHandle; namespace Azure { namespace Core { namespace Amqp { namespace _detail { - class ClaimsBasedSecurityImpl { + class ClaimsBasedSecurityImpl final { public: - ClaimsBasedSecurityImpl(std::shared_ptr session); + ClaimsBasedSecurityImpl(std::shared_ptr<_detail::SessionImpl> session); virtual ~ClaimsBasedSecurityImpl() noexcept; // Disable copy and move because the underlying m_cbs takes a reference to this object. @@ -29,18 +30,20 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { ClaimsBasedSecurityImpl(ClaimsBasedSecurityImpl&&) noexcept = delete; ClaimsBasedSecurityImpl& operator=(ClaimsBasedSecurityImpl&&) noexcept = delete; - CbsOpenResult Open(Azure::Core::Context context); + CbsOpenResult Open(Context const& context); void Close(); std::tuple PutToken( CbsTokenType type, std::string const& audience, std::string const& token, - Azure::Core::Context context); + Context const& context); void SetTrace(bool traceEnabled); private: UniqueAmqpCbsHandle m_cbs; std::shared_ptr<_detail::SessionImpl> m_session; + bool m_cbsOpen{false}; + bool m_traceEnabled{false}; Azure::Core::Amqp::Common::_internal::AsyncOperationQueue m_openResultQueue; Azure::Core::Amqp::Common::_internal:: diff --git a/sdk/core/azure-core-amqp/src/amqp/private/connection_impl.hpp b/sdk/core/azure-core-amqp/src/amqp/private/connection_impl.hpp index ab9dafae5d..1bae727957 100644 --- a/sdk/core/azure-core-amqp/src/amqp/private/connection_impl.hpp +++ b/sdk/core/azure-core-amqp/src/amqp/private/connection_impl.hpp @@ -5,8 +5,11 @@ #include "azure/core/amqp/connection.hpp" #include "azure/core/amqp/network/transport.hpp" + #include + #include + #include #include #include @@ -23,15 +26,32 @@ using UniqueAmqpConnection = Azure::Core::_internal::UniqueHandle connectionImpl) + { + return Azure::Core::Amqp::_internal::Connection(connectionImpl); + } + + static std::shared_ptr GetImpl( + Azure::Core::Amqp::_internal::Connection const& connection) + { + return connection.m_impl; + } + }; + class ConnectionImpl final : public std::enable_shared_from_this { public: ConnectionImpl( - std::shared_ptr transport, + std::shared_ptr transport, _internal::ConnectionOptions const& options, _internal::ConnectionEvents* eventHandler); ConnectionImpl( - std::string const& requestUri, + std::string const& hostName, _internal::ConnectionOptions const& options, _internal::ConnectionEvents* eventHandler); @@ -63,48 +83,40 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { void Close( std::string const& condition, std::string const& description, - Azure::Core::Amqp::Models::AmqpValue info); + Models::AmqpValue info); + + void Poll(); - void Poll() const; + std::string GetHost() const { return m_hostName; } + uint16_t GetPort() const { return m_port; } uint32_t GetMaxFrameSize() const; uint32_t GetRemoteMaxFrameSize() const; - void SetMaxFrameSize(uint32_t frameSize); uint16_t GetMaxChannel() const; - void SetMaxChannel(uint16_t frameSize); std::chrono::milliseconds GetIdleTimeout() const; - void SetIdleTimeout(std::chrono::milliseconds timeout); - void SetRemoteIdleTimeoutEmptyFrameSendRatio(double idleTimeoutEmptyFrameSendRatio); - - void SetProperties(Azure::Core::Amqp::Models::AmqpValue properties); - Azure::Core::Amqp::Models::AmqpValue GetProperties() const; - uint64_t HandleDeadlines(); // ??? - _internal::Endpoint CreateEndpoint(); - void StartEndpoint(_internal::Endpoint const& endpoint); + void SetIdleEmptyFrameSendPercentage(double idleTimeoutEmptyFrameSendRatio); - uint16_t GetEndpointIncomingChannel(_internal::Endpoint endpoint); - void DestroyEndpoint(_internal::Endpoint endpoint); - - void SetTrace(bool enableTrace); + void SetProperties(Models::AmqpValue properties); + Models::AmqpMap GetProperties() const; private: std::shared_ptr m_transport; UniqueAmqpConnection m_connection{}; std::string m_hostName; + uint16_t m_port; std::string m_containerId; _internal::ConnectionOptions m_options; Azure::Core::Amqp::Common::_internal::AsyncOperationQueue> m_newSessionQueue; _internal::ConnectionEvents* m_eventHandler{}; - _internal::CredentialType m_credentialType; - std::shared_ptr<_internal::ConnectionStringCredential> m_credential{}; - std::shared_ptr m_tokenCredential{}; + _internal::ConnectionState m_connectionState = _internal::ConnectionState::Start; ConnectionImpl( _internal::ConnectionEvents* eventHandler, - _internal::CredentialType credentialType, _internal::ConnectionOptions const& options); + void SetState(_internal::ConnectionState newState) { m_connectionState = newState; } + static void OnEndpointFrameReceivedFn( void* context, AMQP_VALUE value, @@ -116,6 +128,6 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { CONNECTION_STATE oldState); // Note: We cannot take ownership of this instance tag. static bool OnNewEndpointFn(void* context, ENDPOINT_HANDLE endpoint); - static void OnIoErrorFn(void* context); + static void OnIOErrorFn(void* context); }; }}}} // namespace Azure::Core::Amqp::_detail diff --git a/sdk/core/azure-core-amqp/src/amqp/private/link_impl.hpp b/sdk/core/azure-core-amqp/src/amqp/private/link_impl.hpp index f150654b2c..40cca22ff9 100644 --- a/sdk/core/azure-core-amqp/src/amqp/private/link_impl.hpp +++ b/sdk/core/azure-core-amqp/src/amqp/private/link_impl.hpp @@ -4,7 +4,11 @@ #pragma once #include "azure/core/amqp/models/amqp_value.hpp" +#include "azure/core/amqp/models/message_source.hpp" +#include "azure/core/amqp/models/message_target.hpp" + #include + #include #include #include @@ -18,15 +22,15 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { std::shared_ptr<_detail::SessionImpl> session, std::string const& name, _internal::SessionRole role, - std::string const& source, - std::string const& target); + Models::_internal::MessageSource const& source, + Models::_internal::MessageTarget const& target); LinkImpl( std::shared_ptr<_detail::SessionImpl> session, _internal::LinkEndpoint& linkEndpoint, std::string const& name, _internal::SessionRole role, - std::string const& source, - std::string const& target); + Models::_internal::MessageSource const& source, + Models::_internal::MessageTarget const& target); ~LinkImpl() noexcept; LinkImpl(LinkImpl const&) = delete; @@ -50,13 +54,13 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { uint64_t GetPeerMaxMessageSize() const; - void SetAttachProperties(Azure::Core::Amqp::Models::AmqpValue attachProperties); + void SetAttachProperties(Models::AmqpValue attachProperties); void SetMaxLinkCredit(uint32_t maxLinkCredit); std::string GetName() const; - std::string const& GetTarget() const; - std::string const& GetSource() const; + Models::_internal::MessageTarget const& GetTarget() const; + Models::_internal::MessageSource const& GetSource() const; uint32_t GetReceivedMessageId() const; @@ -68,13 +72,13 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { bool close, std::string const& errorCondition, std::string const& errorDescription, - Azure::Core::Amqp::Models::AmqpValue& info); + Models::AmqpValue& info); private: LINK_HANDLE m_link; std::shared_ptr<_detail::SessionImpl> m_session; - std::string m_source; - std::string m_target; + Models::_internal::MessageSource m_source; + Models::_internal::MessageTarget m_target; #if 0 MOCKABLE_FUNCTION(, int, link_send_disposition, LINK_HANDLE, link, delivery_number, message_number, AMQP_VALUE, delivery_state); diff --git a/sdk/core/azure-core-amqp/src/amqp/private/management_impl.hpp b/sdk/core/azure-core-amqp/src/amqp/private/management_impl.hpp index 4145e9b286..f39ed66e1b 100644 --- a/sdk/core/azure-core-amqp/src/amqp/private/management_impl.hpp +++ b/sdk/core/azure-core-amqp/src/amqp/private/management_impl.hpp @@ -11,7 +11,9 @@ #include "session_impl.hpp" #include + #include + #include #include @@ -32,7 +34,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { public: ManagementImpl( std::shared_ptr session, - std::string const& managementNodeName, + std::string const& managementEntityName, _internal::ManagementOptions const& options, _internal::ManagementEvents* managementEvents); @@ -44,7 +46,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { * @returns A tuple consisting of the status code for the open and the description of the * status. */ - _internal::ManagementOpenStatus Open(Azure::Core::Context const& context = {}); + _internal::ManagementOpenStatus Open(Context const& context = {}); /** * @brief Close the management instance. @@ -55,11 +57,12 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { std::string const& operationToPerform, std::string const& typeOfOperation, std::string const& locales, - Azure::Core::Amqp::Models::AmqpMessage const& messageToSend, - Azure::Core::Context context); + Models::AmqpMessage messageToSend, + Context const& context); private: UniqueAmqpManagementHandle m_management{}; + std::string m_managementNodeName; _internal::ManagementOptions m_options; std::string m_source; std::shared_ptr m_session; diff --git a/sdk/core/azure-core-amqp/src/amqp/private/message_receiver_impl.hpp b/sdk/core/azure-core-amqp/src/amqp/private/message_receiver_impl.hpp index 478e3e5545..68302f08ea 100644 --- a/sdk/core/azure-core-amqp/src/amqp/private/message_receiver_impl.hpp +++ b/sdk/core/azure-core-amqp/src/amqp/private/message_receiver_impl.hpp @@ -6,40 +6,51 @@ #include "azure/core/amqp/message_receiver.hpp" #include "claims_based_security_impl.hpp" #include "connection_impl.hpp" +#include "link_impl.hpp" #include "message_receiver_impl.hpp" #include "session_impl.hpp" #include + #include #include #include + #include #include +template <> struct Azure::Core::_internal::UniqueHandleHelper +{ + static void FreeMessageReceiver(MESSAGE_RECEIVER_HANDLE obj); + + using type = Azure::Core::_internal:: + BasicUniqueHandle; +}; + namespace Azure { namespace Core { namespace Amqp { namespace _detail { + + using UniqueMessageReceiver = Azure::Core::_internal::UniqueHandle; + + class MessageReceiverFactory final { + public: + static Azure::Core::Amqp::_internal::MessageReceiver CreateFromInternal( + std::shared_ptr receiverImpl) + { + return Azure::Core::Amqp::_internal::MessageReceiver(receiverImpl); + } + }; + class MessageReceiverImpl final : public std::enable_shared_from_this { public: MessageReceiverImpl( std::shared_ptr<_detail::SessionImpl> session, - std::string const& receiverSource, - _internal::MessageReceiverOptions const& options, - _internal::MessageReceiverEvents* receiverEvents = nullptr); - MessageReceiverImpl( - std::shared_ptr<_detail::SessionImpl> session, - std::shared_ptr<_internal::ConnectionStringCredential> credentials, - std::string const& receiverSource, - _internal::MessageReceiverOptions const& options, - _internal::MessageReceiverEvents* receiverEvents = nullptr); - MessageReceiverImpl( - std::shared_ptr<_detail::SessionImpl> session, - std::shared_ptr credentials, - std::string const& receiverSource, + Models::_internal::MessageSource const& receiverSource, _internal::MessageReceiverOptions const& options, _internal::MessageReceiverEvents* receiverEvents = nullptr); MessageReceiverImpl( std::shared_ptr<_detail::SessionImpl> session, _internal::LinkEndpoint& linkEndpoint, - std::string const& receiverSource, + Models::_internal::MessageSource const& receiverSource, _internal::MessageReceiverOptions const& options, _internal::MessageReceiverEvents* receiverEvents = nullptr); ~MessageReceiverImpl() noexcept; @@ -51,24 +62,21 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { operator bool() const { return (m_messageReceiver != nullptr); } - void Open(Azure::Core::Context const& context); + void Open(Context const& context); void Close(); std::string GetLinkName() const; - std::string GetSourceName() const { return m_source; } + std::string GetSourceName() const { return static_cast(m_source.GetAddress()); } uint32_t GetReceivedMessageId(); void SendMessageDisposition( const char* linkName, uint32_t messageNumber, - Azure::Core::Amqp::Models::AmqpValue deliveryState); - void SetTrace(bool traceEnabled); + Models::AmqpValue deliveryState); template - Azure::Core::Amqp::Models::AmqpMessage WaitForIncomingMessage( - Azure::Core::Context context, - Waiters&... waiters) + Models::AmqpMessage WaitForIncomingMessage(Context const& context, Waiters&... waiters) { - auto result = m_messageQueue.WaitForPolledResult( - context, *m_session->GetConnectionToPoll(), waiters...); + auto result + = m_messageQueue.WaitForPolledResult(context, *m_session->GetConnection(), waiters...); if (result) { return std::move(std::get<0>(*result)); @@ -77,26 +85,19 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { } private: - MESSAGE_RECEIVER_HANDLE m_messageReceiver{}; - std::unique_ptr<_detail::Link> m_link; + UniqueMessageReceiver m_messageReceiver{}; + std::shared_ptr<_detail::LinkImpl> m_link; _internal::MessageReceiverOptions m_options; - std::string m_source; + Models::_internal::MessageSource m_source; std::shared_ptr<_detail::SessionImpl> m_session; - std::shared_ptr<_internal::ConnectionStringCredential> m_connectionCredential; - std::shared_ptr m_tokenCredential; - std::unique_ptr m_claimsBasedSecurity; - bool m_cbsOpen{false}; - Azure::Core::Amqp::Common::_internal::AsyncOperationQueue< - Azure::Core::Amqp::Models::AmqpMessage> - m_messageQueue; + Azure::Core::Amqp::Common::_internal::AsyncOperationQueue m_messageQueue; _internal::MessageReceiverEvents* m_eventHandler{}; static AMQP_VALUE OnMessageReceivedFn(const void* context, MESSAGE_HANDLE message); - virtual Azure::Core::Amqp::Models::AmqpValue OnMessageReceived( - Azure::Core::Amqp::Models::AmqpMessage message); + virtual Models::AmqpValue OnMessageReceived(Models::AmqpMessage message); static void OnMessageReceiverStateChangedFn( const void* context, @@ -106,11 +107,5 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { void CreateLink(); void CreateLink(_internal::LinkEndpoint& endpoint); void PopulateLinkProperties(); - - void Authenticate( - _internal::CredentialType type, - std::string const& audience, - std::string const& token, - Azure::Core::Context const& context); }; }}}} // namespace Azure::Core::Amqp::_detail diff --git a/sdk/core/azure-core-amqp/src/amqp/private/message_sender_impl.hpp b/sdk/core/azure-core-amqp/src/amqp/private/message_sender_impl.hpp index 01b465246a..ca2c46fff4 100644 --- a/sdk/core/azure-core-amqp/src/amqp/private/message_sender_impl.hpp +++ b/sdk/core/azure-core-amqp/src/amqp/private/message_sender_impl.hpp @@ -5,34 +5,43 @@ #include "azure/core/amqp/message_sender.hpp" #include "claims_based_security_impl.hpp" +#include "link_impl.hpp" + #include + #include +template <> struct Azure::Core::_internal::UniqueHandleHelper +{ + static void FreeMessageSender(MESSAGE_SENDER_HANDLE obj); + + using type + = Azure::Core::_internal::BasicUniqueHandle; +}; + namespace Azure { namespace Core { namespace Amqp { namespace _detail { + using UniqueMessageSender = Azure::Core::_internal::UniqueHandle; + + class MessageSenderFactory final { + public: + static Azure::Core::Amqp::_internal::MessageSender CreateFromInternal( + std::shared_ptr senderImpl) + { + return Azure::Core::Amqp::_internal::MessageSender(senderImpl); + } + }; class MessageSenderImpl : public std::enable_shared_from_this { public: MessageSenderImpl( std::shared_ptr<_detail::SessionImpl> session, - std::string const& target, + Models::_internal::MessageTarget const& target, _internal::MessageSenderOptions const& options, _internal::MessageSenderEvents* events); MessageSenderImpl( std::shared_ptr<_detail::SessionImpl> session, _internal::LinkEndpoint& endpoint, - std::string const& target, - _internal::MessageSenderOptions const& options, - _internal::MessageSenderEvents* events); - MessageSenderImpl( - std::shared_ptr<_detail::SessionImpl> session, - std::shared_ptr<_internal::ServiceBusSasConnectionStringCredential> credential, - std::string const& target, - _internal::MessageSenderOptions const& options, - _internal::MessageSenderEvents* events); - MessageSenderImpl( - std::shared_ptr<_detail::SessionImpl> session, - std::shared_ptr credential, - std::string const& target, + Models::_internal::MessageTarget const& target, _internal::MessageSenderOptions const& options, _internal::MessageSenderEvents* events); virtual ~MessageSenderImpl() noexcept; @@ -42,16 +51,15 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { MessageSenderImpl(MessageSenderImpl&&) noexcept = delete; MessageSenderImpl& operator=(MessageSenderImpl&&) noexcept = delete; - void Open(Azure::Core::Context const& context); + void Open(Context const& context); void Close(); - std::tuple<_internal::MessageSendResult, Azure::Core::Amqp::Models::AmqpValue> Send( - Azure::Core::Amqp::Models::AmqpMessage const& message, - Azure::Core::Context context); + std::tuple<_internal::MessageSendStatus, Models::AmqpValue> Send( + Models::AmqpMessage const& message, + Context const& context); void QueueSend( - Azure::Core::Amqp::Models::AmqpMessage const& message, + Models::AmqpMessage const& message, Azure::Core::Amqp::_internal::MessageSender::MessageSendCompleteCallback onSendComplete, - Azure::Core::Context context); - void SetTrace(bool traceEnabled); + Context const& context); private: static void OnMessageSenderStateChangedFn( @@ -59,29 +67,18 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { MESSAGE_SENDER_STATE newState, MESSAGE_SENDER_STATE oldState); - void Authenticate( - _internal::CredentialType type, - std::string const& audience, - std::string const& token, - Azure::Core::Context const& context); void CreateLink(); void CreateLink(_internal::LinkEndpoint& endpoint); void PopulateLinkProperties(); - MESSAGE_SENDER_HANDLE m_messageSender{}; - std::unique_ptr<_detail::Link> m_link; + UniqueMessageSender m_messageSender{}; + std::shared_ptr<_detail::LinkImpl> m_link; _internal::MessageSenderEvents* m_events; - Azure::Core::Amqp::Common::_internal::AsyncOperationQueue< - Azure::Core::Amqp::Models::AmqpMessage> - m_messageQueue; + Azure::Core::Amqp::Common::_internal::AsyncOperationQueue m_messageQueue; std::shared_ptr<_detail::SessionImpl> m_session; - std::shared_ptr<_internal::ConnectionStringCredential> m_connectionCredential; - std::shared_ptr m_tokenCredential; - std::unique_ptr m_claimsBasedSecurity; - std::string m_target; + Models::_internal::MessageTarget m_target; _internal::MessageSenderOptions m_options; - bool m_cbsOpen{false}; }; }}}} // namespace Azure::Core::Amqp::_detail diff --git a/sdk/core/azure-core-amqp/src/amqp/private/session_impl.hpp b/sdk/core/azure-core-amqp/src/amqp/private/session_impl.hpp index 54a9c8e6ea..3aa91faca5 100644 --- a/sdk/core/azure-core-amqp/src/amqp/private/session_impl.hpp +++ b/sdk/core/azure-core-amqp/src/amqp/private/session_impl.hpp @@ -4,13 +4,14 @@ #pragma once #include "azure/core/amqp/session.hpp" + +#include + #include #include #include #include -#include - template <> struct Azure::Core::_internal::UniqueHandleHelper { static void FreeAmqpSession(SESSION_HANDLE obj); @@ -22,14 +23,32 @@ using UniqueAmqpSession = Azure::Core::_internal::UniqueHandle sessionImpl) + { + return Azure::Core::Amqp::_internal::Session(sessionImpl); + } + + static std::shared_ptr GetImpl( + Azure::Core::Amqp::_internal::Session const& session) + { + return session.m_impl; + } + }; + class SessionImpl final : public std::enable_shared_from_this { public: SessionImpl( std::shared_ptr<_detail::ConnectionImpl> parentConnection, _internal::Endpoint& newEndpoint, + _internal::SessionOptions const& options, _internal::SessionEvents* eventHandler); SessionImpl( std::shared_ptr<_detail::ConnectionImpl> parentConnection, + std::shared_ptr tokenCredential, + _internal::SessionOptions const& options, _internal::SessionEvents* eventHandler); ~SessionImpl() noexcept; @@ -39,25 +58,34 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail { SessionImpl& operator=(SessionImpl&&) noexcept = delete; operator SESSION_HANDLE() const { return m_session.get(); } - std::shared_ptr GetConnectionToPoll() const { return m_connectionToPoll; } + std::shared_ptr GetConnection() const { return m_connectionToPoll; } - void SetIncomingWindow(uint32_t incomingWindow); uint32_t GetIncomingWindow(); - void SetOutgoingWindow(uint32_t outgoingWindow); uint32_t GetOutgoingWindow(); - void SetHandleMax(uint32_t handleMax); uint32_t GetHandleMax(); void Begin(); void End(std::string const& condition_value, std::string const& description); + void AuthenticateIfNeeded(std::string const& audience, Context const& context); + std::string GetSecurityToken(std::string const& audience) const; + private: SessionImpl(); std::shared_ptr<_detail::ConnectionImpl> m_connectionToPoll; UniqueAmqpSession m_session; + _internal::SessionOptions m_options; _internal::SessionEvents* m_eventHandler{}; + std::shared_ptr m_credential{}; + std::shared_ptr m_claimsBasedSecurity{}; + std::map m_tokenStore; + bool m_cbsOpen{false}; - // Common::AsyncOperationQueue> m_newLinkAttachedQueue; + void Authenticate( + bool isSasToken, + Credentials::TokenRequestContext const& requestContext, + std::string const& audience, + Context const& context); static bool OnLinkAttachedFn( void* context, diff --git a/sdk/core/azure-core-amqp/src/amqp/session.cpp b/sdk/core/azure-core-amqp/src/amqp/session.cpp index b8b61af5f5..da1b70044b 100644 --- a/sdk/core/azure-core-amqp/src/amqp/session.cpp +++ b/sdk/core/azure-core-amqp/src/amqp/session.cpp @@ -2,198 +2,312 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/session.hpp" + #include "azure/core/amqp/connection.hpp" #include "azure/core/amqp/link.hpp" +#include "private/claims_based_security_impl.hpp" #include "private/connection_impl.hpp" #include "private/session_impl.hpp" +#include +#include + #include +using namespace Azure::Core::Diagnostics::_internal; +using namespace Azure::Core::Diagnostics; + void Azure::Core::_internal::UniqueHandleHelper::FreeAmqpSession( SESSION_HANDLE value) { session_destroy(value); } -namespace Azure { namespace Core { namespace Amqp { - namespace _internal { - Endpoint::~Endpoint() +namespace Azure { namespace Core { namespace Amqp { namespace _internal { + Endpoint::~Endpoint() + { + if (m_endpoint) { - if (m_endpoint) - { - connection_destroy_endpoint(m_endpoint); - } + connection_destroy_endpoint(m_endpoint); } + } - Session::Session( - Connection const& parentConnection, - Endpoint& newEndpoint, - SessionEvents* eventHandler) - : m_impl{std::make_shared( - parentConnection.GetImpl(), - newEndpoint, - eventHandler)} - { - } + Session::Session( + Connection const& parentConnection, + Endpoint& newEndpoint, + SessionOptions const& options, + SessionEvents* eventHandler) + : m_impl{std::make_shared<_detail::SessionImpl>( + _detail::ConnectionFactory::GetImpl(parentConnection), + newEndpoint, + options, + eventHandler)} + { + } - Session::Session(Connection const& parentConnection, SessionEvents* eventHandler) - : m_impl{std::make_shared( - parentConnection.GetImpl(), - eventHandler)} - { - } + Session::Session( + Connection const& parentConnection, + std::shared_ptr tokenCredential, + SessionOptions const& options, + SessionEvents* eventHandler) + : m_impl{std::make_shared<_detail::SessionImpl>( + _detail::ConnectionFactory::GetImpl(parentConnection), + tokenCredential, + options, + eventHandler)} + { + } - Session::~Session() noexcept {} + Session::~Session() noexcept {} - void Session::SetIncomingWindow(uint32_t incomingWindow) - { - m_impl->SetIncomingWindow(incomingWindow); - } - uint32_t Session::GetIncomingWindow() const { return m_impl->GetIncomingWindow(); } - void Session::SetOutgoingWindow(uint32_t outgoingWindow) - { - m_impl->SetOutgoingWindow(outgoingWindow); - } - uint32_t Session::GetOutgoingWindow() const { return m_impl->GetOutgoingWindow(); } - void Session::SetHandleMax(uint32_t handleMax) { m_impl->SetHandleMax(handleMax); } - uint32_t Session::GetHandleMax() const { return m_impl->GetHandleMax(); } + uint32_t Session::GetIncomingWindow() const { return m_impl->GetIncomingWindow(); } + uint32_t Session::GetOutgoingWindow() const { return m_impl->GetOutgoingWindow(); } + uint32_t Session::GetHandleMax() const { return m_impl->GetHandleMax(); } - void Session::Begin() { m_impl->Begin(); } - void Session::End(std::string const& condition_value, std::string const& description) - { - m_impl->End(condition_value, description); - } - } // namespace _internal + void Session::Begin() { m_impl->Begin(); } + void Session::End(std::string const& condition_value, std::string const& description) + { + m_impl->End(condition_value, description); + } +}}}} // namespace Azure::Core::Amqp::_internal - namespace _detail { +namespace Azure { namespace Core { namespace Amqp { namespace _detail { - SessionImpl::~SessionImpl() noexcept {} + SessionImpl::~SessionImpl() noexcept {} - SessionImpl::SessionImpl( - std::shared_ptr<_detail::ConnectionImpl> connection, - _internal::Endpoint& endpoint, - _internal::SessionEvents* eventHandler) - : m_connectionToPoll(connection), m_session{session_create_from_endpoint( - *connection, - endpoint.Release(), - SessionImpl::OnLinkAttachedFn, - this)}, - m_eventHandler{eventHandler} + SessionImpl::SessionImpl( + std::shared_ptr<_detail::ConnectionImpl> connection, + _internal::Endpoint& endpoint, + _internal::SessionOptions const& options, + _internal::SessionEvents* eventHandler) + : m_connectionToPoll(connection), m_session{session_create_from_endpoint( + *connection, + EndpointFactory::Release(endpoint), + SessionImpl::OnLinkAttachedFn, + this)}, + m_options{options}, m_eventHandler{eventHandler} + { + if (options.MaximumLinkCount.HasValue()) { - } - - SessionImpl::SessionImpl( - std::shared_ptr<_detail::ConnectionImpl> connection, - _internal::SessionEvents* eventHandler) - : m_connectionToPoll(connection), - m_session{session_create(*connection, SessionImpl::OnLinkAttachedFn, this)}, - m_eventHandler{eventHandler} - - { - } - - void SessionImpl::SetIncomingWindow(uint32_t window) - { - if (session_set_incoming_window(m_session.get(), window)) + if (session_set_handle_max(m_session.get(), options.MaximumLinkCount.Value())) { - throw std::runtime_error("Could not set incoming window"); // LCOV_EXCL_LINE + throw std::runtime_error("Could not set handle max."); // LCOV_EXCL_LINE } } - uint32_t SessionImpl::GetIncomingWindow() + if (options.InitialIncomingWindowSize.HasValue()) { - uint32_t window; - if (session_get_incoming_window(m_session.get(), &window)) + if (session_set_incoming_window(m_session.get(), options.InitialIncomingWindowSize.Value())) { - throw std::runtime_error("Could not get incoming window"); // LCOV_EXCL_LINE + throw std::runtime_error("Could not set incoming window"); // LCOV_EXCL_LINE } - return window; } - - void SessionImpl::SetOutgoingWindow(uint32_t window) + if (options.InitialOutgoingWindowSize.HasValue()) { - if (session_set_outgoing_window(m_session.get(), window)) + if (session_set_outgoing_window(m_session.get(), options.InitialOutgoingWindowSize.Value())) { throw std::runtime_error("Could not set outgoing window"); // LCOV_EXCL_LINE } } + } - uint32_t SessionImpl::GetOutgoingWindow() + SessionImpl::SessionImpl( + std::shared_ptr<_detail::ConnectionImpl> connection, + std::shared_ptr tokenCredential, + _internal::SessionOptions const& options, + _internal::SessionEvents* eventHandler) + : m_connectionToPoll(connection), + m_session{session_create(*connection, SessionImpl::OnLinkAttachedFn, this)}, + m_options{options}, m_eventHandler{eventHandler}, m_credential{tokenCredential} + + { + if (options.MaximumLinkCount.HasValue()) { - uint32_t window; - if (session_get_outgoing_window(m_session.get(), &window)) + if (session_set_handle_max(m_session.get(), options.MaximumLinkCount.Value())) { - throw std::runtime_error("Could not get outgoing window"); // LCOV_EXCL_LINE + throw std::runtime_error("Could not set handle max."); // LCOV_EXCL_LINE } - return window; } - - void SessionImpl::SetHandleMax(uint32_t max) + if (options.InitialIncomingWindowSize.HasValue()) { - if (session_set_handle_max(m_session.get(), max)) + if (session_set_incoming_window(m_session.get(), options.InitialIncomingWindowSize.Value())) { - throw std::runtime_error("Could not set handle max."); // LCOV_EXCL_LINE + throw std::runtime_error("Could not set incoming window"); // LCOV_EXCL_LINE } } - uint32_t SessionImpl::GetHandleMax() + if (options.InitialOutgoingWindowSize.HasValue()) { - uint32_t max; - if (session_get_handle_max(m_session.get(), &max)) + if (session_set_outgoing_window(m_session.get(), options.InitialOutgoingWindowSize.Value())) { - throw std::runtime_error("Could not get handle max."); // LCOV_EXCL_LINE + throw std::runtime_error("Could not set outgoing window"); // LCOV_EXCL_LINE } - return max; } + } - void SessionImpl::Begin() + uint32_t SessionImpl::GetIncomingWindow() + { + uint32_t window; + if (session_get_incoming_window(m_session.get(), &window)) { - if (session_begin(m_session.get())) - { - throw std::runtime_error("Could not begin session"); // LCOV_EXCL_LINE - } + throw std::runtime_error("Could not get incoming window"); // LCOV_EXCL_LINE + } + return window; + } + + uint32_t SessionImpl::GetOutgoingWindow() + { + uint32_t window; + if (session_get_outgoing_window(m_session.get(), &window)) + { + throw std::runtime_error("Could not get outgoing window"); // LCOV_EXCL_LINE } - void SessionImpl::End(const std::string& condition, const std::string& description) + return window; + } + + uint32_t SessionImpl::GetHandleMax() + { + uint32_t max; + if (session_get_handle_max(m_session.get(), &max)) + { + throw std::runtime_error("Could not get handle max."); // LCOV_EXCL_LINE + } + return max; + } + + void SessionImpl::Begin() + { + if (session_begin(m_session.get())) + { + throw std::runtime_error("Could not begin session"); // LCOV_EXCL_LINE + } + } + void SessionImpl::End(const std::string& condition, const std::string& description) + { + // When we end the session, it clears all the links, so we need to ensure that the + // m_newLinkAttachedQueue.Clear(); + if (session_end( + m_session.get(), + condition.empty() ? nullptr : condition.c_str(), + description.empty() ? nullptr : description.c_str())) + { + throw std::runtime_error("Could not begin session"); // LCOV_EXCL_LINE + } + } + + void SessionImpl::AuthenticateIfNeeded(std::string const& audience, Context const& context) + { + if (m_credential) { - // When we end the session, it clears all the links, so we need to ensure that the - // m_newLinkAttachedQueue.Clear(); - if (session_end( - m_session.get(), - condition.empty() ? nullptr : condition.c_str(), - description.empty() ? nullptr : description.c_str())) + bool isSasToken + = m_credential->GetCredentialName() == "ServiceBusSasConnectionStringCredential"; + Credentials::TokenRequestContext requestContext; + if (isSasToken) { - throw std::runtime_error("Could not begin session"); // LCOV_EXCL_LINE + requestContext.MinimumExpiration = std::chrono::minutes(60); } + requestContext.Scopes = m_options.AuthenticationScopes; + std::string tokenAudience = audience; + // If the caller provided a URL, use that url, otherwise build the URL to be used. + if ((audience.find("amqps://") != 0) && (audience.find("amqp://") != 0)) + { + tokenAudience = "amqps://" + m_connectionToPoll->GetHost() + "/" + audience; + } + Authenticate(isSasToken, requestContext, tokenAudience, context); } - - bool SessionImpl::OnLinkAttachedFn( - void* context, - LINK_ENDPOINT_INSTANCE_TAG* newLinkEndpoint, - const char* name, - bool role, - AMQP_VALUE_DATA_TAG* source, - AMQP_VALUE_DATA_TAG* target, - AMQP_VALUE_DATA_TAG* properties) + } + void SessionImpl::Authenticate( + bool isSasToken, + Credentials::TokenRequestContext const& tokenRequestContext, + std::string const& audience, + Context const& context) + { + if (m_credential) { - SessionImpl* session = static_cast(context); - _internal::LinkEndpoint linkEndpoint(newLinkEndpoint); - if (session->m_eventHandler) + m_claimsBasedSecurity = std::make_shared(shared_from_this()); + auto accessToken = m_credential->GetToken(tokenRequestContext, context); + Log::Write( + Logger::Level::Informational, + "Authenticate with audience: " + audience + ", token: " + accessToken.Token); + m_claimsBasedSecurity->SetTrace(true); + if (m_claimsBasedSecurity->Open(context) == CbsOpenResult::Ok) { - return session->m_eventHandler->OnLinkAttached( - session->shared_from_this(), - linkEndpoint, - name, - role == role_receiver ? Azure::Core::Amqp::_internal::SessionRole::Receiver - : Azure::Core::Amqp::_internal::SessionRole::Sender, - source, - target, - properties); + m_cbsOpen = true; + auto result = m_claimsBasedSecurity->PutToken( + (isSasToken ? CbsTokenType::Sas : CbsTokenType::Jwt), + audience, + accessToken.Token, + context); + if (std::get<0>(result) == CbsOperationResult::Ok) + { + m_tokenStore.emplace(std::make_pair(audience, accessToken)); + } } else { - // Even if we don't have any actions to take, if we return false, the connection will be - // aborted. - return true; + throw std::runtime_error("Could not put Claims Based Security token."); // LCOV_EXCL_LINE + } + } + } + + std::string SessionImpl::GetSecurityToken(std::string const& audience) const + { + if (m_credential) + { + if (m_tokenStore.find(audience) == m_tokenStore.end()) + { + Credentials::TokenRequestContext requestContext; + bool isSasToken + = m_credential->GetCredentialName() == "ServiceBusSasConnectionStringCredential"; + if (isSasToken) + { + requestContext.MinimumExpiration = std::chrono::minutes(60); + } + requestContext.Scopes = m_options.AuthenticationScopes; + return m_credential->GetToken(requestContext, {}).Token; } - static_cast(role); + return m_tokenStore.at(audience).Token; } - } // namespace _detail -}}} // namespace Azure::Core::Amqp + return ""; + } + + bool SessionImpl::OnLinkAttachedFn( + void* context, + LINK_ENDPOINT_INSTANCE_TAG* newLinkEndpoint, + const char* name, + bool role, + AMQP_VALUE_DATA_TAG* source, + AMQP_VALUE_DATA_TAG* target, + AMQP_VALUE_DATA_TAG* properties) + { + SessionImpl* session = static_cast(context); + _internal::LinkEndpoint linkEndpoint(LinkEndpointFactory::CreateLinkEndpoint(newLinkEndpoint)); + if (session->m_eventHandler) + { + return session->m_eventHandler->OnLinkAttached( + _detail::SessionFactory::CreateFromInternal(session->shared_from_this()), + linkEndpoint, + name, + role == role_receiver ? Azure::Core::Amqp::_internal::SessionRole::Receiver + : Azure::Core::Amqp::_internal::SessionRole::Sender, + source, + target, + properties); + } + else + { + // Even if we don't have any actions to take, if we return false, the connection will be + // aborted. + return true; + } + static_cast(role); + } + + _internal::Endpoint EndpointFactory::CreateEndpoint(ENDPOINT_HANDLE endpoint) + { + return _internal::Endpoint(endpoint); + } + _internal::LinkEndpoint LinkEndpointFactory::CreateLinkEndpoint(LINK_ENDPOINT_HANDLE endpoint) + { + return _internal::LinkEndpoint(endpoint); + } + +}}}} // namespace Azure::Core::Amqp::_detail diff --git a/sdk/core/azure-core-amqp/src/common/global_state.cpp b/sdk/core/azure-core-amqp/src/common/global_state.cpp index 547fbe4612..17596f0e11 100644 --- a/sdk/core/azure-core-amqp/src/common/global_state.cpp +++ b/sdk/core/azure-core-amqp/src/common/global_state.cpp @@ -4,10 +4,13 @@ // cspell: words xlogging #include "azure/core/amqp/common/global_state.hpp" + #include #include + #include #include + #include #include #include @@ -61,7 +64,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Common { namespace { ss << "File: " << file << ":" << line << " Func: " << func << ": "; } - char outputBuffer[512]; + char outputBuffer[2048]; va_list args; va_start(args, format); vsnprintf(outputBuffer, sizeof(outputBuffer), format, args); diff --git a/sdk/core/azure-core-amqp/src/models/amqp_header.cpp b/sdk/core/azure-core-amqp/src/models/amqp_header.cpp index cead4369dd..4498e30777 100644 --- a/sdk/core/azure-core-amqp/src/models/amqp_header.cpp +++ b/sdk/core/azure-core-amqp/src/models/amqp_header.cpp @@ -2,11 +2,13 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/models/amqp_header.hpp" + #include "azure/core/amqp/models/amqp_value.hpp" #include #include + #include #include @@ -135,7 +137,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { { auto handle = _internal::MessageHeaderFactory::ToUamqp(header); AmqpValue headerAsValue{amqpvalue_create_header(handle.get())}; - return Azure::Core::Amqp::Models::AmqpValue::Serialize(headerAsValue); + return Models::AmqpValue::Serialize(headerAsValue); } MessageHeader MessageHeader::Deserialize(std::uint8_t const* data, size_t size) diff --git a/sdk/core/azure-core-amqp/src/models/amqp_message.cpp b/sdk/core/azure-core-amqp/src/models/amqp_message.cpp index 862b19b74c..0084bf3583 100644 --- a/sdk/core/azure-core-amqp/src/models/amqp_message.cpp +++ b/sdk/core/azure-core-amqp/src/models/amqp_message.cpp @@ -2,6 +2,7 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/models/amqp_message.hpp" + #include "azure/core/amqp/models/amqp_header.hpp" #include "azure/core/amqp/models/amqp_protocol.hpp" #include "azure/core/amqp/models/amqp_value.hpp" @@ -10,6 +11,7 @@ #include #include #include + #include #include @@ -486,7 +488,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { } namespace { - class AmqpMessageDeserializer { + class AmqpMessageDeserializer final { public: AmqpMessageDeserializer() : m_decoder{amqpvalue_decoder_create(OnAmqpMessageFieldDecodedFn, this)} diff --git a/sdk/core/azure-core-amqp/src/models/amqp_properties.cpp b/sdk/core/azure-core-amqp/src/models/amqp_properties.cpp index f431e1280e..a8fc82bea9 100644 --- a/sdk/core/azure-core-amqp/src/models/amqp_properties.cpp +++ b/sdk/core/azure-core-amqp/src/models/amqp_properties.cpp @@ -2,11 +2,13 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/models/amqp_properties.hpp" + #include "azure/core/amqp/models/amqp_value.hpp" #include #include + #include #include #include @@ -274,7 +276,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { { auto handle = _internal::MessagePropertiesFactory::ToUamqp(properties); AmqpValue propertiesAsValue{amqpvalue_create_properties(handle.get())}; - return Azure::Core::Amqp::Models::AmqpValue::Serialize(propertiesAsValue); + return Models::AmqpValue::Serialize(propertiesAsValue); } MessageProperties MessageProperties::Deserialize(uint8_t const* data, size_t size) diff --git a/sdk/core/azure-core-amqp/src/models/amqp_value.cpp b/sdk/core/azure-core-amqp/src/models/amqp_value.cpp index 0ad5fd0a53..353395286a 100644 --- a/sdk/core/azure-core-amqp/src/models/amqp_value.cpp +++ b/sdk/core/azure-core-amqp/src/models/amqp_value.cpp @@ -2,6 +2,7 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/models/amqp_value.hpp" + #include "azure/core/amqp/models/amqp_properties.hpp" #include "azure/core/amqp/models/amqp_protocol.hpp" @@ -14,6 +15,7 @@ #include #include #include + #include #include #include @@ -375,7 +377,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { return os; } - class AmqpValueDeserializer { + class AmqpValueDeserializer final { public: AmqpValueDeserializer() : m_decoder{amqpvalue_decoder_create(OnAmqpValueDecoded, this)} {} @@ -404,7 +406,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { return AmqpValueDeserializer{}(data, size); } - class AmqpValueSerializer { + class AmqpValueSerializer final { public: AmqpValueSerializer() = default; diff --git a/sdk/core/azure-core-amqp/src/models/message_source.cpp b/sdk/core/azure-core-amqp/src/models/message_source.cpp index 175ff213fe..1edfcd2d9d 100644 --- a/sdk/core/azure-core-amqp/src/models/message_source.cpp +++ b/sdk/core/azure-core-amqp/src/models/message_source.cpp @@ -3,16 +3,17 @@ #include "azure/core/amqp/models/message_source.hpp" +#include +#include + #include #include #include #include -#include -#include +#include #include -#include -#include +#include void Azure::Core::_internal::UniqueHandleHelper::FreeMessageSource( SOURCE_HANDLE value) @@ -22,7 +23,7 @@ void Azure::Core::_internal::UniqueHandleHelper::FreeMessag namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace _internal { - MessageSource::MessageSource(Azure::Core::Amqp::Models::AmqpValue const& source) + MessageSource::MessageSource(Models::AmqpValue const& source) { if (source.IsNull()) { @@ -38,6 +39,10 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } } + /* Note: This constructor should NOT be marked as explicit, because we want to enable the implicit + * construction of the MessageSource from a string - this allows callers to construct Link, + * MessageSender, and MessageReceiver objects without forcing the creation of a MessageSource + * object. */ MessageSource::MessageSource(std::string const& address) : m_source(source_create()) { if (m_source == nullptr) @@ -49,6 +54,11 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace throw std::runtime_error("Could not set address."); // LCOV_EXCL_LINE } } + + /* Note: This constructor should NOT be marked as explicit, because we want to enable the implicit + * construction of the MessageSource from a string - this allows callers to construct Link, + * MessageSender, and MessageReceiver objects without forcing the creation of a MessageSource + * object. */ MessageSource::MessageSource(char const* address) : m_source(source_create()) { if (m_source == nullptr) @@ -61,6 +71,17 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } } + MessageSource::MessageSource(MessageSource const& that) + : m_source{source_clone(that.m_source.get())} + { + } + + MessageSource& MessageSource::operator=(MessageSource const& that) + { + m_source.reset(source_clone(that.m_source.get())); + return *this; + } + MessageSource::MessageSource() : m_source(source_create()) {} MessageSource::MessageSource(MessageSourceOptions const& options) : m_source(source_create()) @@ -188,12 +209,12 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } // Convert the MessageSource into a Value. - MessageSource::operator const Azure::Core::Amqp::Models::AmqpValue() const + Models::AmqpValue MessageSource::AsAmqpValue() const { return amqpvalue_create_source(m_source.get()); } - Azure::Core::Amqp::Models::AmqpValue MessageSource::GetAddress() const + Models::AmqpValue MessageSource::GetAddress() const { AMQP_VALUE address; if (source_get_address(m_source.get(), &address)) @@ -270,7 +291,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace return value; } - Azure::Core::Amqp::Models::AmqpMap MessageSource::GetDynamicNodeProperties() const + Models::AmqpMap MessageSource::GetDynamicNodeProperties() const { AMQP_VALUE value; if (source_get_dynamic_node_properties(m_source.get(), &value)) @@ -288,7 +309,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } return value; } - Azure::Core::Amqp::Models::AmqpMap MessageSource::GetFilter() const + Models::AmqpMap MessageSource::GetFilter() const { AMQP_VALUE value; if (source_get_filter(m_source.get(), &value)) @@ -298,7 +319,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace return value; } - Azure::Core::Amqp::Models::AmqpValue MessageSource::GetDefaultOutcome() const + Models::AmqpValue MessageSource::GetDefaultOutcome() const { AMQP_VALUE value; if (source_get_default_outcome(m_source.get(), &value)) @@ -308,7 +329,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace return value; } - Azure::Core::Amqp::Models::AmqpArray MessageSource::GetOutcomes() const + Models::AmqpArray MessageSource::GetOutcomes() const { AMQP_VALUE value; if (source_get_outcomes(m_source.get(), &value)) @@ -318,7 +339,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace return value; } - Azure::Core::Amqp::Models::AmqpArray MessageSource::GetCapabilities() const + Models::AmqpArray MessageSource::GetCapabilities() const { AMQP_VALUE value; if (source_get_capabilities(m_source.get(), &value)) diff --git a/sdk/core/azure-core-amqp/src/models/message_target.cpp b/sdk/core/azure-core-amqp/src/models/message_target.cpp index c77e40ef13..d4e91f8d40 100644 --- a/sdk/core/azure-core-amqp/src/models/message_target.cpp +++ b/sdk/core/azure-core-amqp/src/models/message_target.cpp @@ -3,16 +3,17 @@ #include "azure/core/amqp/models/message_target.hpp" +#include +#include + #include #include #include #include -#include -#include +#include #include -#include -#include +#include void Azure::Core::_internal::UniqueHandleHelper::FreeMessageTarget( TARGET_HANDLE value) @@ -24,7 +25,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace // MessageTarget::MessageTarget(TARGET_HANDLE handle) : m_target{handle} {} - MessageTarget::MessageTarget(Azure::Core::Amqp::Models::AmqpValue const& source) + MessageTarget::MessageTarget(Models::AmqpValue const& source) { if (source.IsNull()) { @@ -63,6 +64,14 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace MessageTarget::MessageTarget() : m_target{target_create()} {} + MessageTarget::MessageTarget(MessageTarget const& that) : m_target{target_clone(that)} {} + + MessageTarget& MessageTarget::operator=(MessageTarget const& that) + { + m_target.reset(target_clone(that.m_target.get())); + return *this; + } + MessageTarget::MessageTarget(MessageTargetOptions const& options) : m_target{target_create()} { if (!options.Address.IsNull()) @@ -160,12 +169,12 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } // Convert the MessageSource into a Value. - MessageTarget::operator const Azure::Core::Amqp::Models::AmqpValue() const + Models::AmqpValue MessageTarget::AsAmqpValue() const { return amqpvalue_create_target(m_target.get()); } - Azure::Core::Amqp::Models::AmqpValue MessageTarget::GetAddress() const + Models::AmqpValue MessageTarget::GetAddress() const { AMQP_VALUE address; if (target_get_address(m_target.get(), &address)) @@ -242,7 +251,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace return value; } - Azure::Core::Amqp::Models::AmqpMap MessageTarget::GetDynamicNodeProperties() const + Models::AmqpMap MessageTarget::GetDynamicNodeProperties() const { AMQP_VALUE value; if (target_get_dynamic_node_properties(m_target.get(), &value)) @@ -252,7 +261,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace return AmqpValue{value}.AsMap(); } - Azure::Core::Amqp::Models::AmqpArray MessageTarget::GetCapabilities() const + Models::AmqpArray MessageTarget::GetCapabilities() const { AMQP_VALUE value; if (target_get_capabilities(m_target.get(), &value)) diff --git a/sdk/core/azure-core-amqp/src/models/messaging_values.cpp b/sdk/core/azure-core-amqp/src/models/messaging_values.cpp index 51acc21719..1be53b274b 100644 --- a/sdk/core/azure-core-amqp/src/models/messaging_values.cpp +++ b/sdk/core/azure-core-amqp/src/models/messaging_values.cpp @@ -7,7 +7,7 @@ #include /* Common Message values */ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace _internal { - Azure::Core::Amqp::Models::AmqpValue Messaging::DeliveryAccepted() + Models::AmqpValue Messaging::DeliveryAccepted() { auto rv = messaging_delivery_accepted(); if (!rv) @@ -16,7 +16,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } return rv; } - Azure::Core::Amqp::Models::AmqpValue Messaging::DeliveryReleased() + Models::AmqpValue Messaging::DeliveryReleased() { auto rv = messaging_delivery_released(); if (!rv) @@ -25,9 +25,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } return rv; } - Azure::Core::Amqp::Models::AmqpValue Messaging::DeliveryReceived( - uint32_t sectionNumber, - uint64_t sectionOffset) + Models::AmqpValue Messaging::DeliveryReceived(uint32_t sectionNumber, uint64_t sectionOffset) { auto rv = messaging_delivery_received(sectionNumber, sectionOffset); if (!rv) @@ -36,7 +34,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } return rv; } - Azure::Core::Amqp::Models::AmqpValue Messaging::DeliveryRejected( + Models::AmqpValue Messaging::DeliveryRejected( std::string const& errorCondition, std::string const& errorDescription) { @@ -49,10 +47,10 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace } return rv; } - Azure::Core::Amqp::Models::AmqpValue Messaging::DeliveryModified( + Models::AmqpValue Messaging::DeliveryModified( bool deliveryFailed, bool undeliverableHere, - Azure::Core::Amqp::Models::AmqpValue annotations) + Models::AmqpValue annotations) { auto rv = messaging_delivery_modified(deliveryFailed, undeliverableHere, annotations); if (!rv) @@ -62,23 +60,4 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace return rv; } - Azure::Core::Amqp::Models::AmqpValue Messaging::CreateSource(std::string const& address) - { - auto rv = messaging_create_source(address.c_str()); - if (!rv) - { - throw std::runtime_error("Could not allocate source described value."); - } - return rv; - } - Azure::Core::Amqp::Models::AmqpValue Messaging::CreateTarget(std::string const& address) - { - auto rv = messaging_create_target(address.c_str()); - if (!rv) - { - throw std::runtime_error("Could not allocate target described value."); - } - return rv; - } - }}}}} // namespace Azure::Core::Amqp::Models::_internal diff --git a/sdk/core/azure-core-amqp/src/network/amqp_header_transport.cpp b/sdk/core/azure-core-amqp/src/network/amqp_header_transport.cpp index 5edcfe9b95..56dd48a369 100644 --- a/sdk/core/azure-core-amqp/src/network/amqp_header_transport.cpp +++ b/sdk/core/azure-core-amqp/src/network/amqp_header_transport.cpp @@ -8,6 +8,7 @@ #include #include #include + #include #include #include @@ -15,10 +16,9 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - AmqpHeaderDetectTransport::AmqpHeaderDetectTransport( + Transport AmqpHeaderDetectTransportFactory::Create( std::shared_ptr parentTransport, TransportEvents* eventHandler) - : Transport(eventHandler) { HEADER_DETECT_IO_CONFIG detectIoConfig{}; HEADER_DETECT_ENTRY headerDetectEntries[] = { @@ -28,9 +28,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac detectIoConfig.underlying_io = parentTransport->GetImpl()->Release(); detectIoConfig.header_detect_entry_count = std::extent::value; detectIoConfig.header_detect_entries = headerDetectEntries; - auto xio = xio_create(header_detect_io_get_interface_description(), &detectIoConfig); - - m_impl->SetInstance(xio); + return _detail::TransportImpl::CreateFromXioHandle( + xio_create(header_detect_io_get_interface_description(), &detectIoConfig), eventHandler); } }}}}} // namespace Azure::Core::Amqp::Network::_internal diff --git a/sdk/core/azure-core-amqp/src/network/private/transport_impl.hpp b/sdk/core/azure-core-amqp/src/network/private/transport_impl.hpp index 060ad53374..68d9ed14e1 100644 --- a/sdk/core/azure-core-amqp/src/network/private/transport_impl.hpp +++ b/sdk/core/azure-core-amqp/src/network/private/transport_impl.hpp @@ -2,8 +2,12 @@ // SPDX-License-Identifier: MIT #pragma once -#include "azure/core/internal/unique_handle.hpp" +#include "azure/core/amqp/common/async_operation_queue.hpp" + +#include + #include + #include #include #include @@ -21,16 +25,6 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac struct TransportImpl : public std::enable_shared_from_this { - - private: - UniqueXioHandle m_xioInstance{}; - Azure::Core::Amqp::Network::_internal::TransportEvents* m_eventHandler; - bool m_isOpen{false}; - - static void OnOpenCompleteFn(void* context, IO_OPEN_RESULT_TAG openResult); - static void OnBytesReceivedFn(void* context, const unsigned char* buffer, size_t size); - static void OnIoErrorFn(void* context); - public: TransportImpl( XIO_HANDLE instance, @@ -39,19 +33,38 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac TransportImpl(Azure::Core::Amqp::Network::_internal::TransportEvents* eventHandler); virtual ~TransportImpl(); - virtual bool Open(); - virtual bool Close(Azure::Core::Amqp::Network::_internal::Transport::TransportCloseCompleteFn); - virtual bool Send( - uint8_t*, - size_t, - Azure::Core::Amqp::Network::_internal::Transport::TransportSendCompleteFn) const; + virtual _internal::TransportOpenStatus Open(Context const& context); + virtual void Close(Context const& context); + virtual bool Send(uint8_t*, size_t, Network::_internal::Transport::TransportSendCompleteFn) + const; void Poll() const; operator XIO_HANDLE() { return m_xioInstance.get(); } XIO_HANDLE Release() { return m_xioInstance.release(); } - void SetEventHandler(Azure::Core::Amqp::Network::_internal::TransportEvents* eventHandler) + void SetEventHandler(Network::_internal::TransportEvents* eventHandler) { m_eventHandler = eventHandler; } - void SetInstance(XIO_HANDLE instance); + + static std::shared_ptr CreateFromXioHandle( + XIO_HANDLE instance, + Network::_internal::TransportEvents* eventHandler) + { + return std::shared_ptr( + new TransportImpl(instance, eventHandler), [](TransportImpl* p) { delete p; }); + } + + private: + UniqueXioHandle m_xioInstance{}; + Azure::Core::Amqp::Common::_internal::AsyncOperationQueue<_internal::TransportOpenStatus> + m_openCompleteQueue; + Azure::Core::Amqp::Common::_internal::AsyncOperationQueue m_closeCompleteQueue; + Network::_internal::TransportEvents* m_eventHandler; + + bool m_isOpen{false}; + + static void OnOpenCompleteFn(void* context, IO_OPEN_RESULT_TAG openResult); + static void OnCloseCompleteFn(void* context); + static void OnBytesReceivedFn(void* context, const unsigned char* buffer, size_t size); + static void OnIOErrorFn(void* context); }; }}}}} // namespace Azure::Core::Amqp::Network::_detail diff --git a/sdk/core/azure-core-amqp/src/network/sasl_transport.cpp b/sdk/core/azure-core-amqp/src/network/sasl_transport.cpp index 469d570de1..1b44e03c46 100644 --- a/sdk/core/azure-core-amqp/src/network/sasl_transport.cpp +++ b/sdk/core/azure-core-amqp/src/network/sasl_transport.cpp @@ -3,8 +3,10 @@ // LCOV_EXCL_START #include "azure/core/amqp/network/sasl_transport.hpp" + #include "azure/core/amqp/network/tls_transport.hpp" #include "private/transport_impl.hpp" + #include #include #include @@ -12,13 +14,13 @@ #include #include -Azure::Core::Amqp::Network::_internal::SaslTransport::SaslTransport( +Azure::Core::Amqp::Network::_internal::Transport +Azure::Core::Amqp::Network::_internal::SaslTransportFactory::Create( std::string const& saslKeyName, std::string const& saslKey, std::string const& hostName, uint16_t hostPort, TransportEvents* eventHandler) - : Transport(eventHandler) { XIO_HANDLE underlying_io; // We assume that localhost connections will be using raw sockets, not TLS. @@ -45,14 +47,15 @@ Azure::Core::Amqp::Network::_internal::SaslTransport::SaslTransport( SASLCLIENTIO_CONFIG saslConfig; saslConfig.underlying_io = underlying_io; saslConfig.sasl_mechanism = saslMechanism; - m_impl->SetInstance(xio_create(saslclientio_get_interface_description(), &saslConfig)); + return _detail::TransportImpl::CreateFromXioHandle( + xio_create(saslclientio_get_interface_description(), &saslConfig), eventHandler); } -Azure::Core::Amqp::Network::_internal::SaslTransport::SaslTransport( +Azure::Core::Amqp::Network::_internal::Transport +Azure::Core::Amqp::Network::_internal::SaslTransportFactory::Create( std::string const& hostName, uint16_t hostPort, TransportEvents* eventHandler) - : Transport(eventHandler) { XIO_HANDLE underlying_io; // We assume that localhost connections will be using raw sockets, not TLS. @@ -76,6 +79,7 @@ Azure::Core::Amqp::Network::_internal::SaslTransport::SaslTransport( SASLCLIENTIO_CONFIG saslConfig; saslConfig.underlying_io = underlying_io; saslConfig.sasl_mechanism = saslMechanism; - m_impl->SetInstance(xio_create(saslclientio_get_interface_description(), &saslConfig)); + return _detail::TransportImpl::CreateFromXioHandle( + xio_create(saslclientio_get_interface_description(), &saslConfig), eventHandler); } // LCOV_EXCL_STOP diff --git a/sdk/core/azure-core-amqp/src/network/socket_listener.cpp b/sdk/core/azure-core-amqp/src/network/socket_listener.cpp index 15c06ad2b8..1b50fc7d5d 100644 --- a/sdk/core/azure-core-amqp/src/network/socket_listener.cpp +++ b/sdk/core/azure-core-amqp/src/network/socket_listener.cpp @@ -2,12 +2,15 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/network/socket_listener.hpp" + #include "azure/core/amqp/common/global_state.hpp" #include "private/transport_impl.hpp" + #include #include #include #include + #include #include #include diff --git a/sdk/core/azure-core-amqp/src/network/socket_transport.cpp b/sdk/core/azure-core-amqp/src/network/socket_transport.cpp index a6738d2d58..441f73e917 100644 --- a/sdk/core/azure-core-amqp/src/network/socket_transport.cpp +++ b/sdk/core/azure-core-amqp/src/network/socket_transport.cpp @@ -2,11 +2,15 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/network/socket_transport.hpp" + #include "private/transport_impl.hpp" + #include #include + #include #include + #include #include @@ -15,18 +19,18 @@ using namespace Azure::Core::Diagnostics; namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - SocketTransport::SocketTransport( + Transport SocketTransportFactory::Create( std::string const& host, uint16_t port, TransportEvents* eventHandler) - : Transport(eventHandler) { Log::Write( Logger::Level::Verbose, "Create socket transport for host " + host + " port: " + std::to_string(port)); SOCKETIO_CONFIG socketConfig{host.c_str(), port, nullptr}; - m_impl->SetInstance(xio_create(socketio_get_interface_description(), &socketConfig)); + return _detail::TransportImpl::CreateFromXioHandle( + xio_create(socketio_get_interface_description(), &socketConfig), eventHandler); } }}}}} // namespace Azure::Core::Amqp::Network::_internal diff --git a/sdk/core/azure-core-amqp/src/network/tls_transport.cpp b/sdk/core/azure-core-amqp/src/network/tls_transport.cpp index a007151127..2428c68b3f 100644 --- a/sdk/core/azure-core-amqp/src/network/tls_transport.cpp +++ b/sdk/core/azure-core-amqp/src/network/tls_transport.cpp @@ -2,16 +2,20 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/network/tls_transport.hpp" + #include "private/transport_impl.hpp" #include #include + #include namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - TlsTransport::TlsTransport(std::string const& host, uint16_t port, TransportEvents* eventHandler) - : Transport(eventHandler) + Transport TlsTransportFactory::Create( + std::string const& host, + uint16_t port, + TransportEvents* eventHandler) { TLSIO_CONFIG tlsConfig{}; tlsConfig.hostname = host.c_str(); @@ -19,9 +23,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac auto tlsio_interface = platform_get_default_tlsio(); - m_impl->SetInstance(xio_create(tlsio_interface, &tlsConfig)); + return _detail::TransportImpl::CreateFromXioHandle( + xio_create(tlsio_interface, &tlsConfig), eventHandler); } - TlsTransport::TlsTransport(TransportEvents* eventHandler) : Transport(eventHandler) {} - }}}}} // namespace Azure::Core::Amqp::Network::_internal diff --git a/sdk/core/azure-core-amqp/src/network/transport.cpp b/sdk/core/azure-core-amqp/src/network/transport.cpp index 48944d6745..f868b065df 100644 --- a/sdk/core/azure-core-amqp/src/network/transport.cpp +++ b/sdk/core/azure-core-amqp/src/network/transport.cpp @@ -2,11 +2,14 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/network/transport.hpp" + #include "azure/core/amqp/common/completion_operation.hpp" #include "azure/core/amqp/common/global_state.hpp" #include "private/transport_impl.hpp" + #include #include + #include void Azure::Core::_internal::UniqueHandleHelper::FreeXio(XIO_HANDLE value) @@ -26,15 +29,10 @@ void EnsureGlobalStateInitialized() } // namespace namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _internal { - Transport::Transport(TransportEvents* eventHandler) - : m_impl{std::make_shared<_detail::TransportImpl>(eventHandler)} - { - } - Transport::~Transport() {} - bool Transport::Open() { return m_impl->Open(); } - bool Transport::Close(TransportCloseCompleteFn callback) { return m_impl->Close(callback); } + TransportOpenStatus Transport::Open(Context const& context) { return m_impl->Open(context); } + void Transport::Close(Context const& context) { return m_impl->Close(context); } bool Transport::Send(uint8_t* buffer, size_t size, TransportSendCompleteFn callback) const { @@ -50,7 +48,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac namespace Azure { namespace Core { namespace Amqp { namespace Network { namespace _detail { - TransportImpl::TransportImpl(Azure::Core::Amqp::Network::_internal::TransportEvents* eventHandler) + TransportImpl::TransportImpl(Network::_internal::TransportEvents* eventHandler) : m_xioInstance(nullptr), m_eventHandler{eventHandler} { EnsureGlobalStateInitialized(); @@ -58,20 +56,10 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac // This constructor is used by the SocketTransport and TlsTransport classes to construct a // transport around an already constructed XIO transport. - TransportImpl::TransportImpl( - XIO_HANDLE handle, - Azure::Core::Amqp::Network::_internal::TransportEvents* eventHandler) + TransportImpl::TransportImpl(XIO_HANDLE handle, Network::_internal::TransportEvents* eventHandler) : m_xioInstance{handle}, m_eventHandler{eventHandler} { - EnsureGlobalStateInitialized(); - } - - void TransportImpl::SetInstance(XIO_HANDLE handle) - { - assert(m_xioInstance == nullptr); assert(handle != nullptr); - m_xioInstance.reset(handle); - EnsureGlobalStateInitialized(); } @@ -82,58 +70,56 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac static void OnOperation(CompleteFn onComplete) { onComplete(); } }; - bool TransportImpl::Close( - Azure::Core::Amqp::Network::_internal::Transport::TransportCloseCompleteFn onCloseComplete) + void TransportImpl::OnCloseCompleteFn(void* context) + { + TransportImpl* transport = reinterpret_cast(context); + transport->m_closeCompleteQueue.CompleteOperation(true); + } + void TransportImpl::Close(Context const& context) { if (!m_isOpen) { throw std::logic_error("Cannot close an unopened transport."); } - m_isOpen = false; - auto closeOperation - = std::make_unique>>(onCloseComplete); if (m_xioInstance) { - if (xio_close( - m_xioInstance.get(), - std::remove_pointer::type::OnOperationFn, - closeOperation.release())) + if (xio_close(m_xioInstance.get(), OnCloseCompleteFn, this)) { - return false; + throw std::runtime_error("Failed to close the transport."); } m_xioInstance = nullptr; } - return true; + auto result = m_closeCompleteQueue.WaitForPolledResult(context, *this); + if (!result) + { + throw Azure::Core::OperationCancelledException("Close operation was cancelled."); + } + m_isOpen = false; } void TransportImpl::OnOpenCompleteFn(void* context, IO_OPEN_RESULT ioOpenResult) { TransportImpl* transport = reinterpret_cast(context); - if (transport->m_eventHandler) + Network::_internal::TransportOpenStatus openResult{ + Network::_internal::TransportOpenStatus::Error}; + switch (ioOpenResult) { - Azure::Core::Amqp::Network::_internal::TransportOpenResult openResult{ - Azure::Core::Amqp::Network::_internal::TransportOpenResult::Error}; - switch (ioOpenResult) - { - // LCOV_EXCL_START - case IO_OPEN_RESULT_INVALID: - openResult = Azure::Core::Amqp::Network::_internal::TransportOpenResult::Invalid; - break; - case IO_OPEN_CANCELLED: - openResult = Azure::Core::Amqp::Network::_internal::TransportOpenResult::Cancelled; - break; - case IO_OPEN_ERROR: - openResult = Azure::Core::Amqp::Network::_internal::TransportOpenResult::Error; - break; - // LCOV_EXCL_STOP - case IO_OPEN_OK: - openResult = Azure::Core::Amqp::Network::_internal::TransportOpenResult::Ok; - break; - } - transport->m_eventHandler->OnOpenComplete(openResult); + // LCOV_EXCL_START + case IO_OPEN_RESULT_INVALID: + openResult = Network::_internal::TransportOpenStatus::Invalid; + break; + case IO_OPEN_CANCELLED: + openResult = Network::_internal::TransportOpenStatus::Cancelled; + break; + case IO_OPEN_ERROR: + openResult = Network::_internal::TransportOpenStatus::Error; + break; + // LCOV_EXCL_STOP + case IO_OPEN_OK: + openResult = Network::_internal::TransportOpenStatus::Ok; + break; } + transport->m_openCompleteQueue.CompleteOperation(openResult); } void TransportImpl::OnBytesReceivedFn(void* context, unsigned char const* buffer, size_t size) @@ -146,60 +132,63 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac } // LCOV_EXCL_START - void TransportImpl::OnIoErrorFn(void* context) + void TransportImpl::OnIOErrorFn(void* context) { TransportImpl* transport = reinterpret_cast(context); if (transport->m_eventHandler) { - transport->m_eventHandler->OnIoError(); + transport->m_eventHandler->OnIOError(); } } // LCOV_EXCL_STOP - bool TransportImpl::Open() + _internal::TransportOpenStatus TransportImpl::Open(Context const& context) { if (m_isOpen) { throw std::logic_error("Cannot open an opened transport."); } - if (xio_open( m_xioInstance.get(), OnOpenCompleteFn, this, OnBytesReceivedFn, this, - OnIoErrorFn, + OnIOErrorFn, this)) { - return false; + return _internal::TransportOpenStatus::Error; } m_isOpen = true; - return true; + auto result = m_openCompleteQueue.WaitForPolledResult(context, *this); + if (result) + { + return std::get<0>(*result); + } + throw Azure::Core::OperationCancelledException("Open operation was cancelled."); } template struct SendCallbackRewriter { static void OnOperation(CompleteFn onComplete, IO_SEND_RESULT sendResult) { - Azure::Core::Amqp::Network::_internal::TransportSendResult result{ - Azure::Core::Amqp::Network::_internal::TransportSendResult::Ok}; + Network::_internal::TransportSendStatus result{Network::_internal::TransportSendStatus::Ok}; switch (sendResult) { // LCOV_EXCL_START case IO_SEND_RESULT_INVALID: - result = Azure::Core::Amqp::Network::_internal::TransportSendResult::Invalid; + result = Network::_internal::TransportSendStatus::Invalid; break; case IO_SEND_CANCELLED: - result = Azure::Core::Amqp::Network::_internal::TransportSendResult::Cancelled; + result = Network::_internal::TransportSendStatus::Cancelled; break; case IO_SEND_ERROR: - result = Azure::Core::Amqp::Network::_internal::TransportSendResult::Error; + result = Network::_internal::TransportSendStatus::Error; break; // LCOV_EXCL_STOP case IO_SEND_OK: - result = Azure::Core::Amqp::Network::_internal::TransportSendResult::Ok; + result = Network::_internal::TransportSendStatus::Ok; break; } onComplete(result); @@ -209,7 +198,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Network { namespac bool TransportImpl::Send( unsigned char* buffer, size_t size, - Azure::Core::Amqp::Network::_internal::Transport::TransportSendCompleteFn sendComplete) const + Network::_internal::Transport::TransportSendCompleteFn sendComplete) const { auto operation{std::make_unique - #include "azure/core/amqp/models/amqp_header.hpp" +#include + using namespace Azure::Core::Amqp::Models; class TestHeaders : public testing::Test { diff --git a/sdk/core/azure-core-amqp/test/ut/amqp_message_tests.cpp b/sdk/core/azure-core-amqp/test/ut/amqp_message_tests.cpp index 3ff6ce6a54..e60b8b410a 100644 --- a/sdk/core/azure-core-amqp/test/ut/amqp_message_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/amqp_message_tests.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT -#include - #include "azure/core/amqp/models/amqp_message.hpp" +#include + using namespace Azure::Core::Amqp::Models; class TestMessage : public testing::Test { diff --git a/sdk/core/azure-core-amqp/test/ut/amqp_properties_tests.cpp b/sdk/core/azure-core-amqp/test/ut/amqp_properties_tests.cpp index 515f7ea9ee..0a610ab4d6 100644 --- a/sdk/core/azure-core-amqp/test/ut/amqp_properties_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/amqp_properties_tests.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT -#include - #include "azure/core/amqp/models/amqp_properties.hpp" +#include + using namespace Azure::Core::Amqp::Models; class TestProperties : public testing::Test { diff --git a/sdk/core/azure-core-amqp/test/ut/amqp_value_tests.cpp b/sdk/core/azure-core-amqp/test/ut/amqp_value_tests.cpp index 512e463d9a..4d13b4578d 100644 --- a/sdk/core/azure-core-amqp/test/ut/amqp_value_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/amqp_value_tests.cpp @@ -1,13 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT -#include - #include "azure/core/amqp/common/global_state.hpp" #include "azure/core/amqp/models/amqp_value.hpp" + #include #include +#include + using namespace Azure::Core::Amqp::Models; class TestValues : public testing::Test { diff --git a/sdk/core/azure-core-amqp/test/ut/azure_core_amqp_tests.cpp b/sdk/core/azure-core-amqp/test/ut/azure_core_amqp_tests.cpp index 1b257efd75..a80ec4e072 100644 --- a/sdk/core/azure-core-amqp/test/ut/azure_core_amqp_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/azure_core_amqp_tests.cpp @@ -1,13 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/core/internal/diagnostics/global_exception.hpp" #include "azure/core/platform.hpp" + #include #include +#include + int main(int argc, char** argv) { #if defined(AZ_PLATFORM_POSIX) diff --git a/sdk/core/azure-core-amqp/test/ut/claim_based_security_tests.cpp b/sdk/core/azure-core-amqp/test/ut/claim_based_security_tests.cpp index 7301427a26..e101ae4669 100644 --- a/sdk/core/azure-core-amqp/test/ut/claim_based_security_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/claim_based_security_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT -#include +#include "mock_amqp_server.hpp" #include #include @@ -15,7 +15,7 @@ #include #include -#include "mock_amqp_server.hpp" +#include // extern uint16_t FindAvailableSocket(); @@ -34,9 +34,9 @@ TEST_F(TestCbs, SimpleCbs) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + Connection connection("localhost", {}); // Create a session - Session session(connection, nullptr); + Session session(connection, {}); { ClaimsBasedSecurity cbs(session); @@ -55,9 +55,10 @@ TEST_F(TestCbs, CbsOpen) { { MessageTests::AmqpServerMock mockServer; - - Connection connection("amqp://localhost:" + std::to_string(mockServer.GetPort()), {}); - Session session(connection); + ConnectionOptions options; + options.Port = mockServer.GetPort(); + Connection connection("localhost", options); + Session session(connection, nullptr); { ClaimsBasedSecurity cbs(session); GTEST_LOG_(INFO) << "Expected failure for Open because no listener." << mockServer.GetPort(); @@ -68,18 +69,23 @@ TEST_F(TestCbs, CbsOpen) { MessageTests::AmqpServerMock mockServer; - Connection connection("amqp://localhost:" + std::to_string(mockServer.GetPort()), {}); - Session session(connection); + ConnectionOptions options; + options.Port = mockServer.GetPort(); + Connection connection("localhost", options); + Session session(connection, nullptr); mockServer.StartListening(); { ClaimsBasedSecurity cbs(session); cbs.SetTrace(true); - EXPECT_EQ(CbsOpenResult::Ok, cbs.Open()); + CbsOpenResult openResult; + EXPECT_EQ(CbsOpenResult::Ok, openResult = cbs.Open()); GTEST_LOG_(INFO) << "Open Completed."; - - cbs.Close(); + if (openResult == CbsOpenResult::Ok) + { + cbs.Close(); + } } mockServer.StopListening(); } @@ -92,8 +98,10 @@ TEST_F(TestCbs, CbsOpenAndPut) { MessageTests::AmqpServerMock mockServer; - Connection connection("amqp://localhost:" + std::to_string(mockServer.GetPort()), {}); - Session session(connection); + ConnectionOptions options; + options.Port = mockServer.GetPort(); + Connection connection("localhost", options); + Session session(connection, nullptr); mockServer.StartListening(); @@ -123,8 +131,10 @@ TEST_F(TestCbs, CbsOpenAndPutError) { MessageTests::AmqpServerMock mockServer; - Connection connection("amqp://localhost:" + std::to_string(mockServer.GetPort()), {}); - Session session(connection); + ConnectionOptions options; + options.Port = mockServer.GetPort(); + Connection connection("localhost", options); + Session session(connection, nullptr); mockServer.StartListening(); diff --git a/sdk/core/azure-core-amqp/test/ut/connection_string_tests.cpp b/sdk/core/azure-core-amqp/test/ut/connection_string_tests.cpp index 134a166bcc..fee8c00147 100644 --- a/sdk/core/azure-core-amqp/test/ut/connection_string_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/connection_string_tests.cpp @@ -2,10 +2,13 @@ // SPDX-Licence-Identifier: MIT #include "azure/core/amqp/connection_string_credential.hpp" + #include -#include + #include +#include + class ConnectionStringTest : public testing::Test { protected: void SetUp() override {} @@ -22,16 +25,11 @@ TEST_F(ConnectionStringTest, SaslPlainConnectionGood) = "Endpoint=sb://{NAMESPACE}.servicebus.windows.net/" "{EVENT_HUB_NAME};EntityPath={EVENT_HUB_NAME};SharedAccessKeyName={ACCESS_KEY_NAME};" "SharedAccessKey={ACCESS_KEY}"; - Azure::Core::Amqp::_internal::SaslPlainConnectionStringCredential credential(connectionString); + Azure::Core::Amqp::_internal::ConnectionStringParser credential(connectionString); EXPECT_EQ("sb://{NAMESPACE}.servicebus.windows.net/{EVENT_HUB_NAME}", credential.GetEndpoint()); EXPECT_EQ("{EVENT_HUB_NAME}", credential.GetEntityPath()); EXPECT_EQ("{ACCESS_KEY_NAME}", credential.GetSharedAccessKeyName()); EXPECT_EQ("{ACCESS_KEY}", credential.GetSharedAccessKey()); - { - auto xport = credential.GetTransport(); - EXPECT_EQ( - credential.GetCredentialType(), Azure::Core::Amqp::_internal::CredentialType::SaslPlain); - } } } @@ -52,13 +50,10 @@ TEST_F(ConnectionStringTest, ServiceBusSasConnectionGood) #if !defined(AZ_PLATFORM_MAC) auto xport = credential.GetTransport(); #endif // !defined(AZ_PLATFORM_MAC) - EXPECT_EQ( - credential.GetCredentialType(), - Azure::Core::Amqp::_internal::CredentialType::ServiceBusSas); // Generate a SAS token which expires in 60 seconds. - auto token = credential.GenerateSasToken( - std::chrono::system_clock::now() + std::chrono::seconds(60)); + Azure::Core::Credentials::TokenRequestContext trc; + auto token = credential.GetToken(trc, {}); } } EXPECT_NO_THROW([]() { @@ -72,21 +67,19 @@ TEST_F(ConnectionStringTest, ServiceBusSasConnectionGood) }()); } -TEST_F(ConnectionStringTest, SaslPlainConnectionBad) +TEST_F(ConnectionStringTest, ConnectionStringParserBad) { { - EXPECT_ANY_THROW( - []() { Azure::Core::Amqp::_internal::SaslPlainConnectionStringCredential xx(""); }()); + EXPECT_ANY_THROW([]() { Azure::Core::Amqp::_internal::ConnectionStringParser xx(""); }()); EXPECT_ANY_THROW([]() { - Azure::Core::Amqp::_internal::SaslPlainConnectionStringCredential yy( - "Foo=Bar;Boo=Eek;Yoiks=Blang!"); + Azure::Core::Amqp::_internal::ConnectionStringParser yy("Foo=Bar;Boo=Eek;Yoiks=Blang!"); }()); EXPECT_ANY_THROW([]() { - Azure::Core::Amqp::_internal::SaslPlainConnectionStringCredential zz( + Azure::Core::Amqp::_internal::ConnectionStringParser zz( "Endpoint=Bar;SharedAccessKeyName=Eek;SharedAccessKey"); }()); EXPECT_ANY_THROW([]() { - Azure::Core::Amqp::_internal::SaslPlainConnectionStringCredential zz( + Azure::Core::Amqp::_internal::ConnectionStringParser zz( "Endpoint=Bar;SharedAccessKeyName=Eek;SharedAccessKey"); }()); } diff --git a/sdk/core/azure-core-amqp/test/ut/connection_tests.cpp b/sdk/core/azure-core-amqp/test/ut/connection_tests.cpp index d68391b2ce..e945a4b34a 100644 --- a/sdk/core/azure-core-amqp/test/ut/connection_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/connection_tests.cpp @@ -10,12 +10,15 @@ #include "azure/core/amqp/network/socket_listener.hpp" #include "azure/core/amqp/network/socket_transport.hpp" #include "azure/core/amqp/session.hpp" + #include #include + #include -#include #include +#include + extern uint16_t FindAvailableSocket(); class TestConnections : public testing::Test { @@ -29,98 +32,88 @@ TEST_F(TestConnections, SimpleConnection) { { // Create a connection - Azure::Core::Amqp::_internal::Connection connection("amqp://localhost:5672", {}); + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.Port = Azure::Core::Amqp::_internal::AmqpPort; - Azure::Core::Amqp::_internal::ConnectionOptions options; - options.SaslCredentials - = std::make_shared( - "Endpoint=sb://testHost.net/" - ";SharedAccessKeyName=SomeName;SharedAccessKey=SomeKey;EntityPath=testhub"); - EXPECT_ANY_THROW( - Azure::Core::Amqp::_internal::Connection connection2("amqp://localhost:5672", options)); + Azure::Core::Amqp::_internal::Connection connection("localhost", {}); } { // Create a connection - Azure::Core::Amqp::_internal::Connection connection("amqps://localhost:5671", {}); + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.Port = Azure::Core::Amqp::_internal::AmqpPort; + + Azure::Core::Amqp::_internal::Connection connection("localhost", connectionOptions); } { Azure::Core::Amqp::_internal::ConnectionOptions options; - auto socketTransport{std::make_shared( - "localhost", Azure::Core::Amqp::_detail::AmqpPort)}; + auto socketTransport{Azure::Core::Amqp::Network::_internal::SocketTransportFactory::Create( + "localhost", Azure::Core::Amqp::_internal::AmqpPort)}; Azure::Core::Amqp::_internal::Connection connection(socketTransport, options); } - { - Azure::Core::Amqp::_internal::ConnectionOptions options; - auto socketTransport{std::make_shared( - "localhost", Azure::Core::Amqp::_detail::AmqpPort)}; - options.SaslCredentials - = std::make_shared( - "Endpoint=sb://testHost.net/" - ";SharedAccessKeyName=SomeName;SharedAccessKey=SomeKey;EntityPath=testhub"); - - EXPECT_ANY_THROW(Azure::Core::Amqp::_internal::Connection connection(socketTransport, options)); - } - -#if 0 - // Create a session - Azure::Core::Amqp::_internal::Session session(connection); - - // Create a sender - Azure::Core::Amqp::Sender sender(session, "test"); - - // Create a receiver - Azure::Core::Amqp::Receiver receiver(session, "test"); - - // Create a message - Azure::Core::Amqp::Message message; - - // Send a message - sender.Send(message); - - // Receive a message - receiver.Receive(); - - // Close the connection - connection.Close(); -#endif } TEST_F(TestConnections, ConnectionAttributes) { - Azure::Core::Amqp::_internal::Connection connection("amqp://localhost:5672", {}); - { + Azure::Core::Amqp::_internal::ConnectionOptions options; + options.IdleTimeout = std::chrono::milliseconds(1532); + + Azure::Core::Amqp::_internal::Connection connection("localhost", options); + + EXPECT_EQ(connection.GetPort(), 5671); + EXPECT_EQ(connection.GetHost(), "localhost"); + auto idleTimeout = connection.GetIdleTimeout(); (void)idleTimeout; - EXPECT_NO_THROW(connection.SetIdleTimeout(std::chrono::milliseconds(1532))); EXPECT_EQ(std::chrono::milliseconds(1532), connection.GetIdleTimeout()); } { + Azure::Core::Amqp::_internal::ConnectionOptions options; + options.MaxFrameSize = 1024 * 64; + options.Port = Azure::Core::Amqp::_internal::AmqpPort; + Azure::Core::Amqp::_internal::Connection connection("localhost", options); + EXPECT_EQ(connection.GetPort(), 5672); + EXPECT_EQ(connection.GetHost(), "localhost"); + auto maxFrameSize = connection.GetMaxFrameSize(); - EXPECT_NO_THROW(connection.SetMaxFrameSize(1024 * 64)); - EXPECT_EQ(1024 * 64, connection.GetMaxFrameSize()); (void)maxFrameSize; + EXPECT_EQ(1024 * 64, connection.GetMaxFrameSize()); EXPECT_NO_THROW( connection.GetRemoteMaxFrameSize()); // Likely doesn't work unless there's a remote. } { + Azure::Core::Amqp::_internal::ConnectionOptions options; + options.MaxChannelCount = 128; + options.Port = Azure::Core::Amqp::_internal::AmqpPort; + + Azure::Core::Amqp::_internal::Connection connection("localhost", options); + EXPECT_EQ(connection.GetPort(), 5672); + EXPECT_EQ(connection.GetHost(), "localhost"); + auto maxChannel = connection.GetMaxChannel(); - EXPECT_NO_THROW(connection.SetMaxChannel(128)); EXPECT_EQ(128, connection.GetMaxChannel()); (void)maxChannel; } { + Azure::Core::Amqp::_internal::ConnectionOptions options; + options.MaxChannelCount = 128; + + Azure::Core::Amqp::_internal::Connection connection("localhost", options); // Ratio must be a number between 0 and 1. - EXPECT_NO_THROW(connection.SetRemoteIdleTimeoutEmptyFrameSendRatio(0.5)); + EXPECT_NO_THROW(connection.SetIdleEmptyFrameSendPercentage(0.5)); } { - EXPECT_NO_THROW(connection.SetProperties("32.95")); - EXPECT_EQ(std::string("32.95"), static_cast(connection.GetProperties())); + Azure::Core::Amqp::_internal::ConnectionOptions options; + options.MaxChannelCount = 128; + options.Properties["test"] = "test"; + + Azure::Core::Amqp::_internal::Connection connection("localhost", options); + EXPECT_EQ(Azure::Core::Amqp::Models::AmqpValue{"test"}, connection.GetProperties()["test"]); } } @@ -130,7 +123,7 @@ TEST_F(TestConnections, ConnectionOpenClose) public: std::shared_ptr WaitForResult( Azure::Core::Amqp::Network::_internal::SocketListener const& listener, - Azure::Core::Context context = {}) + Azure::Core::Context const& context = {}) { GTEST_LOG_(INFO) << "Waiting for listener to accept connection."; auto result = m_listenerQueue.WaitForPolledResult(context, listener); @@ -146,7 +139,6 @@ TEST_F(TestConnections, ConnectionOpenClose) std::shared_ptr transport) { GTEST_LOG_(INFO) << "Socket for listener accepted connection."; - // Capture the XIO into a transport so it won't leak. m_listenerQueue.CompleteOperation(transport); } }; @@ -163,8 +155,9 @@ TEST_F(TestConnections, ConnectionOpenClose) EXPECT_NO_THROW(listener.Start()); // Create a connection - Azure::Core::Amqp::_internal::Connection connection( - "amqp://localhost:" + std::to_string(testPort), {}); + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.Port = testPort; + Azure::Core::Amqp::_internal::Connection connection("localhost", connectionOptions); // Open the connection connection.Open(); @@ -182,13 +175,7 @@ TEST_F(TestConnections, ConnectionOpenClose) { Azure::Core::Amqp::_internal::ConnectionOptions options; - options.HostName = "localhost"; - options.Port = Azure::Core::Amqp::_detail::AmqpsPort; - // std::shared_ptr sockets - // = - // std::make_shared("localhost", - // AmqpsPort); - Azure::Core::Amqp::_internal::Connection connection("amqp://localhost:5671", options); + Azure::Core::Amqp::_internal::Connection connection("localhost", options); } } @@ -199,7 +186,7 @@ class TestSocketListenerEvents : public Azure::Core::Amqp::_internal::SessionEve public: std::unique_ptr WaitForListener( Azure::Core::Amqp::Network::_internal::SocketListener const& listener, - Azure::Core::Context context = {}) + Azure::Core::Context const& context = {}) { auto result = m_listeningQueue.WaitForPolledResult(context, listener); return std::move(std::get<0>(*result)); @@ -215,15 +202,14 @@ class TestSocketListenerEvents : public Azure::Core::Amqp::_internal::SessionEve virtual void OnSocketAccepted( std::shared_ptr transport) override { - std::shared_ptr amqpTransport{ - std::make_shared( + auto amqpTransport{ + Azure::Core::Amqp::Network::_internal::AmqpHeaderDetectTransportFactory::Create( transport, nullptr)}; Azure::Core::Amqp::_internal::ConnectionOptions options; options.ContainerId = "containerId"; - options.HostName = "localhost"; + options.EnableTrace = true; auto newConnection{ std::make_unique(amqpTransport, options, this)}; - newConnection->SetTrace(true); newConnection->Listen(); m_listeningQueue.CompleteOperation(std::move(newConnection)); } @@ -233,13 +219,13 @@ class TestSocketListenerEvents : public Azure::Core::Amqp::_internal::SessionEve Azure::Core::Amqp::_internal::LinkEndpoint& newLinkInstance, std::string const& name, Azure::Core::Amqp::_internal::SessionRole, - Azure::Core::Amqp::Models::AmqpValue source, - Azure::Core::Amqp::Models::AmqpValue target, - Azure::Core::Amqp::Models::AmqpValue) override + Azure::Core::Amqp::Models::AmqpValue const& source, + Azure::Core::Amqp::Models::AmqpValue const& target, + Azure::Core::Amqp::Models::AmqpValue const&) override { Azure::Core::Amqp::_internal::MessageReceiverOptions receiverOptions; receiverOptions.Name = name; - receiverOptions.TargetAddress = static_cast(target); + receiverOptions.MessageTarget = static_cast(target); receiverOptions.SettleMode = Azure::Core::Amqp::_internal::ReceiverSettleMode::First; m_messageReceiver = std::make_unique( @@ -262,14 +248,16 @@ class TestSocketListenerEvents : public Azure::Core::Amqp::_internal::SessionEve Azure::Core::Amqp::_internal::Connection const& connection, Azure::Core::Amqp::_internal::Endpoint& endpoint) override { - m_listeningSession - = std::make_unique(connection, endpoint, this); - m_listeningSession->SetIncomingWindow(10000); + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = 10000; + m_listeningSession = std::make_unique( + connection, endpoint, sessionOptions, this); + m_listeningSession->Begin(); return true; } - virtual void OnIoError(Azure::Core::Amqp::_internal::Connection const&) override {} + virtual void OnIOError(Azure::Core::Amqp::_internal::Connection const&) override {} // Inherited via MessageReceiver virtual Azure::Core::Amqp::Models::AmqpValue OnMessageReceived( Azure::Core::Amqp::_internal::MessageReceiver const&, @@ -297,14 +285,15 @@ TEST_F(TestConnections, ConnectionListenClose) // Ensure someone is listening on the connection for when we call connection.Open. TestSocketListenerEvents listenerEvents; Azure::Core::Amqp::Network::_internal::SocketListener listener( - Azure::Core::Amqp::_detail::AmqpPort, &listenerEvents); + Azure::Core::Amqp::_internal::AmqpPort, &listenerEvents); listener.Start(); { // Create a connection - Azure::Core::Amqp::_internal::Connection connection("amqp://localhost:5672", {}); - + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.Port = Azure::Core::Amqp::_internal::AmqpPort; + Azure::Core::Amqp::_internal::Connection connection("localhost", connectionOptions); // Open the connection connection.Open(); @@ -319,9 +308,8 @@ TEST_F(TestConnections, ConnectionListenClose) { Azure::Core::Amqp::_internal::ConnectionOptions options; - options.HostName = "localhost"; - options.Port = Azure::Core::Amqp::_detail::AmqpsPort; - Azure::Core::Amqp::_internal::Connection connection("amqp://localhost:5672", options); + options.Port = Azure::Core::Amqp::_internal::AmqpPort; + Azure::Core::Amqp::_internal::Connection connection("localhost", options); } listener.Stop(); diff --git a/sdk/core/azure-core-amqp/test/ut/link_tests.cpp b/sdk/core/azure-core-amqp/test/ut/link_tests.cpp index 0e9fd8b294..b0290f7355 100644 --- a/sdk/core/azure-core-amqp/test/ut/link_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/link_tests.cpp @@ -10,11 +10,14 @@ #include "azure/core/amqp/network/socket_listener.hpp" #include "azure/core/amqp/network/socket_transport.hpp" #include "azure/core/amqp/session.hpp" + #include + #include -#include #include +#include + extern uint16_t FindAvailableSocket(); class TestLinks : public testing::Test { @@ -32,7 +35,9 @@ TEST_F(TestLinks, SimpleLink) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + + Connection connection("localhost", {}); + // Create a session Session session(connection, nullptr); @@ -69,7 +74,7 @@ TEST_F(TestLinks, SimpleLink) TEST_F(TestLinks, LinkProperties) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + Connection connection("localhost", {}); Session session(connection, nullptr); { @@ -114,19 +119,15 @@ TEST_F(TestLinks, LinkProperties) Link link(session, "MySession", SessionRole::Sender, "MySource", "MyTarget"); Link link2(link); - Link link3(link.GetImpl()); - EXPECT_EQ(link.GetInitialDeliveryCount(), link2.GetInitialDeliveryCount()); - EXPECT_EQ(link.GetInitialDeliveryCount(), link3.GetInitialDeliveryCount()); // If I set the initial delivery count on one link, it should affect all the copies of that // link. link.SetInitialDeliveryCount(32767); EXPECT_EQ(link.GetInitialDeliveryCount(), link2.GetInitialDeliveryCount()); - EXPECT_EQ(link.GetInitialDeliveryCount(), link3.GetInitialDeliveryCount()); - EXPECT_EQ("MySource", link.GetSource()); - EXPECT_EQ("MyTarget", link.GetTarget()); + EXPECT_EQ(Azure::Core::Amqp::Models::AmqpValue{"MySource"}, link.GetSource().GetAddress()); + EXPECT_EQ(Azure::Core::Amqp::Models::AmqpValue{"MyTarget"}, link.GetTarget().GetAddress()); } } @@ -147,13 +148,12 @@ class LinkSocketListenerEvents : public Azure::Core::Amqp::Network::_internal::S std::shared_ptr transport) override { GTEST_LOG_(INFO) << "OnSocketAccepted - Socket connection received."; - std::shared_ptr amqpTransport{ - std::make_shared( + auto amqpTransport{ + Azure::Core::Amqp::Network::_internal::AmqpHeaderDetectTransportFactory::Create( transport, nullptr)}; Azure::Core::Amqp::_internal::ConnectionOptions options; options.ContainerId = "connectionId"; options.EnableTrace = true; - options.Transport = amqpTransport; m_connection = std::make_shared(amqpTransport, options, this); m_connection->Listen(); @@ -173,25 +173,26 @@ class LinkSocketListenerEvents : public Azure::Core::Amqp::Network::_internal::S Azure::Core::Amqp::_internal::Endpoint& endpoint) override { GTEST_LOG_(INFO) << "OnNewEndpoint - Incoming endpoint created, create session."; - auto listeningSession - = std::make_unique(connection, endpoint, this); - listeningSession->SetIncomingWindow(10000); + Azure::Core::Amqp::_internal::SessionOptions sessionOptions; + sessionOptions.InitialIncomingWindowSize = 10000; + auto listeningSession = std::make_unique( + connection, endpoint, sessionOptions, this); listeningSession->Begin(); m_listeningSessionQueue.CompleteOperation(std::move(listeningSession)); return true; } - virtual void OnIoError(Azure::Core::Amqp::_internal::Connection const&) override {} + virtual void OnIOError(Azure::Core::Amqp::_internal::Connection const&) override {} // Inherited via Session virtual bool OnLinkAttached( Azure::Core::Amqp::_internal::Session const& session, Azure::Core::Amqp::_internal::LinkEndpoint& newLinkInstance, std::string const& name, Azure::Core::Amqp::_internal::SessionRole, - Azure::Core::Amqp::Models::AmqpValue source, - Azure::Core::Amqp::Models::AmqpValue target, - Azure::Core::Amqp::Models::AmqpValue) override + Azure::Core::Amqp::Models::AmqpValue const& source, + Azure::Core::Amqp::Models::AmqpValue const& target, + Azure::Core::Amqp::Models::AmqpValue const&) override { GTEST_LOG_(INFO) << "OnLinkAttached - Link attached to session."; auto newLink = std::make_unique( @@ -211,17 +212,17 @@ class LinkSocketListenerEvents : public Azure::Core::Amqp::Network::_internal::S LinkSocketListenerEvents() {} std::shared_ptr WaitForConnection( Azure::Core::Amqp::Network::_internal::SocketListener const& listener, - Azure::Core::Context context) + Azure::Core::Context const& context) { auto result = m_listeningQueue.WaitForPolledResult(context, listener); return std::move(std::get<0>(*result)); } - std::unique_ptr WaitForSession(Azure::Core::Context context) + std::unique_ptr WaitForSession(Azure::Core::Context const& context) { auto result = m_listeningSessionQueue.WaitForPolledResult(context, *m_connection); return std::move(std::get<0>(*result)); } - std::unique_ptr WaitForLink(Azure::Core::Context context) + std::unique_ptr WaitForLink(Azure::Core::Context const& context) { auto result = m_receiveLinkQueue.WaitForPolledResult(context, *m_connection); return std::move(std::get<0>(*result)); @@ -235,7 +236,9 @@ TEST_F(TestLinks, LinkAttachDetach) uint16_t testPort = FindAvailableSocket(); GTEST_LOG_(INFO) << "Test port: " << testPort; // Create a connection - Connection connection("amqp://localhost:" + std::to_string(testPort), {}, &events); + ConnectionOptions connectionOptions; + connectionOptions.Port = testPort; + Connection connection("localhost", connectionOptions, &events); Session session(connection, nullptr); Network::_internal::SocketListener listener(testPort, &events); diff --git a/sdk/core/azure-core-amqp/test/ut/management_tests.cpp b/sdk/core/azure-core-amqp/test/ut/management_tests.cpp index eab06b225c..bb4b95d16a 100644 --- a/sdk/core/azure-core-amqp/test/ut/management_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/management_tests.cpp @@ -2,11 +2,13 @@ // SPDX-Licence-Identifier: MIT #include "mock_amqp_server.hpp" + #include #include #include #include #include + #include class TestManagement : public testing::Test { @@ -18,20 +20,26 @@ class TestManagement : public testing::Test { using namespace Azure::Core::Amqp::Models; using namespace Azure::Core::Amqp::_internal; +#if !defined(AZ_PLATFORM_MAC) TEST_F(TestManagement, BasicTests) { { - Connection connection("amqps://localhost:5151", {}); - Session session(connection); + ConnectionOptions options; + options.Port = 5151; + Connection connection("localhost", options); + + Session session(connection, nullptr); Management management(session, "Test", {}); } } -#if !defined(AZ_PLATFORM_MAC) TEST_F(TestManagement, ManagementOpenClose) { { - Connection connection("amqps://localhost:5151", {}); - Session session(connection); + ConnectionOptions options; + options.Port = 5151; + Connection connection("localhost", options); + + Session session(connection, nullptr); Management management(session, "Test", {}); EXPECT_ANY_THROW(management.Open()); @@ -42,8 +50,11 @@ TEST_F(TestManagement, ManagementOpenClose) { MessageTests::AmqpServerMock mockServer; - Connection connection("amqp://localhost:" + std::to_string(mockServer.GetPort()), {}); - Session session(connection); + ConnectionOptions connectionOptions; + connectionOptions.Port = mockServer.GetPort(); + Connection connection("localhost", connectionOptions); + + Session session(connection, nullptr); ManagementOptions options; options.EnableTrace = 1; Management management(session, "Test", {}); @@ -82,13 +93,15 @@ class ManagementReceiver : public MessageTests::AmqpServerMock { AmqpValue OnMessageReceived(MessageReceiver const& receiver, AmqpMessage const& incomingMessage) override { - if (receiver.GetSourceName() != "Test" && receiver.GetSourceName() != "$cbs") + // We can only listen on the management or cbs nodes. + if (receiver.GetSourceName() != "$management" && receiver.GetSourceName() != "$cbs") { GTEST_LOG_(INFO) << "Rejecting message because it is for an unexpected node name."; return Azure::Core::Amqp::Models::_internal::Messaging::DeliveryRejected( "test:Rejected", "Unknown message source."); } - if (receiver.GetSourceName() == "Test" + // If this is coming on the management node, we only support the Test operation. + if (receiver.GetSourceName() == "$management" && incomingMessage.ApplicationProperties.at("operation") != "Test") { GTEST_LOG_(INFO) << "Rejecting message because is for an unknown operation."; @@ -138,8 +151,11 @@ TEST_F(TestManagement, ManagementRequestResponse) { MessageTests::AmqpServerMock mockServer; - Connection connection("amqp://localhost:" + std::to_string(mockServer.GetPort()), {}); - Session session(connection); + ConnectionOptions connectionOptions; + connectionOptions.Port = mockServer.GetPort(); + + Connection connection("localhost", connectionOptions); + Session session(connection, nullptr); ManagementOptions options; options.EnableTrace = 1; Management management(session, "Test", {}); @@ -170,8 +186,12 @@ TEST_F(TestManagement, ManagementRequestResponseSimple) { ManagementReceiver mockServer; - Connection connection("amqp://localhost:" + std::to_string(mockServer.GetPort()), {}); - Session session(connection); + ConnectionOptions connectionOptions; + connectionOptions.EnableTrace = true; + connectionOptions.Port = mockServer.GetPort(); + + Connection connection("localhost", connectionOptions); + Session session(connection, nullptr); ManagementOptions options; options.EnableTrace = true; Management management(session, "Test", options); @@ -198,12 +218,12 @@ TEST_F(TestManagement, ManagementRequestResponseExpect500) { ManagementReceiver mockServer; - ConnectionOptions connectOptions; - connectOptions.EnableTrace = true; + ConnectionOptions connectionOptions; + connectionOptions.EnableTrace = true; + connectionOptions.Port = mockServer.GetPort(); - Connection connection( - "amqp://localhost:" + std::to_string(mockServer.GetPort()), connectOptions); - Session session(connection); + Connection connection("localhost", connectionOptions); + Session session(connection, nullptr); ManagementOptions options; options.EnableTrace = true; @@ -234,11 +254,11 @@ TEST_F(TestManagement, ManagementRequestResponseBogusStatusCode) { ManagementReceiver mockServer; - ConnectionOptions connectOptions; - connectOptions.EnableTrace = true; - Connection connection( - "amqp://localhost:" + std::to_string(mockServer.GetPort()), connectOptions); - Session session(connection); + ConnectionOptions connectionOptions; + connectionOptions.EnableTrace = true; + connectionOptions.Port = mockServer.GetPort(); + Connection connection("localhost", connectionOptions); + Session session(connection, nullptr); ManagementOptions options; options.EnableTrace = true; Management management(session, "Test", options); @@ -277,11 +297,12 @@ TEST_F(TestManagement, ManagementRequestResponseBogusStatusName) }; ManagementEventsHandler managementEvents; - ConnectionOptions connectOptions; - connectOptions.EnableTrace = true; - Connection connection( - "amqp://localhost:" + std::to_string(mockServer.GetPort()), connectOptions); - Session session(connection); + ConnectionOptions connectionOptions; + connectionOptions.EnableTrace = true; + connectionOptions.Port = mockServer.GetPort(); + + Connection connection("localhost", connectionOptions); + Session session(connection, nullptr); ManagementOptions options; options.EnableTrace = true; @@ -316,11 +337,11 @@ TEST_F(TestManagement, ManagementRequestResponseBogusStatusName2) { ManagementReceiver mockServer; - ConnectionOptions connectOptions; - connectOptions.EnableTrace = true; - Connection connection( - "amqp://localhost:" + std::to_string(mockServer.GetPort()), connectOptions); - Session session(connection); + ConnectionOptions connectionOptions; + connectionOptions.EnableTrace = true; + connectionOptions.Port = mockServer.GetPort(); + Connection connection("localhost", connectionOptions); + Session session(connection, nullptr); ManagementOptions options; options.EnableTrace = true; options.ExpectedStatusCodeKeyName = "status-code"; @@ -349,63 +370,38 @@ TEST_F(TestManagement, ManagementRequestResponseBogusStatusName2) mockServer.StopListening(); } } -TEST_F(TestManagement, ManagementRequestResponseInvalidNodeName) -{ - // Send a management request with an invalid node name. - { - ManagementReceiver mockServer; - - ConnectionOptions connectOptions; - connectOptions.EnableTrace = true; - Connection connection( - "amqp://localhost:" + std::to_string(mockServer.GetPort()), connectOptions); - Session session(connection); - ManagementOptions options; - options.EnableTrace = true; - Management management(session, "IncorrectNodeName", options); - - mockServer.StartListening(); - auto openResult = management.Open(); - ASSERT_EQ(openResult, ManagementOpenStatus::Ok); - - AmqpMessage messageToSend; - messageToSend.SetBody(AmqpValue("Test")); - - auto response = management.ExecuteOperation("Test", "Type", "Locales", messageToSend); - EXPECT_EQ(response.Status, ManagementOperationStatus::Error); - EXPECT_EQ(response.StatusCode, 0); - EXPECT_EQ(response.Description, ""); - management.Close(); - - mockServer.StopListening(); - } -} TEST_F(TestManagement, ManagementRequestResponseUnknownOperationName) { // Send a management request with an unknown operation name. { ManagementReceiver mockServer; + mockServer.StartListening(); + + ConnectionOptions connectionOptions; + connectionOptions.EnableTrace = true; + connectionOptions.Port = mockServer.GetPort(); + Connection connection("localhost", connectionOptions); + + Session session(connection, nullptr); - ConnectionOptions connectOptions; - connectOptions.EnableTrace = true; - Connection connection( - "amqp://localhost:" + std::to_string(mockServer.GetPort()), connectOptions); - Session session(connection); ManagementOptions options; options.EnableTrace = true; Management management(session, "Test", options); - mockServer.StartListening(); - auto openResult = management.Open(); ASSERT_EQ(openResult, ManagementOpenStatus::Ok); AmqpMessage messageToSend; messageToSend.SetBody(AmqpValue("Test")); - auto response - = management.ExecuteOperation("Unknown Operation", "Type", "Locales", messageToSend); + auto response = management.ExecuteOperation( + "Unknown Operation", + "Type", + "Locales", + messageToSend, + Azure::Core::Context::ApplicationContext.WithDeadline( + std::chrono::system_clock::now() + std::chrono::seconds(10))); EXPECT_EQ(response.Status, ManagementOperationStatus::Error); EXPECT_EQ(response.StatusCode, 0); EXPECT_EQ(response.Description, ""); diff --git a/sdk/core/azure-core-amqp/test/ut/message_sender_receiver.cpp b/sdk/core/azure-core-amqp/test/ut/message_sender_receiver.cpp index 575b4e2d8b..b4f7d08a54 100644 --- a/sdk/core/azure-core-amqp/test/ut/message_sender_receiver.cpp +++ b/sdk/core/azure-core-amqp/test/ut/message_sender_receiver.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT -#include - #include "azure/core/amqp/common/async_operation_queue.hpp" #include "azure/core/amqp/connection.hpp" #include "azure/core/amqp/message_receiver.hpp" @@ -14,11 +12,13 @@ #include "azure/core/amqp/network/socket_listener.hpp" #include "azure/core/amqp/session.hpp" #include "mock_amqp_server.hpp" + #include + #include #include -#include "mock_amqp_server.hpp" +#include extern uint16_t FindAvailableSocket(); @@ -36,7 +36,7 @@ TEST_F(TestMessages, SimpleReceiver) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + Connection connection("localhost", {}); // Create a session Session session(connection, nullptr); // Link link(session, "MySession", SessionRole::Receiver, "MySource", "MyTarget"); @@ -51,13 +51,14 @@ TEST_F(TestMessages, SimpleReceiver) } TEST_F(TestMessages, ReceiverProperties) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + Connection connection("localhost", {}); Session session(connection, nullptr); { - MessageReceiver receiver(session, "MyTarget", {}); + MessageReceiverOptions options; + options.EnableTrace = true; + MessageReceiver receiver(session, "MyTarget", options); EXPECT_ANY_THROW(receiver.GetLinkName()); - receiver.SetTrace(true); } { @@ -73,7 +74,7 @@ TEST_F(TestMessages, SimpleSender) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + Connection connection("localhost", {}); // Create a session Session session(connection, nullptr); // Link link(session, "MySession", SessionRole::Sender, "MySource", "MyTarget"); @@ -88,12 +89,13 @@ TEST_F(TestMessages, SimpleSender) } TEST_F(TestMessages, SenderProperties) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + Connection connection("localhost", {}); Session session(connection, nullptr); { - MessageSender sender(session, "MySource", {}, nullptr); - sender.SetTrace(true); + MessageSenderOptions options; + options.EnableTrace = true; + MessageSender sender(session, "MySource", options, nullptr); } } @@ -109,7 +111,7 @@ class MessageListenerEvents : public Azure::Core::Amqp::Network::_internal::Sock std::shared_ptr WaitForConnection( Azure::Core::Amqp::Network::_internal::SocketListener const& listener, - Azure::Core::Context context) + Azure::Core::Context const& context) { auto result = m_listeningQueue.WaitForPolledResult(context, listener); if (result) @@ -119,7 +121,7 @@ class MessageListenerEvents : public Azure::Core::Amqp::Network::_internal::Sock return nullptr; } std::unique_ptr WaitForSession( - Azure::Core::Context context) + Azure::Core::Context const& context) { auto result = m_listeningSessionQueue.WaitForPolledResult(context, *m_connectionToPoll); if (result) @@ -128,7 +130,7 @@ class MessageListenerEvents : public Azure::Core::Amqp::Network::_internal::Sock } return nullptr; } - std::unique_ptr WaitForReceiver(Azure::Core::Context context) + std::unique_ptr WaitForReceiver(Azure::Core::Context const& context) { auto result = m_messageReceiverQueue.WaitForPolledResult(context, *m_connectionToPoll); if (result) @@ -137,7 +139,7 @@ class MessageListenerEvents : public Azure::Core::Amqp::Network::_internal::Sock } return nullptr; } - Azure::Core::Amqp::Models::AmqpMessage WaitForMessage(Azure::Core::Context context) + Azure::Core::Amqp::Models::AmqpMessage WaitForMessage(Azure::Core::Context const& context) { auto result = m_messageQueue.WaitForPolledResult(context, *m_connectionToPoll); if (result) @@ -167,8 +169,8 @@ class MessageListenerEvents : public Azure::Core::Amqp::Network::_internal::Sock std::shared_ptr transport) override { GTEST_LOG_(INFO) << "OnSocketAccepted - Socket connection received."; - std::shared_ptr amqpTransport{ - std::make_shared( + auto amqpTransport{ + Azure::Core::Amqp::Network::_internal::AmqpHeaderDetectTransportFactory::Create( transport, nullptr)}; Azure::Core::Amqp::_internal::ConnectionOptions options; // options.IdleTimeout = std::chrono::minutes(5); @@ -194,16 +196,17 @@ class MessageListenerEvents : public Azure::Core::Amqp::Network::_internal::Sock Endpoint& endpoint) override { GTEST_LOG_(INFO) << "OnNewEndpoint - Incoming endpoint created, create session."; - auto listeningSession - = std::make_unique(connection, endpoint, this); - listeningSession->SetIncomingWindow(10000); + Azure::Core::Amqp::_internal::SessionOptions options; + options.InitialIncomingWindowSize = 10000; + auto listeningSession = std::make_unique( + connection, endpoint, options, this); listeningSession->Begin(); m_listeningSessionQueue.CompleteOperation(std::move(listeningSession)); return true; } - virtual void OnIoError(Azure::Core::Amqp::_internal::Connection const&) override {} + virtual void OnIOError(Azure::Core::Amqp::_internal::Connection const&) override {} // Inherited via SessionEvents virtual bool OnLinkAttached( @@ -211,25 +214,25 @@ class MessageListenerEvents : public Azure::Core::Amqp::Network::_internal::Sock Azure::Core::Amqp::_internal::LinkEndpoint& newLinkInstance, std::string const& name, Azure::Core::Amqp::_internal::SessionRole, - Azure::Core::Amqp::Models::AmqpValue source, - Azure::Core::Amqp::Models::AmqpValue target, - Azure::Core::Amqp::Models::AmqpValue properties) override + Azure::Core::Amqp::Models::AmqpValue const& source, + Azure::Core::Amqp::Models::AmqpValue const& target, + Azure::Core::Amqp::Models::AmqpValue const& properties) override { GTEST_LOG_(INFO) << "OnLinkAttached - Link attached to session."; MessageReceiverOptions receiverOptions; Azure::Core::Amqp::Models::_internal::MessageTarget messageTarget(target); Azure::Core::Amqp::Models::_internal::MessageSource messageSource(source); - receiverOptions.TargetAddress = static_cast(messageTarget.GetAddress()); + receiverOptions.MessageTarget = messageTarget; receiverOptions.Name = name; receiverOptions.SettleMode = Azure::Core::Amqp::_internal::ReceiverSettleMode::First; receiverOptions.DynamicAddress = messageSource.GetDynamic(); + receiverOptions.EnableTrace = true; auto receiver = std::make_unique( session, newLinkInstance, static_cast(messageSource.GetAddress()), receiverOptions, this); - receiver->SetTrace(true); GTEST_LOG_(INFO) << "Opening the message receiver."; receiver->Open(); m_messageReceiverQueue.CompleteOperation(std::move(receiver)); @@ -268,8 +271,9 @@ TEST_F(TestMessages, ReceiverOpenClose) MessageTests::MessageListenerEvents events; ConnectionOptions connectionOptions; // connectionOptions.IdleTimeout = std::chrono::minutes(5); - Connection connection("amqp://localhost:" + std::to_string(testPort), connectionOptions, &events); - connection.SetTrace(true); + connectionOptions.EnableTrace = true; + connectionOptions.Port = testPort; + Connection connection("localhost", connectionOptions); Session session(connection, nullptr); Azure::Core::Amqp::Network::_internal::SocketListener listener(testPort, &events); @@ -335,9 +339,10 @@ TEST_F(TestMessages, SenderOpenClose) uint16_t testPort = FindAvailableSocket(); GTEST_LOG_(INFO) << "Test port: " << testPort; ConnectionOptions connectionOptions; - // connectionOptions.IdleTimeout = std::chrono::minutes(5); + connectionOptions.IdleTimeout = std::chrono::minutes(5); + connectionOptions.Port = testPort; - Connection connection("amqp://localhost:" + std::to_string(testPort), connectionOptions); + Connection connection("localhost", connectionOptions); Session session(connection, nullptr); // Link link(session, "MySession", SessionRole::Receiver, "MySource", "MyTarget"); @@ -345,7 +350,7 @@ TEST_F(TestMessages, SenderOpenClose) EXPECT_NO_THROW(listener.Start()); { MessageSenderOptions options; - options.SourceAddress = "MySource"; + options.MessageSource = "MySource"; MessageSender sender(session, "MyTarget", options, nullptr); sender.Open(); @@ -355,6 +360,80 @@ TEST_F(TestMessages, SenderOpenClose) listener.Stop(); } +TEST_F(TestMessages, TestLocalhostVsTls) +{ + MessageTests::AmqpServerMock mockServer(5671); + + mockServer.StartListening(); + + ConnectionOptions connectionOptions; + // connectionOptions.IdleTimeout = std::chrono::minutes(5); + connectionOptions.ContainerId = "some"; + // connectionOptions.EnableTrace = true; + connectionOptions.Port = mockServer.GetPort(); + Connection connection("localhost", connectionOptions); + Session session(connection, nullptr); + + { + class SenderEvents : public MessageSenderEvents { + virtual void OnMessageSenderStateChanged( + MessageSender const& sender, + MessageSenderState newState, + MessageSenderState oldState) override + { + GTEST_LOG_(INFO) << "MessageSenderEvents::OnMessageSenderStateChanged. OldState: " + << std::to_string(static_cast(oldState)) + << " NewState: " << std::to_string(static_cast(newState)); + (void)sender; + } + }; + + SenderEvents senderEvents; + MessageSenderOptions options; + options.Name = "sender-link"; + options.MessageSource = "ingress"; + options.SettleMode = SenderSettleMode::Settled; + options.MaxMessageSize = 65536; + MessageSender sender(session, "localhost/ingress", options, &senderEvents); + EXPECT_NO_THROW(sender.Open()); + + Azure::Core::Amqp::Models::AmqpMessage message; + message.SetBody(Azure::Core::Amqp::Models::AmqpBinaryData{'h', 'e', 'l', 'l', 'o'}); + + Azure::Core::Context context; + Azure::Core::Amqp::Common::_internal:: + AsyncOperationQueue + sendCompleteQueue; + sender.QueueSend( + message, + [&](MessageSendStatus sendResult, Azure::Core::Amqp::Models::AmqpValue deliveryStatus) { + GTEST_LOG_(INFO) << "Send Complete!"; + sendCompleteQueue.CompleteOperation(sendResult, deliveryStatus); + }); + try + { + + auto result = sendCompleteQueue.WaitForPolledResult(context, connection); + // Because we're trying to use TLS to connect to a non-TLS port, we should get an error + // sending the message. + EXPECT_EQ(std::get<0>(*result), MessageSendStatus::Error); + } + catch (Azure::Core::OperationCancelledException const&) + { + GTEST_LOG_(INFO) << "Operation cancelled."; + } + catch (std::runtime_error const& ex) + { + // The WaitForPolledResult call can throw an exception if the connection enters the "End" + // state. + GTEST_LOG_(INFO) << "Exception: " << ex.what(); + } + sender.Close(); + } + connection.Close("", "", Models::AmqpValue()); + mockServer.StopListening(); +} + TEST_F(TestMessages, SenderSendAsync) { uint16_t testPort = FindAvailableSocket(); @@ -365,10 +444,13 @@ TEST_F(TestMessages, SenderSendAsync) // connectionOptions.IdleTimeout = std::chrono::minutes(5); connectionOptions.ContainerId = "some"; // connectionOptions.EnableTrace = true; - Connection connection("amqp://localhost:" + std::to_string(testPort), connectionOptions); + connectionOptions.Port = testPort; + Connection connection("localhost", connectionOptions); Session session(connection, nullptr); - Azure::Core::Context receiveContext; + // Set up a 30 second deadline on the receiver. + Azure::Core::Context receiveContext = Azure::Core::Context::ApplicationContext.WithDeadline( + Azure::DateTime::clock::now() + std::chrono::seconds(15)); // Ensure that the thread is started before we start using the message sender. std::mutex threadRunningMutex; @@ -381,7 +463,7 @@ TEST_F(TestMessages, SenderSendAsync) MessageTests::MessageListenerEvents events; Azure::Core::Amqp::Network::_internal::SocketListener listener(testPort, &events); - EXPECT_NO_THROW(listener.Start()); + ASSERT_NO_THROW(listener.Start()); running = true; threadStarted.notify_one(); @@ -421,7 +503,7 @@ TEST_F(TestMessages, SenderSendAsync) SenderEvents senderEvents; MessageSenderOptions options; options.Name = "sender-link"; - options.SourceAddress = "ingress"; + options.MessageSource = "ingress"; options.SettleMode = SenderSettleMode::Settled; options.MaxMessageSize = 65536; MessageSender sender(session, "localhost/ingress", options, &senderEvents); @@ -432,16 +514,16 @@ TEST_F(TestMessages, SenderSendAsync) Azure::Core::Context context; Azure::Core::Amqp::Common::_internal:: - AsyncOperationQueue + AsyncOperationQueue sendCompleteQueue; sender.QueueSend( message, - [&](MessageSendResult sendResult, Azure::Core::Amqp::Models::AmqpValue deliveryStatus) { + [&](MessageSendStatus sendResult, Azure::Core::Amqp::Models::AmqpValue deliveryStatus) { GTEST_LOG_(INFO) << "Send Complete!"; sendCompleteQueue.CompleteOperation(sendResult, deliveryStatus); }); auto result = sendCompleteQueue.WaitForPolledResult(context, connection); - EXPECT_EQ(std::get<0>(*result), MessageSendResult::Ok); + EXPECT_EQ(std::get<0>(*result), MessageSendStatus::Ok); sender.Close(); } @@ -459,7 +541,8 @@ TEST_F(TestMessages, SenderSendSync) // connectionOptions.IdleTimeout = std::chrono::minutes(5); connectionOptions.ContainerId = "some"; - Connection connection("amqp://localhost:" + std::to_string(testPort), connectionOptions); + connectionOptions.Port = testPort; + Connection connection("localhost", connectionOptions); Session session(connection, nullptr); Azure::Core::Context receiveContext; @@ -505,7 +588,7 @@ TEST_F(TestMessages, SenderSendSync) MessageSenderOptions options; options.SettleMode = SenderSettleMode::Settled; options.MaxMessageSize = 65536; - options.SourceAddress = "ingress"; + options.MessageSource = "ingress"; options.Name = "sender-link"; MessageSender sender(session, "localhost/ingress", options, nullptr); EXPECT_NO_THROW(sender.Open()); @@ -514,10 +597,10 @@ TEST_F(TestMessages, SenderSendSync) message.SetBody(Azure::Core::Amqp::Models::AmqpValue{"Hello"}); Azure::Core::Amqp::Common::_internal:: - AsyncOperationQueue + AsyncOperationQueue sendCompleteQueue; auto result = sender.Send(message); - EXPECT_EQ(std::get<0>(result), MessageSendResult::Ok); + EXPECT_EQ(std::get<0>(result), MessageSendStatus::Ok); sender.Close(); } @@ -537,22 +620,20 @@ TEST_F(TestMessages, AuthenticatedSender) // connectionOptions.IdleTimeout = std::chrono::minutes(5); connectionOptions.ContainerId = "some"; - connectionOptions.HostName = sasCredential->GetHostName(); - connectionOptions.Port = sasCredential->GetPort(); - Connection connection(sasCredential->GetTransport(), connectionOptions); - Session session(connection, nullptr); + connectionOptions.Port = server.GetPort(); + Connection connection("localhost", connectionOptions); + Session session(connection, sasCredential); server.StartListening(); MessageSenderOptions senderOptions; senderOptions.Name = "sender-link"; - senderOptions.SourceAddress = "ingress"; + senderOptions.MessageSource = "ingress"; senderOptions.SettleMode = Azure::Core::Amqp::_internal::SenderSettleMode::Settled; senderOptions.MaxMessageSize = 65536; senderOptions.Name = "sender-link"; MessageSender sender( session, - sasCredential, sasCredential->GetEndpoint() + sasCredential->GetEntityPath(), senderOptions, nullptr); @@ -598,19 +679,18 @@ TEST_F(TestMessages, AuthenticatedSenderAzureToken) // connectionOptions.IdleTimeout = std::chrono::minutes(5); connectionOptions.ContainerId = "some"; - connectionOptions.HostName = hostName; - connectionOptions.Port = port; - Connection connection(endpoint, connectionOptions); - Session session(connection, nullptr); + connectionOptions.Port = server.GetPort(); + Connection connection(hostName, connectionOptions); + Session session(connection, tokenCredential); server.StartListening(); MessageSenderOptions senderOptions; senderOptions.Name = "sender-link"; - senderOptions.SourceAddress = "ingress"; + senderOptions.MessageSource = "ingress"; senderOptions.SettleMode = Azure::Core::Amqp::_internal::SenderSettleMode::Settled; senderOptions.MaxMessageSize = 65536; senderOptions.Name = "sender-link"; - MessageSender sender(session, tokenCredential, endpoint, senderOptions, nullptr); + MessageSender sender(session, endpoint, senderOptions, nullptr); sender.Open(); Azure::Core::Amqp::Models::AmqpMessage message; @@ -659,24 +739,22 @@ TEST_F(TestMessages, AuthenticatedReceiver) // connectionOptions.IdleTimeout = std::chrono::minutes(5); connectionOptions.ContainerId = "some"; - connectionOptions.HostName = sasCredential->GetHostName(); - connectionOptions.Port = sasCredential->GetPort(); - Connection connection(sasCredential->GetTransport(), connectionOptions); - Session session(connection, nullptr); + connectionOptions.Port = server.GetPort(); + Connection connection("localhost", connectionOptions); + Session session(connection, sasCredential); server.SetSenderNodeName(sasCredential->GetEndpoint() + sasCredential->GetEntityPath()); server.StartListening(); MessageReceiverOptions receiverOptions; receiverOptions.Name = "receiver-link"; - receiverOptions.TargetAddress = "egress"; + receiverOptions.MessageTarget = "egress"; receiverOptions.SettleMode = Azure::Core::Amqp::_internal::ReceiverSettleMode::First; receiverOptions.MaxMessageSize = 65536; receiverOptions.Name = "receiver-link"; receiverOptions.EnableTrace = true; MessageReceiver receiver( session, - sasCredential, sasCredential->GetEndpoint() + sasCredential->GetEntityPath(), receiverOptions, nullptr); @@ -755,23 +833,22 @@ TEST_F(TestMessages, AuthenticatedReceiverAzureToken) ConnectionOptions connectionOptions; - // connectionOptions.IdleTimeout = std::chrono::minutes(5); + connectionOptions.IdleTimeout = std::chrono::minutes(5); connectionOptions.ContainerId = "some"; - connectionOptions.HostName = hostName; connectionOptions.Port = port; - Connection connection(endpoint, connectionOptions); - Session session(connection, nullptr); + Connection connection(hostName, connectionOptions); + Session session(connection, tokenCredential); server.SetSenderNodeName(endpoint); server.StartListening(); MessageReceiverOptions receiverOptions; receiverOptions.Name = "receiver-link"; - receiverOptions.TargetAddress = "egress"; + receiverOptions.MessageTarget = "egress"; receiverOptions.SettleMode = Azure::Core::Amqp::_internal::ReceiverSettleMode::First; receiverOptions.MaxMessageSize = 65536; receiverOptions.Name = "receiver-link"; - MessageReceiver receiver(session, tokenCredential, endpoint, receiverOptions, nullptr); + MessageReceiver receiver(session, endpoint, receiverOptions, nullptr); receiver.Open(); diff --git a/sdk/core/azure-core-amqp/test/ut/message_source_target.cpp b/sdk/core/azure-core-amqp/test/ut/message_source_target.cpp index 044ff01a21..94955a973c 100644 --- a/sdk/core/azure-core-amqp/test/ut/message_source_target.cpp +++ b/sdk/core/azure-core-amqp/test/ut/message_source_target.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT -#include - #include #include #include +#include + class TestSourceTarget : public testing::Test { protected: void SetUp() override {} @@ -30,10 +30,6 @@ TEST_F(TestSourceTarget, SimpleSourceTarget) MessageSource source(std::string("test")); MessageTarget target(std::string("test")); } - { - MessageSource source(Messaging::CreateSource("test1")); - MessageTarget target(Messaging::CreateTarget("test1")); - } { EXPECT_ANY_THROW(MessageSource source(AmqpValue{})); @@ -197,7 +193,7 @@ TEST_F(TestSourceTarget, TargetProperties) { MessageTarget target("address1"); - const AmqpValue v = target; + const AmqpValue v = target.AsAmqpValue(); AmqpValue value(v); MessageTarget target2(value); @@ -208,7 +204,7 @@ TEST_F(TestSourceTarget, TargetProperties) TEST_F(TestSourceTarget, TargetThroughValue) { MessageTarget target("address1"); - const AmqpValue v = target; + const AmqpValue v = target.AsAmqpValue(); AmqpValue value(v); MessageTarget target2(value); @@ -388,7 +384,7 @@ TEST_F(TestSourceTarget, SourceProperties) { MessageSource source("address1"); - const AmqpValue v = source; + const AmqpValue v = source.AsAmqpValue(); AmqpValue value(v); MessageSource source2(value); diff --git a/sdk/core/azure-core-amqp/test/ut/mock_amqp_server.hpp b/sdk/core/azure-core-amqp/test/ut/mock_amqp_server.hpp index 2997a7c0ac..e2ad6d00fa 100644 --- a/sdk/core/azure-core-amqp/test/ut/mock_amqp_server.hpp +++ b/sdk/core/azure-core-amqp/test/ut/mock_amqp_server.hpp @@ -14,6 +14,9 @@ #include #include #include + +#include + #include extern uint16_t FindAvailableSocket(); @@ -37,22 +40,27 @@ class AmqpServerMock : public Azure::Core::Amqp::Network::_internal::SocketListe }; AmqpServerMock() { m_testPort = FindAvailableSocket(); } + AmqpServerMock(uint16_t listeningPort) : m_testPort{listeningPort} {} virtual void Poll() const {} bool WaitForConnection( Azure::Core::Amqp::Network::_internal::SocketListener const& listener, - Azure::Core::Context context = {}) + Azure::Core::Context const& context = {}) { auto result = m_connectionQueue.WaitForPolledResult(context, listener); + if (result) + { + m_connectionValid = true; + } return result != nullptr; } - bool WaitForMessageReceiver(std::string const& nodeName, Azure::Core::Context context = {}) + bool WaitForMessageReceiver(std::string const& nodeName, Azure::Core::Context const& context = {}) { auto result = m_linkMessageQueues[nodeName].MessageReceiverPresentQueue.WaitForPolledResult( context, *this, *m_connection); return result != nullptr; } - bool WaitForMessageSender(std::string const& nodeName, Azure::Core::Context context = {}) + bool WaitForMessageSender(std::string const& nodeName, Azure::Core::Context const& context = {}) { auto result = m_linkMessageQueues[nodeName].MessageSenderPresentQueue.WaitForPolledResult( context, *this, *m_connection); @@ -204,6 +212,7 @@ class AmqpServerMock : public Azure::Core::Amqp::Network::_internal::SocketListe private: std::shared_ptr m_connection; + bool m_connectionValid{false}; std::shared_ptr m_session; Azure::Core::Amqp::Common::_internal::AsyncOperationQueue m_connectionQueue; @@ -337,13 +346,12 @@ class AmqpServerMock : public Azure::Core::Amqp::Network::_internal::SocketListe std::shared_ptr transport) override { GTEST_LOG_(INFO) << "OnSocketAccepted - Socket connection received."; - std::shared_ptr amqpTransport{ - std::make_shared( + auto amqpTransport{ + Azure::Core::Amqp::Network::_internal::AmqpHeaderDetectTransportFactory::Create( transport, nullptr)}; Azure::Core::Amqp::_internal::ConnectionOptions options; options.ContainerId = "connectionId"; options.EnableTrace = true; - options.Transport = amqpTransport; m_connection = std::make_shared(amqpTransport, options, this); m_connection->Listen(); @@ -357,18 +365,28 @@ class AmqpServerMock : public Azure::Core::Amqp::Network::_internal::SocketListe { GTEST_LOG_(INFO) << "Connection State changed. Old state: " << ConnectionStateToString(oldState) << " New state: " << ConnectionStateToString(newState); + if (newState == Azure::Core::Amqp::_internal::ConnectionState::End + || newState == Azure::Core::Amqp::_internal::ConnectionState::Error) + { + // If the connection is closed, then we should close the connection. + m_connectionValid = false; + m_listenerContext.Cancel(); + } } virtual bool OnNewEndpoint( Azure::Core::Amqp::_internal::Connection const& connection, Azure::Core::Amqp::_internal::Endpoint& endpoint) override { GTEST_LOG_(INFO) << "OnNewEndpoint - Incoming endpoint created, create session."; - m_session = std::make_unique(connection, endpoint, this); - m_session->SetIncomingWindow(10000); + Azure::Core::Amqp::_internal::SessionOptions options; + options.InitialIncomingWindowSize = 10000; + + m_session = std::make_shared( + connection, endpoint, options, this); m_session->Begin(); return true; } - virtual void OnIoError(Azure::Core::Amqp::_internal::Connection const&) override {} + virtual void OnIOError(Azure::Core::Amqp::_internal::Connection const&) override {} // Inherited via Session virtual bool OnLinkAttached( @@ -376,9 +394,9 @@ class AmqpServerMock : public Azure::Core::Amqp::Network::_internal::SocketListe Azure::Core::Amqp::_internal::LinkEndpoint& newLinkInstance, std::string const& name, Azure::Core::Amqp::_internal::SessionRole role, - Azure::Core::Amqp::Models::AmqpValue source, - Azure::Core::Amqp::Models::AmqpValue target, - Azure::Core::Amqp::Models::AmqpValue) override + Azure::Core::Amqp::Models::AmqpValue const& source, + Azure::Core::Amqp::Models::AmqpValue const& target, + Azure::Core::Amqp::Models::AmqpValue const&) override { Azure::Core::Amqp::Models::_internal::MessageSource msgSource(source); Azure::Core::Amqp::Models::_internal::MessageTarget msgTarget(target); @@ -392,10 +410,11 @@ class AmqpServerMock : public Azure::Core::Amqp::Network::_internal::SocketListe Azure::Core::Amqp::_internal::MessageSenderOptions senderOptions; senderOptions.EnableTrace = true; senderOptions.Name = name; - senderOptions.SourceAddress = static_cast(msgSource.GetAddress()); + senderOptions.MessageSource = msgSource; senderOptions.InitialDeliveryCount = 0; std::string targetAddress = static_cast(msgTarget.GetAddress()); - MessageLinkComponents& linkComponents = m_linkMessageQueues[senderOptions.SourceAddress]; + MessageLinkComponents& linkComponents + = m_linkMessageQueues[static_cast(senderOptions.MessageSource.GetAddress())]; if (!linkComponents.LinkSender) { @@ -410,10 +429,11 @@ class AmqpServerMock : public Azure::Core::Amqp::Network::_internal::SocketListe Azure::Core::Amqp::_internal::MessageReceiverOptions receiverOptions; receiverOptions.EnableTrace = true; receiverOptions.Name = name; - receiverOptions.TargetAddress = static_cast(msgTarget.GetAddress()); + receiverOptions.MessageTarget = msgTarget; receiverOptions.InitialDeliveryCount = 0; std::string sourceAddress = static_cast(msgSource.GetAddress()); - MessageLinkComponents& linkComponents = m_linkMessageQueues[receiverOptions.TargetAddress]; + MessageLinkComponents& linkComponents = m_linkMessageQueues[static_cast( + receiverOptions.MessageTarget.GetAddress())]; if (!linkComponents.LinkReceiver) { linkComponents.LinkReceiver diff --git a/sdk/core/azure-core-amqp/test/ut/session_tests.cpp b/sdk/core/azure-core-amqp/test/ut/session_tests.cpp index 1decf9adda..2bb9af4d55 100644 --- a/sdk/core/azure-core-amqp/test/ut/session_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/session_tests.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT -#include - #include "azure/core/amqp/common/async_operation_queue.hpp" #include "azure/core/amqp/common/global_state.hpp" #include "azure/core/amqp/connection.hpp" @@ -12,14 +10,18 @@ #include "azure/core/amqp/network/socket_listener.hpp" #include "azure/core/amqp/network/socket_transport.hpp" #include "azure/core/amqp/session.hpp" + #include +#include + #include #include -#include +#include #if defined(AZ_PLATFORM_POSIX) -#include // for sockaddr_in #include // for poll() + +#include // for sockaddr_in #include // for socket shutdown #elif defined(AZ_PLATFORM_WINDOWS) #include // for WSAPoll(); @@ -42,7 +44,7 @@ TEST_F(TestSessions, SimpleSession) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + Azure::Core::Amqp::_internal::Connection connection("localhost", {}); { // Create a session Session session(connection, nullptr); @@ -79,7 +81,7 @@ TEST_F(TestSessions, SimpleSession) TEST_F(TestSessions, SessionProperties) { // Create a connection - Connection connection("amqp://localhost:5672", {}); + Azure::Core::Amqp::_internal::Connection connection("localhost", {}); { Session session(connection, nullptr); @@ -91,19 +93,22 @@ TEST_F(TestSessions, SessionProperties) } { - Session session(connection, nullptr); - EXPECT_NO_THROW(session.SetHandleMax(37)); + SessionOptions options; + options.MaximumLinkCount = 37; + Session session(connection, nullptr, options); EXPECT_EQ(37, session.GetHandleMax()); } { - Session session(connection, nullptr); - EXPECT_NO_THROW(session.SetIncomingWindow(9278789)); - EXPECT_EQ(9278789, session.GetIncomingWindow()); + SessionOptions options; + options.InitialIncomingWindowSize = 1909119; + Session session(connection, nullptr, options); + EXPECT_EQ(1909119, session.GetIncomingWindow()); } { - Session session(connection, nullptr); - EXPECT_NO_THROW(session.SetOutgoingWindow(32798)); - EXPECT_EQ(32798, session.GetOutgoingWindow()); + SessionOptions options; + options.InitialOutgoingWindowSize = 1909119; + Session session(connection, nullptr, options); + EXPECT_EQ(1909119, session.GetOutgoingWindow()); } } #endif // !AZ_PLATFORM_MAC @@ -123,7 +128,12 @@ uint16_t FindAvailableSocket() int count = 0; while (count < 20) { - uint16_t testPort = dev() % 1000 + 5000; + uint16_t testPort; + // Make absolutely sure that we don't accidentally use the TLS port. + do + { + testPort = dev() % 1000 + 5000; + } while (testPort == AmqpTlsPort); GTEST_LOG_(INFO) << "Trying Test port: " << testPort; @@ -177,7 +187,7 @@ TEST_F(TestSessions, SessionBeginEnd) public: std::shared_ptr WaitForResult( Network::_internal::SocketListener const& listener, - Azure::Core::Context context = {}) + Azure::Core::Context const& context = {}) { auto result = m_listenerQueue.WaitForPolledResult(context, listener); return std::get<0>(*result); @@ -202,7 +212,9 @@ TEST_F(TestSessions, SessionBeginEnd) listener.Start(); // Create a connection - Connection connection("amqp://localhost:" + std::to_string(testPort), {}); + Azure::Core::Amqp::_internal::ConnectionOptions connectionOptions; + connectionOptions.Port = testPort; + Azure::Core::Amqp::_internal::Connection connection("localhost", connectionOptions); { Session session(connection, nullptr); diff --git a/sdk/core/azure-core-amqp/test/ut/transport_tests.cpp b/sdk/core/azure-core-amqp/test/ut/transport_tests.cpp index b0b1c28637..5472afea9e 100644 --- a/sdk/core/azure-core-amqp/test/ut/transport_tests.cpp +++ b/sdk/core/azure-core-amqp/test/ut/transport_tests.cpp @@ -1,16 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-Licence-Identifier: MIT -#include "azure/core/amqp/models/amqp_protocol.hpp" +#include "azure/core/amqp/connection.hpp" + #include #include #include #include #include -#include + #include #include +#include + extern uint16_t FindAvailableSocket(); using namespace Azure::Core::Amqp::Network::_internal; @@ -22,60 +25,46 @@ class TestTlsTransport : public testing::Test { void TearDown() override {} }; -std::string StringFromSendResult(TransportSendResult ts) +std::string StringFromSendResult(TransportSendStatus ts) { switch (ts) { - case TransportSendResult::Unknown: + case TransportSendStatus::Unknown: return "Unknown"; - case TransportSendResult::Ok: + case TransportSendStatus::Ok: return "Ok"; - case TransportSendResult::Error: + case TransportSendStatus::Error: return "Error"; - case TransportSendResult::Cancelled: + case TransportSendStatus::Cancelled: return "Cancelled"; - case TransportSendResult::Invalid: + case TransportSendStatus::Invalid: return "**INVALID**"; } throw std::logic_error("??? Unknown Transport Send Result..."); } -std::string StringFromOpenResult(TransportOpenResult to) +std::string StringFromOpenResult(TransportOpenStatus to) { switch (to) { - case TransportOpenResult::Ok: + case TransportOpenStatus::Ok: return "Ok"; - case TransportOpenResult::Error: + case TransportOpenStatus::Error: return "Error"; - case TransportOpenResult::Cancelled: + case TransportOpenStatus::Cancelled: return "Cancelled"; - case TransportOpenResult::Invalid: + case TransportOpenStatus::Invalid: return "**INVALID**"; } throw std::logic_error("??? Unknown Transport Open Result..."); } -TEST_F(TestTlsTransport, SimpleCreate) -{ - { - TlsTransport transport; - } -} - TEST_F(TestTlsTransport, SimpleSend) { { class TestTransportEvents : public TransportEvents { - AsyncOperationQueue openResultQueue; AsyncOperationQueue> receiveBytesQueue; AsyncOperationQueue errorQueue; - void OnOpenComplete(TransportOpenResult result) override - { - GTEST_LOG_(INFO) << "On open:" << static_cast(result); - - openResultQueue.CompleteOperation(result); - } void OnBytesReceived(Transport const&, uint8_t const* bytes, size_t size) override { GTEST_LOG_(INFO) << "On bytes received: " << size; @@ -83,33 +72,25 @@ TEST_F(TestTlsTransport, SimpleSend) memcpy(val.get(), bytes, size); receiveBytesQueue.CompleteOperation(size, std::move(val)); } - void OnIoError() override + void OnIOError() override { GTEST_LOG_(INFO) << "On I/O Error"; errorQueue.CompleteOperation(true); } public: - TransportOpenResult WaitForOpen(Transport const& transport, Azure::Core::Context context) - { - auto result = openResultQueue.WaitForPolledResult(context, transport); - return std::get<0>(*result); - } std::tuple> WaitForReceive( Transport const& transport, - Azure::Core::Context context) + Azure::Core::Context const& context) { auto result = receiveBytesQueue.WaitForPolledResult(context, transport); return std::make_tuple(std::get<0>(*result), std::move(std::get<1>(*result))); } }; TestTransportEvents events; - TlsTransport transport("www.microsoft.com", 443, &events); - - ASSERT_TRUE(transport.Open()); + auto transport = TlsTransportFactory::Create("www.microsoft.com", 443, &events); - auto openResult = events.WaitForOpen(transport, {}); - EXPECT_EQ(openResult, TransportOpenResult::Ok); + ASSERT_EQ(TransportOpenStatus::Ok, transport.Open()); unsigned char val[] = R"(GET / HTTP/1.1 Host: www.microsoft.com @@ -120,15 +101,15 @@ Accept: */* GTEST_LOG_(INFO) << "Before send" << std::endl; - AsyncOperationQueue sendOperation; - EXPECT_TRUE(transport.Send(val, sizeof(val), [&sendOperation](TransportSendResult result) { + AsyncOperationQueue sendOperation; + EXPECT_TRUE(transport.Send(val, sizeof(val), [&sendOperation](TransportSendStatus result) { std::cout << "Send complete" << StringFromSendResult(result); sendOperation.CompleteOperation(result); })); GTEST_LOG_(INFO) << "Wait for send" << std::endl; auto sendResult{sendOperation.WaitForPolledResult({}, transport)}; - EXPECT_EQ(std::get<0>(*sendResult), TransportSendResult::Ok); + EXPECT_EQ(std::get<0>(*sendResult), TransportSendStatus::Ok); // Wait until we receive data from the www.microsoft.com server. GTEST_LOG_(INFO) << "Wait for data from server." << std::endl; @@ -137,10 +118,7 @@ Accept: */* GTEST_LOG_(INFO) << "Received data from microsoft.com server: " << std::get<0>(receiveResult) << std::endl; - AsyncOperationQueue closeResult; - transport.Close([&closeResult] { closeResult.CompleteOperation(true); }); - auto closeComplete = closeResult.WaitForPolledResult({}, transport); - EXPECT_EQ(true, std::get<0>(*closeComplete)); + EXPECT_NO_THROW(transport.Close()); } } @@ -154,36 +132,40 @@ class TestSocketTransport : public testing::Test { TEST_F(TestSocketTransport, SimpleCreate) { { - SocketTransport transport("localhost", Azure::Core::Amqp::_detail::AmqpPort); + Transport transport{ + SocketTransportFactory::Create("localhost", Azure::Core::Amqp::_internal::AmqpPort)}; } { - SocketTransport transport1("localhost", Azure::Core::Amqp::_detail::AmqpPort); - SocketTransport transport2("localhost", 5673); + Transport transport1{ + SocketTransportFactory::Create("localhost", Azure::Core::Amqp::_internal::AmqpPort)}; + Transport transport2{SocketTransportFactory::Create("localhost", 5673)}; } } TEST_F(TestSocketTransport, SimpleOpen) { + // Wait until we receive data from the www.microsoft.com server, with a 10 second timeout. + Azure::Core::Context completionContext = Azure::Core::Context::ApplicationContext.WithDeadline( + std::chrono::system_clock::now() + std::chrono::seconds(10)); { + Transport transport{SocketTransportFactory::Create("www.microsoft.com", 80)}; - SocketTransport transport("www.microsoft.com", 80); - - ASSERT_TRUE(transport.Open()); - EXPECT_TRUE(transport.Close([]() {})); + ASSERT_EQ(TransportOpenStatus::Ok, transport.Open(completionContext)); + EXPECT_NO_THROW(transport.Close()); } { - SocketTransport transport("www.microsoft.com", 80); - ASSERT_TRUE(transport.Open()); - transport.Close(nullptr); + Transport transport{SocketTransportFactory::Create("www.microsoft.com", 80)}; + ASSERT_EQ(TransportOpenStatus::Ok, transport.Open(completionContext)); + transport.Close(); } { - SocketTransport transport("www.microsoft.com", 80); - EXPECT_ANY_THROW(transport.Close(nullptr)); + Transport transport{SocketTransportFactory::Create("www.microsoft.com", 80)}; + EXPECT_ANY_THROW(transport.Close()); } { - SocketTransport transport("www.microsoft.com", 80); - transport.Open(); + Transport transport{SocketTransportFactory::Create("www.microsoft.com", 80)}; + ASSERT_EQ(TransportOpenStatus::Ok, transport.Open(completionContext)); EXPECT_ANY_THROW(transport.Open()); } } @@ -192,15 +174,8 @@ TEST_F(TestSocketTransport, SimpleSend) { { class TestTransportEvents : public TransportEvents { - AsyncOperationQueue openResultQueue; AsyncOperationQueue> receiveBytesQueue; AsyncOperationQueue errorQueue; - void OnOpenComplete(TransportOpenResult result) override - { - GTEST_LOG_(INFO) << "On open:" << static_cast(result); - - openResultQueue.CompleteOperation(result); - } void OnBytesReceived(Transport const&, uint8_t const* bytes, size_t size) override { GTEST_LOG_(INFO) << "On bytes received: " << size; @@ -208,36 +183,28 @@ TEST_F(TestSocketTransport, SimpleSend) memcpy(val.get(), bytes, size); receiveBytesQueue.CompleteOperation(size, std::move(val)); } - void OnIoError() override + void OnIOError() override { GTEST_LOG_(INFO) << "On I/O Error"; errorQueue.CompleteOperation(true); } public: - TransportOpenResult WaitForOpen(Transport const& transport, Azure::Core::Context context) - { - auto result = openResultQueue.WaitForPolledResult(context, transport); - return std::get<0>(*result); - } std::tuple> WaitForReceive( Transport const& transport, - Azure::Core::Context context) + Azure::Core::Context const& context) { auto result = receiveBytesQueue.WaitForPolledResult(context, transport); return std::make_tuple(std::get<0>(*result), std::move(std::get<1>(*result))); } }; TestTransportEvents events; - SocketTransport transport("www.microsoft.com", 80, &events); + Transport transport{SocketTransportFactory::Create("www.microsoft.com", 80, &events)}; - EXPECT_TRUE(transport.Open()); // Wait until we receive data from the www.microsoft.com server, with a 10 second timeout. Azure::Core::Context completionContext = Azure::Core::Context::ApplicationContext.WithDeadline( std::chrono::system_clock::now() + std::chrono::seconds(10)); - auto openResult = events.WaitForOpen(transport, completionContext); - - EXPECT_EQ(openResult, TransportOpenResult::Ok); + ASSERT_EQ(TransportOpenStatus::Ok, transport.Open(completionContext)); unsigned char val[] = R"(GET / HTTP/1.1 Host: www.microsoft.com @@ -248,15 +215,15 @@ Accept: */* GTEST_LOG_(INFO) << "Before send" << std::endl; - AsyncOperationQueue sendOperation; - EXPECT_TRUE(transport.Send(val, sizeof(val), [&sendOperation](TransportSendResult result) { + AsyncOperationQueue sendOperation; + EXPECT_TRUE(transport.Send(val, sizeof(val), [&sendOperation](TransportSendStatus result) { std::cout << "Send complete" << StringFromSendResult(result); sendOperation.CompleteOperation(result); })); GTEST_LOG_(INFO) << "Wait for send" << std::endl; auto sendResult{sendOperation.WaitForPolledResult({}, transport)}; - EXPECT_EQ(std::get<0>(*sendResult), TransportSendResult::Ok); + EXPECT_EQ(std::get<0>(*sendResult), TransportSendStatus::Ok); // Wait until we receive data from the www.microsoft.com server. GTEST_LOG_(INFO) << "Wait for data from server." << std::endl; @@ -266,9 +233,7 @@ Accept: */* << std::endl; AsyncOperationQueue closeResult; - transport.Close([&closeResult] { closeResult.CompleteOperation(true); }); - auto closeComplete = closeResult.WaitForPolledResult({}, transport); - EXPECT_EQ(true, std::get<0>(*closeComplete)); + EXPECT_NO_THROW(transport.Close()); } } @@ -313,17 +278,14 @@ TEST_F(TestSocketTransport, SimpleListenerEcho) std::shared_ptr GetListenerTransport( SocketListener const& listener, - Azure::Core::Context context) + Azure::Core::Context const& context) { auto result = m_listenerTransportQueue.WaitForPolledResult(context, listener); return std::move(std::get<0>(*result)); } - TransportOpenResult WaitForOpen(SocketListener const& listener, Azure::Core::Context context) - { - auto result = openResultQueue.WaitForPolledResult(context, listener); - return std::get<0>(*result); - } - std::vector WaitForReceive(Transport const& transport, Azure::Core::Context context) + std::vector WaitForReceive( + Transport const& transport, + Azure::Core::Context const& context) { auto result = receiveBytesQueue.WaitForPolledResult(context, transport); if (result) @@ -335,7 +297,6 @@ TEST_F(TestSocketTransport, SimpleListenerEcho) private: AsyncOperationQueue> m_listenerTransportQueue; - AsyncOperationQueue openResultQueue; AsyncOperationQueue> receiveBytesQueue; AsyncOperationQueue errorQueue; virtual void OnSocketAccepted(std::shared_ptr newTransport) override @@ -345,11 +306,6 @@ TEST_F(TestSocketTransport, SimpleListenerEcho) newTransport->Open(); m_listenerTransportQueue.CompleteOperation(newTransport); } - void OnOpenComplete(TransportOpenResult result) override - { - GTEST_LOG_(INFO) << "On open:" << static_cast(result); - openResultQueue.CompleteOperation(result); - } void OnBytesReceived(Transport const& transport, uint8_t const* bytes, size_t size) override { GTEST_LOG_(INFO) << "On Listener bytes received: " << size; @@ -362,11 +318,11 @@ TEST_F(TestSocketTransport, SimpleListenerEcho) receiveBytesQueue.CompleteOperation(echoedBytes); // Echo back the data received. - transport.Send(const_cast(bytes), size, [](TransportSendResult sendResult) { + transport.Send(const_cast(bytes), size, [](TransportSendStatus sendResult) { GTEST_LOG_(INFO) << "OnListener Send Bytes Complete..." << StringFromSendResult(sendResult); }); } - void OnIoError() override + void OnIOError() override { GTEST_LOG_(INFO) << "On I/O Error"; errorQueue.CompleteOperation(true); @@ -381,15 +337,8 @@ TEST_F(TestSocketTransport, SimpleListenerEcho) EXPECT_NO_THROW(listener.Start()); class SendingEvents : public TransportEvents { - AsyncOperationQueue openResultQueue; AsyncOperationQueue> receiveBytesQueue; AsyncOperationQueue errorQueue; - void OnOpenComplete(TransportOpenResult result) override - { - GTEST_LOG_(INFO) << "On open:" << static_cast(result); - - openResultQueue.CompleteOperation(result); - } void OnBytesReceived(Transport const&, uint8_t const* bytes, size_t size) override { GTEST_LOG_(INFO) << "On bytes received: " << size; @@ -401,28 +350,25 @@ TEST_F(TestSocketTransport, SimpleListenerEcho) receiveBytesQueue.CompleteOperation(echoedBytes); } - void OnIoError() override + void OnIOError() override { GTEST_LOG_(INFO) << "On I/O Error"; errorQueue.CompleteOperation(true); } public: - TransportOpenResult WaitForOpen(Transport const& transport, Azure::Core::Context context) - { - auto result = openResultQueue.WaitForPolledResult(context, transport); - return std::get<0>(*result); - } - std::vector WaitForReceive(Transport const& transport, Azure::Core::Context context) + std::vector WaitForReceive( + Transport const& transport, + Azure::Core::Context const& context) { auto result = receiveBytesQueue.WaitForPolledResult(context, transport); return std::get<0>(*result); } }; SendingEvents sendingEvents; - SocketTransport sender("localhost", testPort, &sendingEvents); + Transport sender{SocketTransportFactory::Create("localhost", testPort, &sendingEvents)}; - ASSERT_TRUE(sender.Open()); + ASSERT_EQ(TransportOpenStatus::Ok, sender.Open()); // Note: Keep this string under 64 bytes in length because the default socket I/O buffer size // is 64 bytes and that helps ensure that this will be handled in a single OnReceiveBytes @@ -432,14 +378,14 @@ Host: www.microsoft.com)"; // Synchronously send the data to the listener. { - AsyncOperationQueue sendOperation; + AsyncOperationQueue sendOperation; - sender.Send(val, sizeof(val), [&sendOperation](TransportSendResult result) { + sender.Send(val, sizeof(val), [&sendOperation](TransportSendStatus result) { GTEST_LOG_(INFO) << "Sender send complete " << StringFromSendResult(result); sendOperation.CompleteOperation(result); }); auto sendResult{sendOperation.WaitForPolledResult({}, sender)}; - EXPECT_EQ(std::get<0>(*sendResult), TransportSendResult::Ok); + EXPECT_EQ(std::get<0>(*sendResult), TransportSendStatus::Ok); } GTEST_LOG_(INFO) << "Wait for listener to receive the bytes we just sent."; @@ -458,7 +404,7 @@ Host: www.microsoft.com)"; EXPECT_EQ(sizeof(val), receivedData.size()); EXPECT_EQ(0, memcmp(val, receivedData.data(), receivedData.size())); - listenerTransport->Close(nullptr); + listenerTransport->Close(); listener.Stop(); } #endif // !defined(AZ_PLATFORM_MAC) diff --git a/sdk/core/azure-core-test/inc/azure/core/test/test_base.hpp b/sdk/core/azure-core-test/inc/azure/core/test/test_base.hpp index de0cbc342c..9de37d6045 100644 --- a/sdk/core/azure-core-test/inc/azure/core/test/test_base.hpp +++ b/sdk/core/azure-core-test/inc/azure/core/test/test_base.hpp @@ -5,11 +5,10 @@ * Base class for running live and playback tests using the interceptor manager */ -#include - #include "azure/core/test/network_models.hpp" #include "azure/core/test/test_context_manager.hpp" #include "azure/core/test/test_proxy_manager.hpp" + #include #include #include @@ -22,6 +21,8 @@ #include #include +#include + using namespace std::chrono_literals; namespace Azure { namespace Core { namespace Test { diff --git a/sdk/core/azure-core-test/inc/azure/core/test/test_context_manager.hpp b/sdk/core/azure-core-test/inc/azure/core/test/test_context_manager.hpp index fb21c5e543..8ea214ab42 100644 --- a/sdk/core/azure-core-test/inc/azure/core/test/test_context_manager.hpp +++ b/sdk/core/azure-core-test/inc/azure/core/test/test_context_manager.hpp @@ -7,10 +7,11 @@ #pragma once -#include +#include "azure/core/test/network_models.hpp" + #include -#include "azure/core/test/network_models.hpp" +#include namespace Azure { namespace Core { namespace Test { /** diff --git a/sdk/core/azure-core-test/inc/azure/core/test/test_proxy_manager.hpp b/sdk/core/azure-core-test/inc/azure/core/test/test_proxy_manager.hpp index f1097c9bb3..ed98e6b29b 100644 --- a/sdk/core/azure-core-test/inc/azure/core/test/test_proxy_manager.hpp +++ b/sdk/core/azure-core-test/inc/azure/core/test/test_proxy_manager.hpp @@ -7,15 +7,16 @@ #pragma once +#include "azure/core/test/network_models.hpp" +#include "azure/core/test/test_context_manager.hpp" +#include "azure/core/test/test_proxy_policy.hpp" + #include #include #include + #include #include - -#include "azure/core/test/network_models.hpp" -#include "azure/core/test/test_context_manager.hpp" -#include "azure/core/test/test_proxy_policy.hpp" #if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) #include #endif diff --git a/sdk/core/azure-core-test/inc/azure/core/test/test_proxy_policy.hpp b/sdk/core/azure-core-test/inc/azure/core/test/test_proxy_policy.hpp index e003b0ebd2..26cdceed56 100644 --- a/sdk/core/azure-core-test/inc/azure/core/test/test_proxy_policy.hpp +++ b/sdk/core/azure-core-test/inc/azure/core/test/test_proxy_policy.hpp @@ -8,9 +8,6 @@ #pragma once -#include -#include - #include "azure/core/test/network_models.hpp" #include "azure/core/test/test_proxy_manager.hpp" @@ -19,6 +16,9 @@ #include #include +#include +#include + namespace Azure { namespace Core { namespace Test { // Partial class. Required to reference the Interceptor that is defined in the implementation. diff --git a/sdk/core/azure-core-test/src/test_base.cpp b/sdk/core/azure-core-test/src/test_base.cpp index 286fd16873..2d88478ad9 100644 --- a/sdk/core/azure-core-test/src/test_base.cpp +++ b/sdk/core/azure-core-test/src/test_base.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/core/test/test_base.hpp" +#include + #include #include diff --git a/sdk/core/azure-core-test/src/test_proxy_manager.cpp b/sdk/core/azure-core-test/src/test_proxy_manager.cpp index 2c12182317..2dc84f6967 100644 --- a/sdk/core/azure-core-test/src/test_proxy_manager.cpp +++ b/sdk/core/azure-core-test/src/test_proxy_manager.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "azure/core/test/test_proxy_manager.hpp" + #include #include #include -#include "azure/core/test/test_proxy_manager.hpp" - #include #include #include diff --git a/sdk/core/azure-core-test/src/test_proxy_policy.cpp b/sdk/core/azure-core-test/src/test_proxy_policy.cpp index 826e8f7a2b..7e07ca18d1 100644 --- a/sdk/core/azure-core-test/src/test_proxy_policy.cpp +++ b/sdk/core/azure-core-test/src/test_proxy_policy.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/test/test_proxy_policy.hpp" + #include "azure/core/test/network_models.hpp" #include "azure/core/test/test_context_manager.hpp" diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/opentelemetry.cpp b/sdk/core/azure-core-tracing-opentelemetry/src/opentelemetry.cpp index 692b3472f0..fba6833dbd 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/opentelemetry.cpp +++ b/sdk/core/azure-core-tracing-opentelemetry/src/opentelemetry.cpp @@ -2,10 +2,13 @@ // SPDX-License-Identifier: MIT #include "azure/core/tracing/opentelemetry/opentelemetry.hpp" + #include "opentelemetry_private.hpp" + #include #include #include + #include #if defined(_MSC_VER) // The OpenTelemetry headers generate a couple of warnings on MSVC in the OTel 1.2 package, suppress diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/opentelemetry_private.hpp b/sdk/core/azure-core-tracing-opentelemetry/src/opentelemetry_private.hpp index a733ee2b34..d52b566c1c 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/opentelemetry_private.hpp +++ b/sdk/core/azure-core-tracing-opentelemetry/src/opentelemetry_private.hpp @@ -4,6 +4,7 @@ #pragma once #include "azure/core/tracing/opentelemetry/opentelemetry.hpp" + #include #if defined(_MSC_VER) // The OpenTelemetry headers generate a couple of warnings on MSVC in the OTel 1.2 package, suppress diff --git a/sdk/core/azure-core-tracing-opentelemetry/test/ut/azure_core_otel_test.cpp b/sdk/core/azure-core-tracing-opentelemetry/test/ut/azure_core_otel_test.cpp index ded42c49d3..ef3c823948 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/test/ut/azure_core_otel_test.cpp +++ b/sdk/core/azure-core-tracing-opentelemetry/test/ut/azure_core_otel_test.cpp @@ -4,6 +4,7 @@ #define USE_MEMORY_EXPORTER 1 #include "../src/opentelemetry_private.hpp" #include "azure/core/tracing/opentelemetry/opentelemetry.hpp" + #include #if defined(_MSC_VER) @@ -27,6 +28,7 @@ #endif #include + #include class OpenTelemetryTests : public Azure::Core::Test::TestBase { diff --git a/sdk/core/azure-core-tracing-opentelemetry/test/ut/azure_core_test.cpp b/sdk/core/azure-core-tracing-opentelemetry/test/ut/azure_core_test.cpp index 959703daba..454c20eab6 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/test/ut/azure_core_test.cpp +++ b/sdk/core/azure-core-tracing-opentelemetry/test/ut/azure_core_test.cpp @@ -5,6 +5,7 @@ #include "azure/core/platform.hpp" #include + #include int main(int argc, char** argv) diff --git a/sdk/core/azure-core-tracing-opentelemetry/test/ut/service_support_test.cpp b/sdk/core/azure-core-tracing-opentelemetry/test/ut/service_support_test.cpp index 10684d7a1b..d882ac2701 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/test/ut/service_support_test.cpp +++ b/sdk/core/azure-core-tracing-opentelemetry/test/ut/service_support_test.cpp @@ -1,10 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - -#include -#include +#include "test_exporter.hpp" // Span Exporter used for OpenTelemetry tests. #include #include @@ -12,7 +9,10 @@ #include #include -#include "test_exporter.hpp" // Span Exporter used for OpenTelemetry tests. +#include +#include + +#include #if defined(_MSC_VER) // The OpenTelemetry headers generate a couple of warnings on MSVC in the OTel 1.2 package, suppress // the warnings across the includes. diff --git a/sdk/core/azure-core-tracing-opentelemetry/test/ut/test_exporter.hpp b/sdk/core/azure-core-tracing-opentelemetry/test/ut/test_exporter.hpp index 4339fe2c70..b446ca351d 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/test/ut/test_exporter.hpp +++ b/sdk/core/azure-core-tracing-opentelemetry/test/ut/test_exporter.hpp @@ -4,6 +4,7 @@ #pragma once #include + #include class RecordedSpan : public opentelemetry::sdk::trace::Recordable { diff --git a/sdk/core/azure-core/inc/azure/core/context.hpp b/sdk/core/azure-core/inc/azure/core/context.hpp index 0e19c9bf12..624ee49d25 100644 --- a/sdk/core/azure-core/inc/azure/core/context.hpp +++ b/sdk/core/azure-core/inc/azure/core/context.hpp @@ -12,6 +12,7 @@ #include "azure/core/datetime.hpp" #include "azure/core/dll_import_export.hpp" #include "azure/core/rtti.hpp" + #include #include #include diff --git a/sdk/core/azure-core/inc/azure/core/internal/http/http_sanitizer.hpp b/sdk/core/azure-core/inc/azure/core/internal/http/http_sanitizer.hpp index 4068012ea0..97a03f1264 100644 --- a/sdk/core/azure-core/inc/azure/core/internal/http/http_sanitizer.hpp +++ b/sdk/core/azure-core/inc/azure/core/internal/http/http_sanitizer.hpp @@ -4,6 +4,7 @@ #pragma once #include "azure/core/url.hpp" + #include namespace Azure { namespace Core { namespace Http { namespace _internal { diff --git a/sdk/core/azure-core/inc/azure/core/internal/json/json.hpp b/sdk/core/azure-core/inc/azure/core/internal/json/json.hpp index 048154a9e8..391c300771 100644 --- a/sdk/core/azure-core/inc/azure/core/internal/json/json.hpp +++ b/sdk/core/azure-core/inc/azure/core/internal/json/json.hpp @@ -2176,10 +2176,7 @@ _az_JSON_HEDLEY_DIAGNOSTIC_PUSH class exception : public std::exception { public: /// returns the explanatory string - const char* what() const noexcept override - { - return m.what(); - } + const char* what() const noexcept override { return m.what(); } /// the id of the exception const int id; @@ -15737,125 +15734,141 @@ namespace Azure { namespace Core { namespace Json { namespace _internal { namesp #pragma warning(disable : 28020) #endif - /*! - @brief check whether a string is UTF-8 encoded - - The function checks each byte of a string whether it is UTF-8 encoded. The - result of the check is stored in the @a state parameter. The function must - be called initially with state 0 (accept). State 1 means the string must - be rejected, because the current byte is not allowed. If the string is - completely processed, but the state is non-zero, the string ended - prematurely; that is, the last byte indicated more bytes should have - followed. - - @param[in,out] state the state of the decoding - @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT) - @param[in] byte next byte to decode - @return new state - - @note The function has been edited: a std::array is used. - - @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann - @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ - */ - static std::uint8_t decode( - std::uint8_t& state, - std::uint32_t& codep, - const std::uint8_t byte) noexcept - { - static const std::array utf8d = {{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF - 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF - 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF - 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF - 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2 - 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4 - 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6 - 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, - 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8 - }}; + /*! + @brief check whether a string is UTF-8 encoded - const std::uint8_t type = utf8d[byte]; + The function checks each byte of a string whether it is UTF-8 encoded. The + result of the check is stored in the @a state parameter. The function must + be called initially with state 0 (accept). State 1 means the string must + be rejected, because the current byte is not allowed. If the string is + completely processed, but the state is non-zero, the string ended + prematurely; that is, the last byte indicated more bytes should have + followed. - codep = (state != UTF8_ACCEPT) ? (byte & 0x3fu) | (codep << 6u) : (0xFFu >> type) & (byte); + @param[in,out] state the state of the decoding + @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT) + @param[in] byte next byte to decode + @return new state - std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); - assert(index < 400); - state = utf8d[index]; - return state; - } + @note The function has been edited: a std::array is used. + + @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann + @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ + */ + static std::uint8_t decode( + std::uint8_t& state, + std::uint32_t& codep, + const std::uint8_t byte) noexcept + { + static const std::array utf8d + = {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF + 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF + 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, + 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF + 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, + 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF + 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, + 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, + 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2 + 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4 + 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6 + 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, + 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8 + }}; + + const std::uint8_t type = utf8d[byte]; + + codep = (state != UTF8_ACCEPT) ? (byte & 0x3fu) | (codep << 6u) + : (0xFFu >> type) & (byte); + + std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); + assert(index < 400); + state = utf8d[index]; + return state; + } #if defined(_MSC_VER) #pragma warning(pop) #endif - /* - * Overload to make the compiler happy while it is instantiating - * dump_integer for number_unsigned_t. - * Must never be called. - */ - number_unsigned_t remove_sign(number_unsigned_t x) - { - assert(false); // LCOV_EXCL_LINE - return x; // LCOV_EXCL_LINE - } + /* + * Overload to make the compiler happy while it is instantiating + * dump_integer for number_unsigned_t. + * Must never be called. + */ + number_unsigned_t remove_sign(number_unsigned_t x) + { + assert(false); // LCOV_EXCL_LINE + return x; // LCOV_EXCL_LINE + } - /* - * Helper function for dump_integer - * - * This function takes a negative signed integer and returns its absolute - * value as unsigned integer. The plus/minus shuffling is necessary as we can - * not directly remove the sign of an arbitrary signed integer as the - * absolute values of INT_MIN and INT_MAX are usually not the same. See - * `#1708` for details. - */ - inline number_unsigned_t remove_sign(number_integer_t x) noexcept - { - assert(x < 0 && x < (std::numeric_limits::max)()); - return static_cast(-(x + 1)) + 1; - } + /* + * Helper function for dump_integer + * + * This function takes a negative signed integer and returns its absolute + * value as unsigned integer. The plus/minus shuffling is necessary as we can + * not directly remove the sign of an arbitrary signed integer as the + * absolute values of INT_MIN and INT_MAX are usually not the same. See + * `#1708` for details. + */ + inline number_unsigned_t remove_sign(number_integer_t x) noexcept + { + assert(x < 0 && x < (std::numeric_limits::max)()); + return static_cast(-(x + 1)) + 1; + } - private: - /// the output of the serializer - output_adapter_t o = nullptr; + private: + /// the output of the serializer + output_adapter_t o = nullptr; - /// a (hopefully) large enough character buffer - std::array number_buffer{{}}; + /// a (hopefully) large enough character buffer + std::array number_buffer{{}}; - /// the locale - const std::lconv* loc = nullptr; - /// the locale's thousand separator character - const char thousands_sep = '\0'; - /// the locale's decimal point character - const char decimal_point = '\0'; + /// the locale + const std::lconv* loc = nullptr; + /// the locale's thousand separator character + const char thousands_sep = '\0'; + /// the locale's decimal point character + const char decimal_point = '\0'; - /// string buffer - std::array string_buffer{{}}; + /// string buffer + std::array string_buffer{{}}; - /// the indentation character - const char indent_char; - /// the indentation string - string_t indent_string; + /// the indentation character + const char indent_char; + /// the indentation string + string_t indent_string; - /// error_handler how to react on decoding errors - const error_handler_t error_handler; - }; + /// error_handler how to react on decoding errors + const error_handler_t error_handler; + }; }}}}} // namespace Azure::Core::Json::_internal::detail // #include diff --git a/sdk/core/azure-core/inc/azure/core/internal/tracing/tracing_impl.hpp b/sdk/core/azure-core/inc/azure/core/internal/tracing/tracing_impl.hpp index 0401d2fdce..98111f50c4 100644 --- a/sdk/core/azure-core/inc/azure/core/internal/tracing/tracing_impl.hpp +++ b/sdk/core/azure-core/inc/azure/core/internal/tracing/tracing_impl.hpp @@ -11,6 +11,7 @@ #include "azure/core/datetime.hpp" #include "azure/core/nullable.hpp" #include "azure/core/tracing/tracing.hpp" + #include #include #include diff --git a/sdk/core/azure-core/inc/azure/core/operation_status.hpp b/sdk/core/azure-core/inc/azure/core/operation_status.hpp index fd969bd0bc..73535faef3 100644 --- a/sdk/core/azure-core/inc/azure/core/operation_status.hpp +++ b/sdk/core/azure-core/inc/azure/core/operation_status.hpp @@ -10,12 +10,11 @@ #pragma once #include "azure/core/dll_import_export.hpp" +#include "azure/core/internal/strings.hpp" #include #include // for std::move -#include "azure/core/internal/strings.hpp" - namespace Azure { namespace Core { /** diff --git a/sdk/core/azure-core/inc/azure/core/paged_response.hpp b/sdk/core/azure-core/inc/azure/core/paged_response.hpp index a4d279542c..925509886d 100644 --- a/sdk/core/azure-core/inc/azure/core/paged_response.hpp +++ b/sdk/core/azure-core/inc/azure/core/paged_response.hpp @@ -8,13 +8,13 @@ #pragma once -#include -#include - #include "azure/core/context.hpp" #include "azure/core/http/raw_response.hpp" #include "azure/core/nullable.hpp" +#include +#include + namespace Azure { namespace Core { /** diff --git a/sdk/core/azure-core/inc/azure/core/response.hpp b/sdk/core/azure-core/inc/azure/core/response.hpp index f8460c26ec..3bb13c6374 100644 --- a/sdk/core/azure-core/inc/azure/core/response.hpp +++ b/sdk/core/azure-core/inc/azure/core/response.hpp @@ -11,6 +11,7 @@ #include "azure/core/http/http.hpp" #include "azure/core/nullable.hpp" + #include // for unique_ptr #include #include // for move diff --git a/sdk/core/azure-core/inc/azure/core/tracing/tracing.hpp b/sdk/core/azure-core/inc/azure/core/tracing/tracing.hpp index 470f10e481..6b7be7f677 100644 --- a/sdk/core/azure-core/inc/azure/core/tracing/tracing.hpp +++ b/sdk/core/azure-core/inc/azure/core/tracing/tracing.hpp @@ -9,6 +9,7 @@ #pragma once #include + #include #include diff --git a/sdk/core/azure-core/src/base64.cpp b/sdk/core/azure-core/src/base64.cpp index ab485cc8d3..9e9803acef 100644 --- a/sdk/core/azure-core/src/base64.cpp +++ b/sdk/core/azure-core/src/base64.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/base64.hpp" + #include "azure/core/platform.hpp" #include diff --git a/sdk/core/azure-core/src/datetime.cpp b/sdk/core/azure-core/src/datetime.cpp index f70c125e47..f1d2c11f9d 100644 --- a/sdk/core/azure-core/src/datetime.cpp +++ b/sdk/core/azure-core/src/datetime.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/datetime.hpp" + #include "azure/core/internal/strings.hpp" #include "azure/core/platform.hpp" diff --git a/sdk/core/azure-core/src/environment.cpp b/sdk/core/azure-core/src/environment.cpp index cb4c9c47bd..b5e43c712b 100644 --- a/sdk/core/azure-core/src/environment.cpp +++ b/sdk/core/azure-core/src/environment.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "azure/core/platform.hpp" - #include "azure/core/internal/environment.hpp" +#include "azure/core/platform.hpp" + #if defined(AZ_PLATFORM_WINDOWS) #if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN @@ -13,9 +13,9 @@ #define NOMINMAX #endif -#include - #include + +#include #else #include #endif diff --git a/sdk/core/azure-core/src/exception.cpp b/sdk/core/azure-core/src/exception.cpp index 330bb60018..3a03c1ba10 100644 --- a/sdk/core/azure-core/src/exception.cpp +++ b/sdk/core/azure-core/src/exception.cpp @@ -2,9 +2,11 @@ // SPDX-License-Identifier: MIT #include "azure/core/exception.hpp" + #include "azure/core/http/http.hpp" #include "azure/core/http/policies/policy.hpp" #include "azure/core/internal/json/json.hpp" + #include #include #include diff --git a/sdk/core/azure-core/src/http/bearer_token_authentication_policy.cpp b/sdk/core/azure-core/src/http/bearer_token_authentication_policy.cpp index e8fd9ffc65..924b2d1fc9 100644 --- a/sdk/core/azure-core/src/http/bearer_token_authentication_policy.cpp +++ b/sdk/core/azure-core/src/http/bearer_token_authentication_policy.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "azure/core/http/policies/policy.hpp" - #include "azure/core/credentials/credentials.hpp" +#include "azure/core/http/policies/policy.hpp" #include "azure/core/internal/credentials/authorization_challenge_parser.hpp" #include diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index 80309f8936..89c0ade9de 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -63,6 +63,7 @@ #if defined(AZ_PLATFORM_POSIX) #include // for poll() + #include // for socket shutdown #elif defined(AZ_PLATFORM_WINDOWS) #include // for WSAPoll(); diff --git a/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp b/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp index df455984e3..fff264bb21 100644 --- a/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp +++ b/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp @@ -11,11 +11,11 @@ #include "azure/core/dll_import_export.hpp" #include "azure/core/http/http.hpp" - #include "curl_connection_private.hpp" -#include #include + +#include #include #include #include diff --git a/sdk/core/azure-core/src/http/curl/curl_connection_private.hpp b/sdk/core/azure-core/src/http/curl/curl_connection_private.hpp index ce6354a6c1..f2ce456b23 100644 --- a/sdk/core/azure-core/src/http/curl/curl_connection_private.hpp +++ b/sdk/core/azure-core/src/http/curl/curl_connection_private.hpp @@ -11,6 +11,7 @@ #include "azure/core/http/http.hpp" #include "azure/core/internal/unique_handle.hpp" + #include #include diff --git a/sdk/core/azure-core/src/http/curl/curl_session_private.hpp b/sdk/core/azure-core/src/http/curl/curl_session_private.hpp index 9c5ba99fab..25b3f00f1b 100644 --- a/sdk/core/azure-core/src/http/curl/curl_session_private.hpp +++ b/sdk/core/azure-core/src/http/curl/curl_session_private.hpp @@ -12,7 +12,6 @@ #pragma once #include "azure/core/http/http.hpp" - #include "curl_connection_pool_private.hpp" #include "curl_connection_private.hpp" diff --git a/sdk/core/azure-core/src/http/http.cpp b/sdk/core/azure-core/src/http/http.cpp index 0cd34fc89f..b8850f618a 100644 --- a/sdk/core/azure-core/src/http/http.cpp +++ b/sdk/core/azure-core/src/http/http.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/http/http.hpp" + #include "azure/core/http/policies/policy.hpp" #include "azure/core/internal/strings.hpp" #include "azure/core/url.hpp" diff --git a/sdk/core/azure-core/src/http/http_sanitizer.cpp b/sdk/core/azure-core/src/http/http_sanitizer.cpp index 66792761ea..4aceede23f 100644 --- a/sdk/core/azure-core/src/http/http_sanitizer.cpp +++ b/sdk/core/azure-core/src/http/http_sanitizer.cpp @@ -2,7 +2,9 @@ // SPDX-License-Identifier: MIT #include "azure/core/internal/http/http_sanitizer.hpp" + #include "azure/core/url.hpp" + #include #include diff --git a/sdk/core/azure-core/src/http/policy.cpp b/sdk/core/azure-core/src/http/policy.cpp index 9202267f54..b1096a1ee0 100644 --- a/sdk/core/azure-core/src/http/policy.cpp +++ b/sdk/core/azure-core/src/http/policy.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/http/policies/policy.hpp" + #include "azure/core/http/http.hpp" using Azure::Core::Context; diff --git a/sdk/core/azure-core/src/http/raw_response.cpp b/sdk/core/azure-core/src/http/raw_response.cpp index f3316d3b35..f2bca95cfe 100644 --- a/sdk/core/azure-core/src/http/raw_response.cpp +++ b/sdk/core/azure-core/src/http/raw_response.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/http/raw_response.hpp" + #include "azure/core/http/http.hpp" using namespace Azure::Core::IO; diff --git a/sdk/core/azure-core/src/http/url.cpp b/sdk/core/azure-core/src/http/url.cpp index 9ef2faa46e..1ae3850268 100644 --- a/sdk/core/azure-core/src/http/url.cpp +++ b/sdk/core/azure-core/src/http/url.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/url.hpp" + #include "azure/core/internal/strings.hpp" #include diff --git a/sdk/core/azure-core/src/http/user_agent.cpp b/sdk/core/azure-core/src/http/user_agent.cpp index 3e5ae5128b..71e829941e 100644 --- a/sdk/core/azure-core/src/http/user_agent.cpp +++ b/sdk/core/azure-core/src/http/user_agent.cpp @@ -7,13 +7,14 @@ * @remark See #policy.hpp */ -#include - #include "azure/core/context.hpp" #include "azure/core/http/policies/policy.hpp" #include "azure/core/internal/strings.hpp" #include "azure/core/internal/tracing/service_tracing.hpp" #include "azure/core/platform.hpp" + +#include + #include #if defined(AZ_PLATFORM_WINDOWS) diff --git a/sdk/core/azure-core/src/http/winhttp/win_http_request.hpp b/sdk/core/azure-core/src/http/winhttp/win_http_request.hpp index 97e083bff9..1eb637ee3e 100644 --- a/sdk/core/azure-core/src/http/winhttp/win_http_request.hpp +++ b/sdk/core/azure-core/src/http/winhttp/win_http_request.hpp @@ -12,7 +12,9 @@ #include "azure/core/http/win_http_transport.hpp" #include "azure/core/url.hpp" + #include + #include #include #pragma warning(push) diff --git a/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp b/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp index f0276fddca..f9181f49ed 100644 --- a/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp +++ b/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp @@ -2,10 +2,9 @@ // SPDX-License-Identifier: MIT // cspell:words HCERTIFICATECHAIN PCCERT CCERT HCERTCHAINENGINE HCERTSTORE -#include "azure/core/http/http.hpp" - #include "azure/core/base64.hpp" #include "azure/core/diagnostics/logger.hpp" +#include "azure/core/http/http.hpp" #include "azure/core/internal/diagnostics/log.hpp" #include "azure/core/internal/strings.hpp" #include "azure/core/internal/unique_handle.hpp" @@ -16,6 +15,7 @@ #endif #include + #include #include #include diff --git a/sdk/core/azure-core/src/io/body_stream.cpp b/sdk/core/azure-core/src/io/body_stream.cpp index 2c2e036676..fe64affa6a 100644 --- a/sdk/core/azure-core/src/io/body_stream.cpp +++ b/sdk/core/azure-core/src/io/body_stream.cpp @@ -6,8 +6,9 @@ #if defined(AZ_PLATFORM_POSIX) #include #include // for open and _O_RDONLY -#include // for lseek #include // for lseek + +#include // for lseek #elif defined(AZ_PLATFORM_WINDOWS) #if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN diff --git a/sdk/core/azure-core/src/logger.cpp b/sdk/core/azure-core/src/logger.cpp index e502e5be99..ded80a4352 100644 --- a/sdk/core/azure-core/src/logger.cpp +++ b/sdk/core/azure-core/src/logger.cpp @@ -2,13 +2,13 @@ // SPDX-License-Identifier: MIT #include "azure/core/diagnostics/logger.hpp" + #include "azure/core/internal/diagnostics/log.hpp" +#include "private/environment_log_level_listener.hpp" #include #include -#include "private/environment_log_level_listener.hpp" - using namespace Azure::Core::Diagnostics; using namespace Azure::Core::Diagnostics::_internal; diff --git a/sdk/core/azure-core/src/tracing/tracing.cpp b/sdk/core/azure-core/src/tracing/tracing.cpp index f3453f78b3..a37d350d02 100644 --- a/sdk/core/azure-core/src/tracing/tracing.cpp +++ b/sdk/core/azure-core/src/tracing/tracing.cpp @@ -5,6 +5,7 @@ #include "azure/core/http/policies/policy.hpp" #include "azure/core/internal/tracing/service_tracing.hpp" #include "azure/core/internal/tracing/tracing_impl.hpp" + #include namespace Azure { namespace Core { namespace Tracing { namespace _internal { diff --git a/sdk/core/azure-core/test/libcurl-stress-test/deploy.ps1 b/sdk/core/azure-core/test/libcurl-stress-test/deploy.ps1 index cdd1e5a802..f37d3a9df5 100644 --- a/sdk/core/azure-core/test/libcurl-stress-test/deploy.ps1 +++ b/sdk/core/azure-core/test/libcurl-stress-test/deploy.ps1 @@ -1,2 +1,2 @@ Set-Location $PSScriptRoot -pwsh "../../../../../eng/common/scripts/stress-testing/deploy-stress-tests.ps1" -Login -PushImages +pwsh "../../../../../eng/common/scripts/stress-testing/deploy-stress-tests.ps1" diff --git a/sdk/core/azure-core/test/libcurl-stress-test/libcurl_stress_test.cpp b/sdk/core/azure-core/test/libcurl-stress-test/libcurl_stress_test.cpp index 06a4b4709b..e5c74247d4 100644 --- a/sdk/core/azure-core/test/libcurl-stress-test/libcurl_stress_test.cpp +++ b/sdk/core/azure-core/test/libcurl-stress-test/libcurl_stress_test.cpp @@ -16,6 +16,7 @@ #include #include + #include void SendRequest(std::string target) diff --git a/sdk/core/azure-core/test/perf/src/azure_core_perf_test.cpp b/sdk/core/azure-core/test/perf/src/azure_core_perf_test.cpp index 880eab2584..e512b23473 100644 --- a/sdk/core/azure-core/test/perf/src/azure_core_perf_test.cpp +++ b/sdk/core/azure-core/test/perf/src/azure_core_perf_test.cpp @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/core/test/nullable_test.hpp" #include "azure/core/test/uuid_test.hpp" +#include + #include int main(int argc, char** argv) diff --git a/sdk/core/azure-core/test/ut/CMakeLists.txt b/sdk/core/azure-core/test/ut/CMakeLists.txt index fb1617e75b..13d5878cde 100644 --- a/sdk/core/azure-core/test/ut/CMakeLists.txt +++ b/sdk/core/azure-core/test/ut/CMakeLists.txt @@ -42,6 +42,7 @@ endif() add_executable ( azure-core-test + test_traits.hpp authorization_challenge_parser_test.cpp azure_core_test.cpp base64_test.cpp diff --git a/sdk/core/azure-core/test/ut/azure_core_test.cpp b/sdk/core/azure-core/test/ut/azure_core_test.cpp index 1b257efd75..a80ec4e072 100644 --- a/sdk/core/azure-core/test/ut/azure_core_test.cpp +++ b/sdk/core/azure-core/test/ut/azure_core_test.cpp @@ -1,13 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/core/internal/diagnostics/global_exception.hpp" #include "azure/core/platform.hpp" + #include #include +#include + int main(int argc, char** argv) { #if defined(AZ_PLATFORM_POSIX) diff --git a/sdk/core/azure-core/test/ut/azure_libcurl_core_main_test.cpp b/sdk/core/azure-core/test/ut/azure_libcurl_core_main_test.cpp index 169919e835..2f50d25f16 100644 --- a/sdk/core/azure-core/test/ut/azure_libcurl_core_main_test.cpp +++ b/sdk/core/azure-core/test/ut/azure_libcurl_core_main_test.cpp @@ -13,11 +13,6 @@ #if !defined(NOMINMAX) #define NOMINMAX #endif -#include -#include - -#include - #include "azure/core/context.hpp" #include "azure/core/http/curl_transport.hpp" #include "azure/core/http/http.hpp" @@ -29,6 +24,11 @@ #include "http/curl/curl_connection_private.hpp" #include "http/curl/curl_session_private.hpp" +#include +#include + +#include + namespace Azure { namespace Core { namespace Test { TEST(SdkWithLibcurl, globalCleanUp) { diff --git a/sdk/core/azure-core/test/ut/base64_test.cpp b/sdk/core/azure-core/test/ut/base64_test.cpp index bb11e7a159..c36f82a9ae 100644 --- a/sdk/core/azure-core/test/ut/base64_test.cpp +++ b/sdk/core/azure-core/test/ut/base64_test.cpp @@ -2,11 +2,13 @@ // SPDX-License-Identifier: MIT #include -#include + #include #include #include +#include + using namespace Azure::Core; TEST(Base64, Basic) diff --git a/sdk/core/azure-core/test/ut/bearer_token_authentication_policy_test.cpp b/sdk/core/azure-core/test/ut/bearer_token_authentication_policy_test.cpp index 7f62e91c88..cec24d5a38 100644 --- a/sdk/core/azure-core/test/ut/bearer_token_authentication_policy_test.cpp +++ b/sdk/core/azure-core/test/ut/bearer_token_authentication_policy_test.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include +#include #include #include diff --git a/sdk/core/azure-core/test/ut/bodystream_test.cpp b/sdk/core/azure-core/test/ut/bodystream_test.cpp index 446a435ea3..0f3de5b6b5 100644 --- a/sdk/core/azure-core/test/ut/bodystream_test.cpp +++ b/sdk/core/azure-core/test/ut/bodystream_test.cpp @@ -17,10 +17,10 @@ #include #endif -#include - #include +#include + using namespace Azure::Core::IO; using namespace Azure::Core; diff --git a/sdk/core/azure-core/test/ut/case_insensitive_containers_test.cpp b/sdk/core/azure-core/test/ut/case_insensitive_containers_test.cpp index e02b99cd4b..6193978425 100644 --- a/sdk/core/azure-core/test/ut/case_insensitive_containers_test.cpp +++ b/sdk/core/azure-core/test/ut/case_insensitive_containers_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include +#include + using namespace Azure::Core; TEST(CaseInsensitiveMap, Find) diff --git a/sdk/core/azure-core/test/ut/client_options_test.cpp b/sdk/core/azure-core/test/ut/client_options_test.cpp index 367c40e3ed..b8060af0a7 100644 --- a/sdk/core/azure-core/test/ut/client_options_test.cpp +++ b/sdk/core/azure-core/test/ut/client_options_test.cpp @@ -6,11 +6,12 @@ #include #include #include -#include #include #include +#include + using namespace Azure::Core; using namespace Azure::Core::_internal; using namespace Azure::Core::Http; diff --git a/sdk/core/azure-core/test/ut/context_test.cpp b/sdk/core/azure-core/test/ut/context_test.cpp index 0eb9e72df0..5d54102556 100644 --- a/sdk/core/azure-core/test/ut/context_test.cpp +++ b/sdk/core/azure-core/test/ut/context_test.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include #include @@ -12,6 +10,8 @@ #include #include +#include + using namespace Azure::Core; TEST(Context, Basic) diff --git a/sdk/core/azure-core/test/ut/curl_connection_pool_test.cpp b/sdk/core/azure-core/test/ut/curl_connection_pool_test.cpp index a02b2eec1d..23b43b48b3 100644 --- a/sdk/core/azure-core/test/ut/curl_connection_pool_test.cpp +++ b/sdk/core/azure-core/test/ut/curl_connection_pool_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "transport_adapter_base_test.hpp" + #include #include #include @@ -16,12 +17,12 @@ // The next includes are from Azure Core private headers. // They are included to test the connection pool from the libcurl transport adapter implementation. +#include "curl_session_test.hpp" + #include #include #include -#include "curl_session_test.hpp" - using testing::ValuesIn; using namespace Azure::Core::Http::_detail; using namespace std::chrono_literals; diff --git a/sdk/core/azure-core/test/ut/curl_options_test.cpp b/sdk/core/azure-core/test/ut/curl_options_test.cpp index a1ffdf3aab..34e76a5fee 100644 --- a/sdk/core/azure-core/test/ut/curl_options_test.cpp +++ b/sdk/core/azure-core/test/ut/curl_options_test.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include #include #include @@ -10,19 +8,21 @@ #include #include +#include + #if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) #include "azure/core/http/curl_transport.hpp" #endif -#include -#include -#include - #include "transport_adapter_base_test.hpp" #include #include +#include +#include +#include + namespace Azure { namespace Core { namespace Test { // proxy server can take some minutes to handle the request. Only testing HTTP proxy diff --git a/sdk/core/azure-core/test/ut/curl_session_test.hpp b/sdk/core/azure-core/test/ut/curl_session_test.hpp index f84c11398e..936fb206cb 100644 --- a/sdk/core/azure-core/test/ut/curl_session_test.hpp +++ b/sdk/core/azure-core/test/ut/curl_session_test.hpp @@ -19,10 +19,11 @@ #endif // _MSC_VER #include -#include -#include + #include +#include +#include #include namespace Azure { namespace Core { namespace Test { diff --git a/sdk/core/azure-core/test/ut/datetime_test.cpp b/sdk/core/azure-core/test/ut/datetime_test.cpp index eaf59d0186..99bcc83c39 100644 --- a/sdk/core/azure-core/test/ut/datetime_test.cpp +++ b/sdk/core/azure-core/test/ut/datetime_test.cpp @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include #include #include #include +#include + using namespace Azure; // cspell:words AGMT, CEST diff --git a/sdk/core/azure-core/test/ut/environment_log_level_listener_test.cpp b/sdk/core/azure-core/test/ut/environment_log_level_listener_test.cpp index 85f3b009fe..dae8a371f5 100644 --- a/sdk/core/azure-core/test/ut/environment_log_level_listener_test.cpp +++ b/sdk/core/azure-core/test/ut/environment_log_level_listener_test.cpp @@ -1,11 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include #include +#include using Azure::Core::Diagnostics::Logger; using Azure::Core::Diagnostics::_detail::EnvironmentLogLevelListener; diff --git a/sdk/core/azure-core/test/ut/etag_test.cpp b/sdk/core/azure-core/test/ut/etag_test.cpp index 6369b6a35c..bc5cb3d983 100644 --- a/sdk/core/azure-core/test/ut/etag_test.cpp +++ b/sdk/core/azure-core/test/ut/etag_test.cpp @@ -1,12 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT - -#include +#include "test_traits.hpp" #include #include +#include + using namespace Azure; TEST(ETag, ToString) @@ -259,6 +260,54 @@ TEST(ETag, EqualsWeak) EXPECT_FALSE(ETag::Equals(weakTagtwo, weakTagTwo, ETag::ETagComparison::Weak)); } +TEST(Etag, Assignable) +{ + EXPECT_TRUE(ClassTraits::is_assignable()); + EXPECT_TRUE(ClassTraits::is_assignable()); + EXPECT_FALSE(ClassTraits::is_trivially_assignable()); + EXPECT_FALSE(ClassTraits::is_trivially_assignable()); + EXPECT_TRUE(ClassTraits::is_nothrow_assignable()); + EXPECT_FALSE(ClassTraits::is_nothrow_assignable()); +} + +TEST(Etag, Constructible) +{ + EXPECT_TRUE((ClassTraits::is_constructible())); + EXPECT_FALSE((ClassTraits::is_trivially_constructible())); + EXPECT_FALSE((ClassTraits::is_nothrow_constructible())); + EXPECT_TRUE(ClassTraits::is_default_constructible()); + EXPECT_FALSE(ClassTraits::is_trivially_default_constructible()); + EXPECT_FALSE(ClassTraits::is_nothrow_default_constructible()); +} + +TEST(Etag, CopyAndMoveConstructible) +{ + EXPECT_TRUE(ClassTraits::is_copy_constructible()); + EXPECT_FALSE(ClassTraits::is_trivially_copy_constructible()); + EXPECT_FALSE(ClassTraits::is_nothrow_copy_constructible()); + EXPECT_TRUE(ClassTraits::is_move_constructible()); + EXPECT_FALSE(ClassTraits::is_trivially_move_constructible()); + EXPECT_TRUE(ClassTraits::is_nothrow_move_constructible()); +} + +TEST(Etag, CopyAndMoveAssignable) +{ + EXPECT_TRUE(ClassTraits::is_copy_assignable()); + EXPECT_FALSE(ClassTraits::is_trivially_copy_assignable()); + EXPECT_FALSE(ClassTraits::is_nothrow_copy_assignable()); + EXPECT_TRUE(ClassTraits::is_move_assignable()); + EXPECT_FALSE(ClassTraits::is_trivially_move_assignable()); + EXPECT_TRUE(ClassTraits::is_nothrow_move_assignable()); +} + +TEST(Etag, Destructible) +{ + EXPECT_TRUE(ClassTraits::is_destructible()); + EXPECT_FALSE(ClassTraits::is_trivially_destructible()); + EXPECT_TRUE(ClassTraits::is_nothrow_destructible()); + EXPECT_FALSE(ClassTraits::has_virtual_destructor()); +} + #if GTEST_HAS_DEATH_TEST TEST(ETag, PreCondition) { diff --git a/sdk/core/azure-core/test/ut/exception_test.cpp b/sdk/core/azure-core/test/ut/exception_test.cpp index 023d1e0457..4077cfdd33 100644 --- a/sdk/core/azure-core/test/ut/exception_test.cpp +++ b/sdk/core/azure-core/test/ut/exception_test.cpp @@ -3,9 +3,11 @@ #include #include -#include + #include +#include + using namespace Azure::Core; using namespace Azure::Core::Http::_internal; diff --git a/sdk/core/azure-core/test/ut/extendable_enumeration_test.cpp b/sdk/core/azure-core/test/ut/extendable_enumeration_test.cpp index 2747466f40..01af12da40 100644 --- a/sdk/core/azure-core/test/ut/extendable_enumeration_test.cpp +++ b/sdk/core/azure-core/test/ut/extendable_enumeration_test.cpp @@ -2,9 +2,11 @@ // SPDX-License-Identifier: MIT #include -#include + #include +#include + using namespace Azure::Core; class MyEnum : public Azure::Core::_internal::ExtendableEnumeration { diff --git a/sdk/core/azure-core/test/ut/global_context_test.cpp b/sdk/core/azure-core/test/ut/global_context_test.cpp index c642b3acb5..ce2a7d1754 100644 --- a/sdk/core/azure-core/test/ut/global_context_test.cpp +++ b/sdk/core/azure-core/test/ut/global_context_test.cpp @@ -10,14 +10,14 @@ * */ -#include - #include #include #include #include +#include + using namespace Azure::Core; TEST(Context, ApplicationContext) diff --git a/sdk/core/azure-core/test/ut/http_method_test.cpp b/sdk/core/azure-core/test/ut/http_method_test.cpp index a5ad171b69..45f05da8b3 100644 --- a/sdk/core/azure-core/test/ut/http_method_test.cpp +++ b/sdk/core/azure-core/test/ut/http_method_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include +#include + using namespace Azure::Core::Http; // cSpell:words humuhumunukunukuapuaa diff --git a/sdk/core/azure-core/test/ut/http_test.cpp b/sdk/core/azure-core/test/ut/http_test.cpp index 9a90c23d4c..2f30f33afd 100644 --- a/sdk/core/azure-core/test/ut/http_test.cpp +++ b/sdk/core/azure-core/test/ut/http_test.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "http_test.hpp" + #include #include #include @@ -12,6 +11,8 @@ #include #include +#include + using namespace Azure::Core; namespace Azure { namespace Core { namespace Test { diff --git a/sdk/core/azure-core/test/ut/http_test.hpp b/sdk/core/azure-core/test/ut/http_test.hpp index 0772748ce1..102d2e5686 100644 --- a/sdk/core/azure-core/test/ut/http_test.hpp +++ b/sdk/core/azure-core/test/ut/http_test.hpp @@ -7,10 +7,10 @@ * */ -#include - #include +#include + namespace Azure { namespace Core { namespace Test { class TestHttp : public ::testing::Test { diff --git a/sdk/core/azure-core/test/ut/json_test.cpp b/sdk/core/azure-core/test/ut/json_test.cpp index 7fdf2c21d4..cf9850f00c 100644 --- a/sdk/core/azure-core/test/ut/json_test.cpp +++ b/sdk/core/azure-core/test/ut/json_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include + #include using json = Azure::Core::Json::_internal::json; diff --git a/sdk/core/azure-core/test/ut/logging_test.cpp b/sdk/core/azure-core/test/ut/logging_test.cpp index 90c01e851d..d71e7250b2 100644 --- a/sdk/core/azure-core/test/ut/logging_test.cpp +++ b/sdk/core/azure-core/test/ut/logging_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include + #include using Azure::Core::Diagnostics::Logger; diff --git a/sdk/core/azure-core/test/ut/match_conditions_test.cpp b/sdk/core/azure-core/test/ut/match_conditions_test.cpp index f588cb01a9..95575be089 100644 --- a/sdk/core/azure-core/test/ut/match_conditions_test.cpp +++ b/sdk/core/azure-core/test/ut/match_conditions_test.cpp @@ -3,9 +3,11 @@ #include #include -#include + #include +#include + using namespace Azure; TEST(MatchConditions, Basic) diff --git a/sdk/core/azure-core/test/ut/md5_test.cpp b/sdk/core/azure-core/test/ut/md5_test.cpp index 792fa3d75c..dc19426272 100644 --- a/sdk/core/azure-core/test/ut/md5_test.cpp +++ b/sdk/core/azure-core/test/ut/md5_test.cpp @@ -1,16 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include #include #include + +#include #include -#include #include #include #include #include +#include + using namespace Azure::Core::Cryptography; static std::vector ComputeHash(const std::string& data) diff --git a/sdk/core/azure-core/test/ut/modified_conditions_test.cpp b/sdk/core/azure-core/test/ut/modified_conditions_test.cpp index 676f591289..8486ff7a19 100644 --- a/sdk/core/azure-core/test/ut/modified_conditions_test.cpp +++ b/sdk/core/azure-core/test/ut/modified_conditions_test.cpp @@ -3,10 +3,12 @@ #include #include -#include + #include #include +#include + using namespace Azure; TEST(ModifiedConditions, Basic) diff --git a/sdk/core/azure-core/test/ut/nullable_test.cpp b/sdk/core/azure-core/test/ut/nullable_test.cpp index adee4830d3..a9f05a320f 100644 --- a/sdk/core/azure-core/test/ut/nullable_test.cpp +++ b/sdk/core/azure-core/test/ut/nullable_test.cpp @@ -2,10 +2,12 @@ // SPDX-License-Identifier: MIT #include -#include + #include #include +#include + using namespace Azure; TEST(Nullable, Basic) diff --git a/sdk/core/azure-core/test/ut/operation_status_test.cpp b/sdk/core/azure-core/test/ut/operation_status_test.cpp index a613a7e37d..2274a25d84 100644 --- a/sdk/core/azure-core/test/ut/operation_status_test.cpp +++ b/sdk/core/azure-core/test/ut/operation_status_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include +#include + using namespace Azure::Core; TEST(OperationStatus, Basic) diff --git a/sdk/core/azure-core/test/ut/operation_test.cpp b/sdk/core/azure-core/test/ut/operation_test.cpp index f76755d939..03dd493a5f 100644 --- a/sdk/core/azure-core/test/ut/operation_test.cpp +++ b/sdk/core/azure-core/test/ut/operation_test.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "operation_test.hpp" #include @@ -11,6 +9,8 @@ #include +#include + using namespace Azure::Core; using namespace Azure::Core::Test; using namespace std::literals; diff --git a/sdk/core/azure-core/test/ut/operation_test.hpp b/sdk/core/azure-core/test/ut/operation_test.hpp index b585eeb798..21c8923b89 100644 --- a/sdk/core/azure-core/test/ut/operation_test.hpp +++ b/sdk/core/azure-core/test/ut/operation_test.hpp @@ -8,10 +8,13 @@ #include #include #include + #include #include #include +#include + namespace Azure { namespace Core { namespace Test { class StringClient; diff --git a/sdk/core/azure-core/test/ut/pipeline_test.cpp b/sdk/core/azure-core/test/ut/pipeline_test.cpp index cabd6c5d04..43478ce378 100644 --- a/sdk/core/azure-core/test/ut/pipeline_test.cpp +++ b/sdk/core/azure-core/test/ut/pipeline_test.cpp @@ -3,10 +3,11 @@ #include #include -#include #include +#include + TEST(Pipeline, createPipeline) { // Construct pipeline without exception diff --git a/sdk/core/azure-core/test/ut/policy_test.cpp b/sdk/core/azure-core/test/ut/policy_test.cpp index 3b57dd00c9..8971cf6edc 100644 --- a/sdk/core/azure-core/test/ut/policy_test.cpp +++ b/sdk/core/azure-core/test/ut/policy_test.cpp @@ -3,10 +3,11 @@ #include #include -#include #include +#include + namespace { class NoOpPolicy final : public Azure::Core::Http::Policies::HttpPolicy { public: diff --git a/sdk/core/azure-core/test/ut/request_activity_policy_test.cpp b/sdk/core/azure-core/test/ut/request_activity_policy_test.cpp index 2af4ddb13a..16af896dcb 100644 --- a/sdk/core/azure-core/test/ut/request_activity_policy_test.cpp +++ b/sdk/core/azure-core/test/ut/request_activity_policy_test.cpp @@ -5,9 +5,11 @@ #include "azure/core/internal/http/pipeline.hpp" #include "azure/core/internal/tracing/service_tracing.hpp" #include "azure/core/tracing/tracing.hpp" -#include + #include +#include + using namespace Azure::Core; using namespace Azure::Core::Http; using namespace Azure::Core::Http::Policies; diff --git a/sdk/core/azure-core/test/ut/response_t_test.cpp b/sdk/core/azure-core/test/ut/response_t_test.cpp index ee7f89595e..d368ce1424 100644 --- a/sdk/core/azure-core/test/ut/response_t_test.cpp +++ b/sdk/core/azure-core/test/ut/response_t_test.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include #include @@ -10,6 +8,8 @@ #include #include +#include + using namespace Azure::Core; using namespace Azure::Core::Http; diff --git a/sdk/core/azure-core/test/ut/retry_policy_test.cpp b/sdk/core/azure-core/test/ut/retry_policy_test.cpp index da2db233da..10bab673c8 100644 --- a/sdk/core/azure-core/test/ut/retry_policy_test.cpp +++ b/sdk/core/azure-core/test/ut/retry_policy_test.cpp @@ -5,10 +5,10 @@ #include "azure/core/http/policies/policy.hpp" #include "azure/core/internal/http/pipeline.hpp" -#include - #include +#include + using namespace Azure::Core::Http; using namespace Azure::Core::Http::Policies; using namespace Azure::Core::Http::Policies::_internal; diff --git a/sdk/core/azure-core/test/ut/service_tracing_test.cpp b/sdk/core/azure-core/test/ut/service_tracing_test.cpp index 1823938f5c..b8d109d8b7 100644 --- a/sdk/core/azure-core/test/ut/service_tracing_test.cpp +++ b/sdk/core/azure-core/test/ut/service_tracing_test.cpp @@ -2,7 +2,9 @@ // SPDX-License-Identifier: MIT #include "azure/core/internal/tracing/tracing_impl.hpp" + #include + #include using namespace Azure::Core; @@ -39,6 +41,7 @@ TEST(TracingContextFactory, ServiceTraceEnums) #include #include + #include using namespace Azure::Core; diff --git a/sdk/core/azure-core/test/ut/sha_test.cpp b/sdk/core/azure-core/test/ut/sha_test.cpp index 826f805503..868df62379 100644 --- a/sdk/core/azure-core/test/ut/sha_test.cpp +++ b/sdk/core/azure-core/test/ut/sha_test.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "gtest/gtest.h" - #include "azure/core/internal/cryptography/sha_hash.hpp" +#include "gtest/gtest.h" using namespace Azure::Core::Cryptography::_internal; diff --git a/sdk/core/azure-core/test/ut/simplified_header_test.cpp b/sdk/core/azure-core/test/ut/simplified_header_test.cpp index e5db883674..3f396340b5 100644 --- a/sdk/core/azure-core/test/ut/simplified_header_test.cpp +++ b/sdk/core/azure-core/test/ut/simplified_header_test.cpp @@ -18,10 +18,11 @@ #endif // _MSC_VER #include -#include #include +#include + class DllExportTest final { AZ_CORE_DLLEXPORT static const bool DllExportHIncluded; }; diff --git a/sdk/core/azure-core/test/ut/string_test.cpp b/sdk/core/azure-core/test/ut/string_test.cpp index acc0d252ab..d4da2e8c6e 100644 --- a/sdk/core/azure-core/test/ut/string_test.cpp +++ b/sdk/core/azure-core/test/ut/string_test.cpp @@ -2,11 +2,12 @@ // SPDX-License-Identifier: MIT #include -#include #include #include +#include + TEST(String, invariantCompare) { using Azure::Core::_internal::StringExtensions; diff --git a/sdk/core/azure-core/test/ut/telemetry_policy_test.cpp b/sdk/core/azure-core/test/ut/telemetry_policy_test.cpp index ee4e4b6756..348483b592 100644 --- a/sdk/core/azure-core/test/ut/telemetry_policy_test.cpp +++ b/sdk/core/azure-core/test/ut/telemetry_policy_test.cpp @@ -3,6 +3,7 @@ #include #include + #include using namespace Azure::Core; diff --git a/sdk/core/azure-core/test/ut/test_traits.hpp b/sdk/core/azure-core/test/ut/test_traits.hpp new file mode 100644 index 0000000000..bac24179c7 --- /dev/null +++ b/sdk/core/azure-core/test/ut/test_traits.hpp @@ -0,0 +1,132 @@ +#include + +template struct ClassTraits +{ + static_assert(std::is_class::value, "ClassTraits can only be used with class types"); + + // Check if T is constructible from Args + static constexpr bool is_constructible() { return std::is_constructible::value; } + + // Check if T is trivially constructible from Args + static constexpr bool is_trivially_constructible() + { + return std::is_trivially_constructible::value; + } + + // Check if T is nothrow constructible from Args + static constexpr bool is_nothrow_constructible() + { + return std::is_nothrow_constructible::value; + } + + // Check if T has a default constructor + static constexpr bool is_default_constructible() + { + return std::is_default_constructible::value; + } + + // Check if T has a trivially default constructor + static constexpr bool is_trivially_default_constructible() + { + return std::is_trivially_default_constructible::value; + } + + // Check if T has a nothrow default constructor + static constexpr bool is_nothrow_default_constructible() + { + return std::is_nothrow_default_constructible::value; + } + + // Check if T is copy-constructible + static constexpr bool is_copy_constructible() { return std::is_copy_constructible::value; } + + // Check if T is trivially copy-constructible + static constexpr bool is_trivially_copy_constructible() + { + return std::is_trivially_copy_constructible::value; + } + + // Check if T is nothrow copy-constructible + static constexpr bool is_nothrow_copy_constructible() + { + return std::is_nothrow_copy_constructible::value; + } + + // Check if T is move-constructible + static constexpr bool is_move_constructible() { return std::is_move_constructible::value; } + + // Check if T is trivially move-constructible + static constexpr bool is_trivially_move_constructible() + { + return std::is_trivially_move_constructible::value; + } + + // Check if T is nothrow move-constructible + static constexpr bool is_nothrow_move_constructible() + { + return std::is_nothrow_move_constructible::value; + } + + // Check if T is assignable from U + template static constexpr bool is_assignable() + { + return std::is_assignable::value; + } + + // Check if T is trivially assignable from U + template static constexpr bool is_trivially_assignable() + { + return std::is_trivially_assignable::value; + } + + // Check if T is nothrow assignable from U + template static constexpr bool is_nothrow_assignable() + { + return std::is_nothrow_assignable::value; + } + + // Check if T is copy-assignable + static constexpr bool is_copy_assignable() { return std::is_copy_assignable::value; } + + // Check if T is trivially copy-assignable + static constexpr bool is_trivially_copy_assignable() + { + return std::is_trivially_copy_assignable::value; + } + + // Check if T is nothrow copy-assignable + static constexpr bool is_nothrow_copy_assignable() + { + return std::is_nothrow_copy_assignable::value; + } + + // Check if T is move-assignable + static constexpr bool is_move_assignable() { return std::is_move_assignable::value; } + + // Check if T is trivially move-assignable + static constexpr bool is_trivially_move_assignable() + { + return std::is_trivially_move_assignable::value; + } + + // Check if T is nothrow move-assignable + static constexpr bool is_nothrow_move_assignable() + { + return std::is_nothrow_move_assignable::value; + } + + // Check if T is destructible + static constexpr bool is_destructible() { return std::is_destructible::value; } + + // Check if T is trivially destructible + static constexpr bool is_trivially_destructible() + { + return std::is_trivially_destructible::value; + } + + // Check if T is nothrow destructible + static constexpr bool is_nothrow_destructible() { return std::is_nothrow_destructible::value; } + + // Check if T has virtual destructor + static constexpr bool has_virtual_destructor() { return std::has_virtual_destructor::value; } +}; \ No newline at end of file diff --git a/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp b/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp index f1ad6dca73..df7a333e42 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp +++ b/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp @@ -17,8 +17,10 @@ #endif #include "transport_adapter_base_test.hpp" + #include #include + #include #include #include diff --git a/sdk/core/azure-core/test/ut/transport_adapter_base_test.hpp b/sdk/core/azure-core/test/ut/transport_adapter_base_test.hpp index 768ba51175..ec108b8ba3 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter_base_test.hpp +++ b/sdk/core/azure-core/test/ut/transport_adapter_base_test.hpp @@ -12,11 +12,12 @@ #include #include #include -#include #include #include +#include + namespace Azure { namespace Core { namespace Test { namespace _detail { diff --git a/sdk/core/azure-core/test/ut/transport_policy_options.cpp b/sdk/core/azure-core/test/ut/transport_policy_options.cpp index ee11723a9c..1a6b13a5cd 100644 --- a/sdk/core/azure-core/test/ut/transport_policy_options.cpp +++ b/sdk/core/azure-core/test/ut/transport_policy_options.cpp @@ -13,11 +13,13 @@ #include "azure/core/internal/json/json.hpp" #include "azure/core/platform.hpp" #include "azure/core/response.hpp" -#include + #include #include #include +#include + using namespace std::chrono_literals; namespace Azure { namespace Core { namespace Test { diff --git a/sdk/core/azure-core/test/ut/url_test.cpp b/sdk/core/azure-core/test/ut/url_test.cpp index a15a715b04..7eb0e780ca 100644 --- a/sdk/core/azure-core/test/ut/url_test.cpp +++ b/sdk/core/azure-core/test/ut/url_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include +#include + namespace Azure { namespace Core { namespace Test { class TestURL : public ::testing::Test { diff --git a/sdk/core/azure-core/test/ut/uuid_test.cpp b/sdk/core/azure-core/test/ut/uuid_test.cpp index 1f47839da3..71b118ddca 100644 --- a/sdk/core/azure-core/test/ut/uuid_test.cpp +++ b/sdk/core/azure-core/test/ut/uuid_test.cpp @@ -2,10 +2,12 @@ // SPDX-License-Identifier: MIT #include -#include + #include #include +#include + using namespace Azure::Core; TEST(Uuid, Basic) diff --git a/sdk/core/perf/inc/azure/perf/base_test.hpp b/sdk/core/perf/inc/azure/perf/base_test.hpp index 18a0e9ee9f..d4a300dde9 100644 --- a/sdk/core/perf/inc/azure/perf/base_test.hpp +++ b/sdk/core/perf/inc/azure/perf/base_test.hpp @@ -11,6 +11,7 @@ #include "azure/perf/options.hpp" #include "azure/perf/test_options.hpp" + #include #include #include diff --git a/sdk/core/perf/inc/azure/perf/options.hpp b/sdk/core/perf/inc/azure/perf/options.hpp index 6c54433fa0..fc0b45be2c 100644 --- a/sdk/core/perf/inc/azure/perf/options.hpp +++ b/sdk/core/perf/inc/azure/perf/options.hpp @@ -9,8 +9,6 @@ #pragma once -#include - #include "azure/core/nullable.hpp" #include "azure/perf/argagg.hpp" #include "azure/perf/dynamic_test_options.hpp" @@ -19,6 +17,7 @@ #include #include +#include #include namespace Azure { namespace Perf { diff --git a/sdk/core/perf/src/program.cpp b/sdk/core/perf/src/program.cpp index c788388c72..8c0c1ce2ff 100644 --- a/sdk/core/perf/src/program.cpp +++ b/sdk/core/perf/src/program.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/perf/program.hpp" + #include "azure/perf/argagg.hpp" #include diff --git a/sdk/core/perf/src/random_stream.cpp b/sdk/core/perf/src/random_stream.cpp index a32e3ec58a..93f05f1651 100644 --- a/sdk/core/perf/src/random_stream.cpp +++ b/sdk/core/perf/src/random_stream.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/perf/random_stream.hpp" +#include + #if defined(AZ_PLATFORM_WINDOWS) #if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN diff --git a/sdk/core/perf/test/inc/azure/perf/test/http_client_get_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/http_client_get_test.hpp index 7e206e8de9..f65dc7e3de 100644 --- a/sdk/core/perf/test/inc/azure/perf/test/http_client_get_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/http_client_get_test.hpp @@ -9,11 +9,10 @@ #pragma once -#include - #include #include #include +#include #include #include diff --git a/sdk/core/perf/test/inc/azure/perf/test/http_pipeline_get_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/http_pipeline_get_test.hpp index 6fe16f62b0..c89d9e7b7d 100644 --- a/sdk/core/perf/test/inc/azure/perf/test/http_pipeline_get_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/http_pipeline_get_test.hpp @@ -9,12 +9,11 @@ #pragma once -#include - #include #include #include #include +#include #include #include diff --git a/sdk/core/perf/test/src/perf_test.cpp b/sdk/core/perf/test/src/perf_test.cpp index bbe9cd2d46..f91bec8db1 100644 --- a/sdk/core/perf/test/src/perf_test.cpp +++ b/sdk/core/perf/test/src/perf_test.cpp @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/perf/test/delay_test.hpp" #include "azure/perf/test/extended_options_test.hpp" #include "azure/perf/test/http_pipeline_get_test.hpp" + +#include #if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) #include "azure/perf/test/curl_http_client_get_test.hpp" #endif diff --git a/sdk/core/perf/test/src/random_stream_test.cpp b/sdk/core/perf/test/src/random_stream_test.cpp index ea495f36dd..863aa6cd72 100644 --- a/sdk/core/perf/test/src/random_stream_test.cpp +++ b/sdk/core/perf/test/src/random_stream_test.cpp @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include + #include +#include + TEST(circular_stream, basic) { size_t const totalSize = 1024 * 1024 * 3; // should give 5 loops diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/eventhubs.cpp b/sdk/eventhubs/azure-messaging-eventhubs/src/eventhubs.cpp index 3996624565..acc9ac3a26 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/eventhubs.cpp +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/eventhubs.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: MIT #include "azure/messaging/eventhubs.hpp" + #include "private/package_version.hpp" + #include #include diff --git a/sdk/identity/azure-identity/img/mermaidjs/DefaultAzureCredentialAuthFlow.md b/sdk/identity/azure-identity/img/mermaidjs/DefaultAzureCredentialAuthFlow.md new file mode 100644 index 0000000000..26b5d98e00 --- /dev/null +++ b/sdk/identity/azure-identity/img/mermaidjs/DefaultAzureCredentialAuthFlow.md @@ -0,0 +1,19 @@ +```mermaid +%% STEPS TO GENERATE IMAGE +%% ======================= +%% 1. Install mermaid CLI (see https://github.com/mermaid-js/mermaid-cli/blob/master/README.md) +%% v10.0.2 is known good for our process. npm install -g @mermaid-js/mermaid-cli@10.0.2 +%% 2. Run command: mmdc -i DefaultAzureCredentialAuthFlow.md -o DefaultAzureCredentialAuthFlow.svg + +flowchart LR; + A(Environment):::deployed ==> B(Azure CLI):::developer ==> C(Managed Identity):::deployed; + + subgraph CREDENTIAL TYPES; + direction LR; + Deployed(Deployed service):::deployed ~~~ Developer(Developer):::developer; + end; + + %% Define styles for credential type boxes + classDef deployed fill:#95C37E, stroke:#71AD4C; + classDef developer fill:#F5AF6F, stroke:#EB7C39; +``` diff --git a/sdk/identity/azure-identity/img/mermaidjs/DefaultAzureCredentialAuthFlow.svg b/sdk/identity/azure-identity/img/mermaidjs/DefaultAzureCredentialAuthFlow.svg new file mode 100644 index 0000000000..2529692979 --- /dev/null +++ b/sdk/identity/azure-identity/img/mermaidjs/DefaultAzureCredentialAuthFlow.svg @@ -0,0 +1 @@ +
CREDENTIAL TYPES
Developer
Deployed service
Environment
Azure CLI
Managed Identity
\ No newline at end of file diff --git a/sdk/identity/azure-identity/inc/azure/identity/azure_cli_credential.hpp b/sdk/identity/azure-identity/inc/azure/identity/azure_cli_credential.hpp index 0de97ff2f0..a47fd828be 100644 --- a/sdk/identity/azure-identity/inc/azure/identity/azure_cli_credential.hpp +++ b/sdk/identity/azure-identity/inc/azure/identity/azure_cli_credential.hpp @@ -12,7 +12,6 @@ #include #include - #include #include diff --git a/sdk/identity/azure-identity/samples/azure_cli_credential.cpp b/sdk/identity/azure-identity/samples/azure_cli_credential.cpp index 93c84f0c21..ff70a5e679 100644 --- a/sdk/identity/azure-identity/samples/azure_cli_credential.cpp +++ b/sdk/identity/azure-identity/samples/azure_cli_credential.cpp @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include - #include +#include + int main() { try diff --git a/sdk/identity/azure-identity/samples/chained_token_credential.cpp b/sdk/identity/azure-identity/samples/chained_token_credential.cpp index 758892d1ea..dbfdc108d2 100644 --- a/sdk/identity/azure-identity/samples/chained_token_credential.cpp +++ b/sdk/identity/azure-identity/samples/chained_token_credential.cpp @@ -1,16 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - -#include - #include +#include #include #include - #include +#include + int main() { try diff --git a/sdk/identity/azure-identity/samples/client_certificate_credential.cpp b/sdk/identity/azure-identity/samples/client_certificate_credential.cpp index 2cca8a0780..92034ddebb 100644 --- a/sdk/identity/azure-identity/samples/client_certificate_credential.cpp +++ b/sdk/identity/azure-identity/samples/client_certificate_credential.cpp @@ -3,12 +3,11 @@ #include -#include - #include - #include +#include + // 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. diff --git a/sdk/identity/azure-identity/samples/client_secret_credential.cpp b/sdk/identity/azure-identity/samples/client_secret_credential.cpp index 3f92f1630c..9ca9795348 100644 --- a/sdk/identity/azure-identity/samples/client_secret_credential.cpp +++ b/sdk/identity/azure-identity/samples/client_secret_credential.cpp @@ -3,12 +3,11 @@ #include -#include - #include - #include +#include + // 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. diff --git a/sdk/identity/azure-identity/samples/default_azure_credential.cpp b/sdk/identity/azure-identity/samples/default_azure_credential.cpp index da2f590905..475397f60f 100644 --- a/sdk/identity/azure-identity/samples/default_azure_credential.cpp +++ b/sdk/identity/azure-identity/samples/default_azure_credential.cpp @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include - #include +#include + int main() { try diff --git a/sdk/identity/azure-identity/samples/environment_credential.cpp b/sdk/identity/azure-identity/samples/environment_credential.cpp index d41e89c390..c94d498fcf 100644 --- a/sdk/identity/azure-identity/samples/environment_credential.cpp +++ b/sdk/identity/azure-identity/samples/environment_credential.cpp @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include - #include +#include + int main() { try diff --git a/sdk/identity/azure-identity/samples/managed_identity_credential.cpp b/sdk/identity/azure-identity/samples/managed_identity_credential.cpp index b83336bc79..54e4a2cc06 100644 --- a/sdk/identity/azure-identity/samples/managed_identity_credential.cpp +++ b/sdk/identity/azure-identity/samples/managed_identity_credential.cpp @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include - #include +#include + int main() { try diff --git a/sdk/identity/azure-identity/src/azure_cli_credential.cpp b/sdk/identity/azure-identity/src/azure_cli_credential.cpp index d4fc308ac3..775594b226 100644 --- a/sdk/identity/azure-identity/src/azure_cli_credential.cpp +++ b/sdk/identity/azure-identity/src/azure_cli_credential.cpp @@ -32,8 +32,9 @@ #include #include #include -#include #include + +#include #endif using Azure::Identity::AzureCliCredential; diff --git a/sdk/identity/azure-identity/src/chained_token_credential.cpp b/sdk/identity/azure-identity/src/chained_token_credential.cpp index c7b441bac3..3a53bf450d 100644 --- a/sdk/identity/azure-identity/src/chained_token_credential.cpp +++ b/sdk/identity/azure-identity/src/chained_token_credential.cpp @@ -3,11 +3,10 @@ #include "azure/identity/chained_token_credential.hpp" +#include "azure/core/internal/diagnostics/log.hpp" #include "private/chained_token_credential_impl.hpp" #include "private/identity_log.hpp" -#include "azure/core/internal/diagnostics/log.hpp" - #include using namespace Azure::Identity; diff --git a/sdk/identity/azure-identity/src/default_azure_credential.cpp b/sdk/identity/azure-identity/src/default_azure_credential.cpp index 79bebb9970..8c1c7825f5 100644 --- a/sdk/identity/azure-identity/src/default_azure_credential.cpp +++ b/sdk/identity/azure-identity/src/default_azure_credential.cpp @@ -6,7 +6,6 @@ #include "azure/identity/azure_cli_credential.hpp" #include "azure/identity/environment_credential.hpp" #include "azure/identity/managed_identity_credential.hpp" - #include "private/chained_token_credential_impl.hpp" #include "private/identity_log.hpp" diff --git a/sdk/identity/azure-identity/src/environment_credential.cpp b/sdk/identity/azure-identity/src/environment_credential.cpp index 5c1fbcf499..30ad944796 100644 --- a/sdk/identity/azure-identity/src/environment_credential.cpp +++ b/sdk/identity/azure-identity/src/environment_credential.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: MIT #include "azure/identity/environment_credential.hpp" + #include "azure/identity/client_certificate_credential.hpp" #include "azure/identity/client_secret_credential.hpp" - #include "private/identity_log.hpp" #include diff --git a/sdk/identity/azure-identity/src/managed_identity_credential.cpp b/sdk/identity/azure-identity/src/managed_identity_credential.cpp index 7b64abcaf1..de6666621c 100644 --- a/sdk/identity/azure-identity/src/managed_identity_credential.cpp +++ b/sdk/identity/azure-identity/src/managed_identity_credential.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/identity/managed_identity_credential.hpp" + #include "private/managed_identity_source.hpp" using namespace Azure::Identity; diff --git a/sdk/identity/azure-identity/src/private/managed_identity_source.hpp b/sdk/identity/azure-identity/src/private/managed_identity_source.hpp index 146da297bf..a4f7d9d181 100644 --- a/sdk/identity/azure-identity/src/private/managed_identity_source.hpp +++ b/sdk/identity/azure-identity/src/private/managed_identity_source.hpp @@ -4,13 +4,12 @@ #pragma once #include "azure/identity/detail/token_cache.hpp" +#include "token_credential_impl.hpp" #include #include #include -#include "token_credential_impl.hpp" - #include #include #include diff --git a/sdk/identity/azure-identity/src/token_credential_impl.cpp b/sdk/identity/azure-identity/src/token_credential_impl.cpp index 114d16f811..9a496dab47 100644 --- a/sdk/identity/azure-identity/src/token_credential_impl.cpp +++ b/sdk/identity/azure-identity/src/token_credential_impl.cpp @@ -3,11 +3,11 @@ #include "private/token_credential_impl.hpp" +#include "private/package_version.hpp" + #include #include -#include "private/package_version.hpp" - #include #include diff --git a/sdk/identity/azure-identity/test/e2e/azure_identity_e2e_test.cpp b/sdk/identity/azure-identity/test/e2e/azure_identity_e2e_test.cpp index 329348a3ab..cbc2df0400 100644 --- a/sdk/identity/azure-identity/test/e2e/azure_identity_e2e_test.cpp +++ b/sdk/identity/azure-identity/test/e2e/azure_identity_e2e_test.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include +#include #include #include diff --git a/sdk/identity/azure-identity/test/perf/inc/azure/identity/test/secret_credential_test.hpp b/sdk/identity/azure-identity/test/perf/inc/azure/identity/test/secret_credential_test.hpp index c7861c5e48..04c772d734 100644 --- a/sdk/identity/azure-identity/test/perf/inc/azure/identity/test/secret_credential_test.hpp +++ b/sdk/identity/azure-identity/test/perf/inc/azure/identity/test/secret_credential_test.hpp @@ -9,9 +9,8 @@ #pragma once -#include - #include +#include #include #include diff --git a/sdk/identity/azure-identity/test/perf/src/azure_identity_perf_test.cpp b/sdk/identity/azure-identity/test/perf/src/azure_identity_perf_test.cpp index 2844cee015..a15ad18374 100644 --- a/sdk/identity/azure-identity/test/perf/src/azure_identity_perf_test.cpp +++ b/sdk/identity/azure-identity/test/perf/src/azure_identity_perf_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/identity/test/secret_credential_test.hpp" +#include + int main(int argc, char** argv) { diff --git a/sdk/identity/azure-identity/test/ut/client_certificate_credential_test.cpp b/sdk/identity/azure-identity/test/ut/client_certificate_credential_test.cpp index f67963ab35..c34957dfc2 100644 --- a/sdk/identity/azure-identity/test/ut/client_certificate_credential_test.cpp +++ b/sdk/identity/azure-identity/test/ut/client_certificate_credential_test.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: MIT #include "azure/identity/client_certificate_credential.hpp" - #include "credential_test_helper.hpp" #include diff --git a/sdk/identity/azure-identity/test/ut/client_secret_credential_test.cpp b/sdk/identity/azure-identity/test/ut/client_secret_credential_test.cpp index 81d354bf1f..6943cc3a40 100644 --- a/sdk/identity/azure-identity/test/ut/client_secret_credential_test.cpp +++ b/sdk/identity/azure-identity/test/ut/client_secret_credential_test.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: MIT #include "azure/identity/client_secret_credential.hpp" - #include "credential_test_helper.hpp" #include diff --git a/sdk/identity/azure-identity/test/ut/default_azure_credential_test.cpp b/sdk/identity/azure-identity/test/ut/default_azure_credential_test.cpp index 7ab26d4b50..1790f0a3d6 100644 --- a/sdk/identity/azure-identity/test/ut/default_azure_credential_test.cpp +++ b/sdk/identity/azure-identity/test/ut/default_azure_credential_test.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MIT #include "azure/identity/default_azure_credential.hpp" - #include "credential_test_helper.hpp" + #include #include diff --git a/sdk/identity/azure-identity/test/ut/environment_credential_test.cpp b/sdk/identity/azure-identity/test/ut/environment_credential_test.cpp index 71f4b6c063..1e984aa270 100644 --- a/sdk/identity/azure-identity/test/ut/environment_credential_test.cpp +++ b/sdk/identity/azure-identity/test/ut/environment_credential_test.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MIT #include "azure/identity/environment_credential.hpp" - #include "credential_test_helper.hpp" + #include #include diff --git a/sdk/identity/azure-identity/test/ut/managed_identity_credential_test.cpp b/sdk/identity/azure-identity/test/ut/managed_identity_credential_test.cpp index 31deb38bbf..569354fc2a 100644 --- a/sdk/identity/azure-identity/test/ut/managed_identity_credential_test.cpp +++ b/sdk/identity/azure-identity/test/ut/managed_identity_credential_test.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MIT #include "azure/identity/managed_identity_credential.hpp" - #include "credential_test_helper.hpp" + #include #include diff --git a/sdk/identity/azure-identity/test/ut/tenant_id_resolver_test.cpp b/sdk/identity/azure-identity/test/ut/tenant_id_resolver_test.cpp index ab0f839b5f..16acc704dd 100644 --- a/sdk/identity/azure-identity/test/ut/tenant_id_resolver_test.cpp +++ b/sdk/identity/azure-identity/test/ut/tenant_id_resolver_test.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "private/tenant_id_resolver.hpp" - #include "credential_test_helper.hpp" +#include "private/tenant_id_resolver.hpp" #include diff --git a/sdk/identity/azure-identity/test/ut/token_cache_test.cpp b/sdk/identity/azure-identity/test/ut/token_cache_test.cpp index 4731db56c9..114a22460b 100644 --- a/sdk/identity/azure-identity/test/ut/token_cache_test.cpp +++ b/sdk/identity/azure-identity/test/ut/token_cache_test.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "azure/identity/detail/token_cache.hpp" - #include "azure/identity/client_secret_credential.hpp" +#include "azure/identity/detail/token_cache.hpp" #include diff --git a/sdk/identity/azure-identity/test/ut/token_credential_impl_test.cpp b/sdk/identity/azure-identity/test/ut/token_credential_impl_test.cpp index 567bba73aa..d8c210bda3 100644 --- a/sdk/identity/azure-identity/test/ut/token_credential_impl_test.cpp +++ b/sdk/identity/azure-identity/test/ut/token_credential_impl_test.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "private/token_credential_impl.hpp" - #include "credential_test_helper.hpp" +#include "private/token_credential_impl.hpp" #include #include diff --git a/sdk/identity/azure-identity/test/ut/token_credential_test.cpp b/sdk/identity/azure-identity/test/ut/token_credential_test.cpp index bfe57d7c02..b3bdb7e6b6 100644 --- a/sdk/identity/azure-identity/test/ut/token_credential_test.cpp +++ b/sdk/identity/azure-identity/test/ut/token_credential_test.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include #include #include @@ -10,6 +8,8 @@ #include #include +#include + namespace Azure { namespace Identity { namespace Test { class TokenCredentialTest : public Azure::Core::Test::TestBase { diff --git a/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/rest_client_models.hpp b/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/rest_client_models.hpp index 09104b7ea6..19d8017a48 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/rest_client_models.hpp +++ b/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/rest_client_models.hpp @@ -13,6 +13,7 @@ #include #include #include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/settings_client.hpp b/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/settings_client.hpp index 1968c28ed4..a10864681f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/settings_client.hpp +++ b/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/settings_client.hpp @@ -14,6 +14,7 @@ #include #include #include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/settings_client_options.hpp b/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/settings_client_options.hpp index fef1f468c5..3cd10aed3d 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/settings_client_options.hpp +++ b/sdk/keyvault/azure-security-keyvault-administration/inc/azure/keyvault/administration/settings_client_options.hpp @@ -10,8 +10,8 @@ #pragma once #include - #include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/keyvault_settings_common_request.cpp b/sdk/keyvault/azure-security-keyvault-administration/src/keyvault_settings_common_request.cpp index 41b161fd29..3632dda55d 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/keyvault_settings_common_request.cpp +++ b/sdk/keyvault/azure-security-keyvault-administration/src/keyvault_settings_common_request.cpp @@ -2,10 +2,12 @@ // SPDX-License-Identifier: MIT #include "private/keyvault_settings_common_request.hpp" + #include "private/administration_constants.hpp" #include #include + #include using namespace Azure::Security::KeyVault; diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/settings_client.cpp b/sdk/keyvault/azure-security-keyvault-administration/src/settings_client.cpp index 195876bd71..4d661d4b66 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/settings_client.cpp +++ b/sdk/keyvault/azure-security-keyvault-administration/src/settings_client.cpp @@ -4,6 +4,7 @@ #include "private/administration_constants.hpp" #include "private/keyvault_settings_common_request.hpp" #include "private/package_version.hpp" + #include #include #include @@ -12,6 +13,7 @@ #include #include #include + #include using namespace Azure::Core::Http; diff --git a/sdk/keyvault/azure-security-keyvault-administration/test/ut/settings_client_base_test.hpp b/sdk/keyvault/azure-security-keyvault-administration/test/ut/settings_client_base_test.hpp index 5dd4d4ed13..3a9f7f7dfc 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/test/ut/settings_client_base_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-administration/test/ut/settings_client_base_test.hpp @@ -7,14 +7,15 @@ * */ -#include - #include #include #include + #include #include +#include + namespace Azure { namespace Security { namespace KeyVault { diff --git a/sdk/keyvault/azure-security-keyvault-administration/test/ut/settings_client_test.cpp b/sdk/keyvault/azure-security-keyvault-administration/test/ut/settings_client_test.cpp index 4462635b1d..1e75f8d48b 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/test/ut/settings_client_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-administration/test/ut/settings_client_test.cpp @@ -1,17 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/keyvault/administration/settings_client.hpp" #include "settings_client_base_test.hpp" + #include +#include #include + #include -#include #include #include +#include + using namespace Azure::Security::KeyVault::Administration; using namespace Azure::Security::KeyVault::Administration::Models; using namespace Azure::Security::KeyVault::Administration::Test; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates.hpp b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates.hpp index 0ad17566ea..137a2cd34f 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates.hpp @@ -8,11 +8,9 @@ #pragma once -#include "azure/keyvault/certificates/dll_import_export.hpp" - #include "azure/keyvault/certificates/certificate_client.hpp" #include "azure/keyvault/certificates/certificate_client_models.hpp" #include "azure/keyvault/certificates/certificate_client_operations.hpp" #include "azure/keyvault/certificates/certificate_client_options.hpp" - +#include "azure/keyvault/certificates/dll_import_export.hpp" #include "azure/keyvault/certificates/rtti.hpp" diff --git a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client.hpp b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client.hpp index 3999b8ab1c..f54f9125ad 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client.hpp @@ -12,6 +12,7 @@ #include "azure/keyvault/certificates/certificate_client_models.hpp" #include "azure/keyvault/certificates/certificate_client_operations.hpp" #include "azure/keyvault/certificates/certificate_client_options.hpp" + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_models.hpp b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_models.hpp index 7c43324bb2..4a79c66012 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_models.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_models.hpp @@ -16,6 +16,7 @@ #include #include #include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_options.hpp b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_options.hpp index 6d5fcc69fd..60b906e2ff 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_options.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_options.hpp @@ -9,10 +9,11 @@ #pragma once -#include - #include "azure/keyvault/certificates/certificate_client_models.hpp" #include "azure/keyvault/certificates/dll_import_export.hpp" + +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client.cpp b/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client.cpp index 58ad90b024..66aa3af43c 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client.cpp @@ -9,8 +9,8 @@ #include "private/certificate_serializers.hpp" #include "private/keyvault_certificates_common_request.hpp" #include "private/package_version.hpp" -#include +#include #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client_operations.cpp b/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client_operations.cpp index 0d6d72971b..8697668d7b 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client_operations.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client_operations.cpp @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include "azure/keyvault/certificates/certificate_client_operations.hpp" + #include "azure/keyvault/certificates/certificate_client.hpp" #include "azure/keyvault/certificates/certificate_client_models.hpp" #include "private/certificate_constants.hpp" #include "private/certificate_serializers.hpp" + #include using namespace Azure::Security::KeyVault::Certificates; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_serializers.cpp b/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_serializers.cpp index 83fc81e982..877d261609 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_serializers.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_serializers.cpp @@ -1,17 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "private/certificate_serializers.hpp" + +#include "azure/keyvault/certificates/certificate_client_models.hpp" +#include "private/certificate_constants.hpp" +#include "private/certificate_key_usage.hpp" + #include #include #include #include #include -#include "azure/keyvault/certificates/certificate_client_models.hpp" -#include "private/certificate_constants.hpp" -#include "private/certificate_key_usage.hpp" -#include "private/certificate_serializers.hpp" - using namespace Azure::Security::KeyVault::Certificates::_detail; using namespace Azure::Security::KeyVault::Certificates; using namespace Azure::Core::Json::_internal; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/keyvault_certificates_common_request.cpp b/sdk/keyvault/azure-security-keyvault-certificates/src/keyvault_certificates_common_request.cpp index 840173cd9f..b2075a9734 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/keyvault_certificates_common_request.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/keyvault_certificates_common_request.cpp @@ -2,10 +2,12 @@ // SPDX-License-Identifier: MIT #include "private/keyvault_certificates_common_request.hpp" + #include "private/certificate_constants.hpp" #include #include + #include using namespace Azure::Security::KeyVault; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/private/certificate_serializers.hpp b/sdk/keyvault/azure-security-keyvault-certificates/src/private/certificate_serializers.hpp index 414c2d6ea5..bdb20fa1e2 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/private/certificate_serializers.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/private/certificate_serializers.hpp @@ -11,6 +11,7 @@ #include "azure/keyvault/certificates/certificate_client_models.hpp" #include "azure/keyvault/certificates/certificate_client_options.hpp" + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-certificates/test/perf/inc/azure/keyvault/certificates/test/get_certificate_test.hpp b/sdk/keyvault/azure-security-keyvault-certificates/test/perf/inc/azure/keyvault/certificates/test/get_certificate_test.hpp index fc48c3dae7..ddff618057 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/test/perf/inc/azure/keyvault/certificates/test/get_certificate_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/test/perf/inc/azure/keyvault/certificates/test/get_certificate_test.hpp @@ -9,11 +9,11 @@ #pragma once -#include - #include #include #include +#include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-certificates/test/perf/src/azure_security_keyvault_certificates_perf_test.cpp b/sdk/keyvault/azure-security-keyvault-certificates/test/perf/src/azure_security_keyvault_certificates_perf_test.cpp index e0c2e4486d..d1bdfd92fd 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/test/perf/src/azure_security_keyvault_certificates_perf_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/test/perf/src/azure_security_keyvault_certificates_perf_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/keyvault/certificates/test/get_certificate_test.hpp" +#include + int main(int argc, char** argv) { diff --git a/sdk/keyvault/azure-security-keyvault-certificates/test/samples/certificate-import-certificate/certificate_import_certificate.cpp b/sdk/keyvault/azure-security-keyvault-certificates/test/samples/certificate-import-certificate/certificate_import_certificate.cpp index 79a8576ebd..3e7102663c 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/test/samples/certificate-import-certificate/certificate_import_certificate.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/test/samples/certificate-import-certificate/certificate_import_certificate.cpp @@ -18,6 +18,7 @@ #include #include #include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_base_test.hpp b/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_base_test.hpp index f5073271ce..64022b91e4 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_base_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_base_test.hpp @@ -7,15 +7,17 @@ * */ -#include - #include "../src/private/certificate_serializers.hpp" + #include #include #include + #include #include +#include + namespace Azure { namespace Security { namespace KeyVault { diff --git a/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp b/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp index bb6295d1ea..b2d9744192 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/test/ut/certificate_client_test.cpp @@ -1,15 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "certificate_client_base_test.hpp" + #include +#include + #include -#include #include #include +#include + using namespace std::chrono_literals; using namespace Azure::Security::KeyVault::Certificates; using namespace Azure::Security::KeyVault::Certificates::Test; diff --git a/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/cryptography/cryptography_client_models.hpp b/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/cryptography/cryptography_client_models.hpp index 7e05eb33c5..0573a6daf2 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/cryptography/cryptography_client_models.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/cryptography/cryptography_client_models.hpp @@ -9,10 +9,10 @@ #pragma once -#include - #include "azure/keyvault/keys/dll_import_export.hpp" +#include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/cryptography/cryptography_client_options.hpp b/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/cryptography/cryptography_client_options.hpp index 5adfc81cee..058fc813f2 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/cryptography/cryptography_client_options.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/cryptography/cryptography_client_options.hpp @@ -10,10 +10,10 @@ #pragma once -#include - #include "azure/keyvault/keys/dll_import_export.hpp" +#include + namespace Azure { namespace Security { namespace KeyVault { diff --git a/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/key_client_options.hpp b/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/key_client_options.hpp index 8912beddcd..ed837ad6f4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/key_client_options.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/key_client_options.hpp @@ -9,11 +9,11 @@ #pragma once -#include - #include "azure/keyvault/keys/dll_import_export.hpp" #include "azure/keyvault/keys/key_client_models.hpp" +#include + namespace Azure { namespace Security { namespace KeyVault { namespace Keys { /** diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/cryptography_client.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/cryptography_client.cpp index 1df12afca1..497aec3d80 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/cryptography_client.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/cryptography_client.cpp @@ -1,16 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include -#include -#include - -#include -#include - #include "azure/keyvault/keys/cryptography/cryptography_client.hpp" -#include "azure/keyvault/keys/key_client_models.hpp" #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" @@ -20,6 +11,14 @@ #include "../private/key_wrap_parameters.hpp" #include "../private/keyvault_protocol.hpp" #include "../private/package_version.hpp" +#include "azure/keyvault/keys/key_client_models.hpp" + +#include +#include +#include +#include +#include +#include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/decrypt_parameters.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/decrypt_parameters.cpp index 8e986cf961..dd7d73c8c3 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/decrypt_parameters.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/decrypt_parameters.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/decrypt_result.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/decrypt_result.cpp index bbec38e0ce..b24f73624e 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/decrypt_result.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/decrypt_result.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/encrypt_parameters.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/encrypt_parameters.cpp index 2efc8c29fc..64a33bfdc5 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/encrypt_parameters.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/encrypt_parameters.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/encrypt_result.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/encrypt_result.cpp index 601136bc36..21b9f12c4b 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/encrypt_result.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/encrypt_result.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_sign_parameters.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_sign_parameters.cpp index 6e35811695..9c399ae6e4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_sign_parameters.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_sign_parameters.cpp @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include +#include "../private/key_sign_parameters.hpp" #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" -#include "../private/key_sign_parameters.hpp" + +#include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_verify_parameters.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_verify_parameters.cpp index 2b55efc336..5b4f40c6d2 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_verify_parameters.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_verify_parameters.cpp @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include +#include "../private/key_verify_parameters.hpp" #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" -#include "../private/key_verify_parameters.hpp" + +#include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_wrap_parameters.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_wrap_parameters.cpp index aa7e444cf8..56200b1823 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_wrap_parameters.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/key_wrap_parameters.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/sign_result.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/sign_result.cpp index 5b8ae22811..b3850ab549 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/sign_result.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/sign_result.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/signature_algorithm.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/signature_algorithm.cpp index 498adc107b..27fb365d15 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/signature_algorithm.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/signature_algorithm.cpp @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include + namespace Azure { namespace Security { namespace KeyVault { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/unwrap_result.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/unwrap_result.cpp index d99136d698..0cf931517a 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/unwrap_result.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/unwrap_result.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/verify_result.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/verify_result.cpp index 225a898ff0..bcef5240b6 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/verify_result.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/verify_result.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/wrap_result.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/wrap_result.cpp index e68293d87f..35815e8e37 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/wrap_result.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/cryptography/wrap_result.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "../private/cryptography_serializers.hpp" #include "../private/key_constants.hpp" #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" +#include +#include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/delete_key_operation.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/delete_key_operation.cpp index eebce6b742..9d698012af 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/delete_key_operation.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/delete_key_operation.cpp @@ -1,15 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - -#include - #include "azure/keyvault/keys/key_client.hpp" #include "azure/keyvault/keys/key_client_models.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" +#include + using namespace Azure::Security::KeyVault::Keys; using namespace Azure::Security::KeyVault; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/deleted_key.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/deleted_key.cpp index faa5206acb..8a78dacdcb 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/deleted_key.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/deleted_key.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "azure/keyvault/keys/key_client_models.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" +#include +#include + using namespace Azure::Security::KeyVault::Keys; using namespace Azure::Core::Json::_internal; using Azure::Core::_internal::PosixTimeConverter; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/import_key_options.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/import_key_options.cpp index 013e65fab8..83e76e0a41 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/import_key_options.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/import_key_options.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "azure/keyvault/keys/key_client_options.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" +#include +#include + #include using namespace Azure::Security::KeyVault::Keys; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/json_web_key.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/json_web_key.cpp index df5a6368ad..df68760bfa 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/json_web_key.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/json_web_key.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "azure/keyvault/keys/key_client_models.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" +#include +#include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/key_backup.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/key_backup.cpp index 76d1fe9164..fda44978ce 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/key_backup.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/key_backup.cpp @@ -1,13 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "private/key_backup.hpp" + +#include "private/key_constants.hpp" + #include #include #include -#include "private/key_backup.hpp" -#include "private/key_constants.hpp" - #include using namespace Azure::Security::KeyVault::Keys::_detail; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/key_client.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/key_client.cpp index 0dae980d10..685bc4b3f7 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/key_client.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/key_client.cpp @@ -1,14 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include -#include -#include -#include -#include - #include "azure/keyvault/keys/key_client.hpp" + #include "private/cryptography_internal_access.hpp" #include "private/key_backup.hpp" #include "private/key_constants.hpp" @@ -17,6 +11,13 @@ #include "private/keyvault_protocol.hpp" #include "private/package_version.hpp" +#include +#include +#include +#include +#include +#include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/key_get_random_bytes.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/key_get_random_bytes.cpp index 7e5c9746ff..d194a91361 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/key_get_random_bytes.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/key_get_random_bytes.cpp @@ -4,6 +4,7 @@ #include "azure/keyvault/keys/key_client_models.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/key_release_options.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/key_release_options.cpp index 8363a05b6b..3a0436b3d8 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/key_release_options.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/key_release_options.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "azure/keyvault/keys/key_client_options.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" +#include +#include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/key_release_policy.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/key_release_policy.cpp index 1ac616f01e..a87b291da4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/key_release_policy.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/key_release_policy.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "azure/keyvault/keys/key_client_options.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" +#include +#include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/key_request_parameters.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/key_request_parameters.cpp index df8f8d15ea..8bb446f1e3 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/key_request_parameters.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/key_request_parameters.cpp @@ -1,13 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include +#include "private/key_request_parameters.hpp" #include "private/key_constants.hpp" -#include "private/key_request_parameters.hpp" #include "private/key_serializers.hpp" +#include +#include + #include using namespace Azure::Security::KeyVault::Keys::_detail; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/key_rotation_policy.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/key_rotation_policy.cpp index dbeae29ba1..adc1626f62 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/key_rotation_policy.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/key_rotation_policy.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include - #include "azure/keyvault/keys/key_client_models.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" +#include +#include + using namespace Azure::Security::KeyVault::Keys; using namespace Azure::Core::Json::_internal; using Azure::Core::_internal::PosixTimeConverter; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/keyvault_key.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/keyvault_key.cpp index e14f5c92b2..2150180275 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/keyvault_key.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/keyvault_key.cpp @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "azure/keyvault/keys/key_client_models.hpp" +#include "private/key_constants.hpp" +#include "private/key_serializers.hpp" + #include #include #include #include -#include "azure/keyvault/keys/key_client_models.hpp" -#include "private/key_constants.hpp" -#include "private/key_serializers.hpp" - using namespace Azure::Security::KeyVault::Keys; using namespace Azure::Core::Json::_internal; using Azure::Core::_internal::PosixTimeConverter; diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/keyvault_protocol.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/keyvault_protocol.cpp index 9e0c4ca069..6dbc3b5ba4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/keyvault_protocol.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/keyvault_protocol.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "private/keyvault_protocol.hpp" + #include "private/key_constants.hpp" #include "private/keyvault_constants.hpp" diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/private/cryptography_internal_access.hpp b/sdk/keyvault/azure-security-keyvault-keys/src/private/cryptography_internal_access.hpp index c7a5cad091..070c2d933b 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/private/cryptography_internal_access.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/private/cryptography_internal_access.hpp @@ -9,10 +9,10 @@ #pragma once -#include - #include "azure/keyvault/keys/cryptography/cryptography_client.hpp" +#include + #include namespace Azure { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/private/cryptography_serializers.hpp b/sdk/keyvault/azure-security-keyvault-keys/src/private/cryptography_serializers.hpp index fd05ad27a6..da5f7605d5 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/private/cryptography_serializers.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/private/cryptography_serializers.hpp @@ -10,15 +10,14 @@ #pragma once -#include -#include - #include "azure/keyvault/keys/cryptography/cryptography_client_models.hpp" - #include "key_sign_parameters.hpp" #include "key_verify_parameters.hpp" #include "key_wrap_parameters.hpp" +#include +#include + #include namespace Azure { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/private/key_request_parameters.hpp b/sdk/keyvault/azure-security-keyvault-keys/src/private/key_request_parameters.hpp index e23536243d..3a9d8e1653 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/private/key_request_parameters.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/private/key_request_parameters.hpp @@ -9,12 +9,12 @@ #pragma once -#include -#include - #include "azure/keyvault/keys/key_client_models.hpp" #include "azure/keyvault/keys/key_client_options.hpp" +#include +#include + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/private/key_serializers.hpp b/sdk/keyvault/azure-security-keyvault-keys/src/private/key_serializers.hpp index dc95902cd2..5662acbb22 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/private/key_serializers.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/private/key_serializers.hpp @@ -9,11 +9,11 @@ #pragma once -#include - #include "azure/keyvault/keys/key_client_models.hpp" #include "azure/keyvault/keys/key_client_options.hpp" +#include + #include namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace _detail { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/recover_deleted_key_operation.cpp b/sdk/keyvault/azure-security-keyvault-keys/src/recover_deleted_key_operation.cpp index f16d0ee959..c43df7c7aa 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/recover_deleted_key_operation.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/src/recover_deleted_key_operation.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/keyvault/keys/key_client.hpp" #include "azure/keyvault/keys/key_client_models.hpp" #include "private/key_constants.hpp" #include "private/key_serializers.hpp" +#include + using namespace Azure::Security::KeyVault::Keys; using namespace Azure::Security::KeyVault; diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/perf/inc/azure/keyvault/keys/test/get_key_test.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/perf/inc/azure/keyvault/keys/test/get_key_test.hpp index 339afc5291..956851418c 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/perf/inc/azure/keyvault/keys/test/get_key_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/perf/inc/azure/keyvault/keys/test/get_key_test.hpp @@ -9,11 +9,10 @@ #pragma once -#include - #include #include #include +#include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/perf/src/azure_security_keyvault_keys_perf_test.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/perf/src/azure_security_keyvault_keys_perf_test.cpp index e32fcb7bc3..c8e330a2d4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/perf/src/azure_security_keyvault_keys_perf_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/perf/src/azure_security_keyvault_keys_perf_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/keyvault/keys/test/get_key_test.hpp" +#include + int main(int argc, char** argv) { diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut-hsm/key_client_test_hsm_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut-hsm/key_client_test_hsm_live.cpp index b0a3a514c1..778a43bc62 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut-hsm/key_client_test_hsm_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut-hsm/key_client_test_hsm_live.cpp @@ -4,6 +4,7 @@ #include "key_client_test_hsm_live.hpp" #include "gtest/gtest.h" + #include using namespace Azure::Security::KeyVault::Keys; diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut-hsm/key_client_test_hsm_live.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut-hsm/key_client_test_hsm_live.hpp index 5c4d3dd2fc..99c7f31d4e 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut-hsm/key_client_test_hsm_live.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut-hsm/key_client_test_hsm_live.hpp @@ -6,11 +6,11 @@ * @brief The base class to construct and init a Key Vault HSM client. * */ -#include - #include #include +#include + namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace Test { class KeyVaultKeyHSMClient : public Azure::Core::Test::TestBase { diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp index d3536f79f3..40f6389593 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_backup_test_live.cpp @@ -2,18 +2,18 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" - #include "key_client_base_test.hpp" #include #include #include -#include #include #include #include +#include + using namespace Azure::Security::KeyVault::Keys::Test; using namespace Azure::Security::KeyVault::Keys; using namespace Azure::Core::Json::_internal; diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_base_test.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_base_test.hpp index a47a2756ec..df77d3ece1 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_base_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_base_test.hpp @@ -6,8 +6,6 @@ * @brief The base class to construct and init a Key Vault client. * */ -#include - #include #include #include @@ -20,6 +18,8 @@ #include #include +#include + namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace Test { class KeyVaultKeyClient : public Azure::Core::Test::TestBase { diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_create_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_create_test_live.cpp index 89d6150a42..d9cd4f184b 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_create_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_create_test_live.cpp @@ -1,20 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "gtest/gtest.h" #include "key_client_base_test.hpp" - #include "private/key_constants.hpp" #include "private/key_serializers.hpp" #include "test_consts.hpp" -#include "gtest/gtest.h" + #include #include #include #include #include -#include + #include +#include + using namespace Azure::Core::_internal; using namespace Azure::Security::KeyVault::Keys; using namespace Azure::Security::KeyVault::Keys::Test; diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_delete_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_delete_test_live.cpp index 752d323a29..0005380442 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_delete_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_delete_test_live.cpp @@ -2,14 +2,14 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" - #include "key_client_base_test.hpp" #include -#include #include +#include + namespace { std::string GetConflictErrorMsg(std::string const& keyName) diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_get_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_get_test_live.cpp index dacc326455..6fbf9ef24f 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_get_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_get_test_live.cpp @@ -2,14 +2,14 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" - #include "key_client_base_test.hpp" #include -#include #include +#include + using namespace Azure::Security::KeyVault::Keys::Test; using namespace Azure::Security::KeyVault::Keys; diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_import_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_import_test_live.cpp index 756336584b..0586f4f211 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_import_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_import_test_live.cpp @@ -2,14 +2,12 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" +#include "key_client_base_test.hpp" #include #include - #include -#include "key_client_base_test.hpp" - #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_test.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_test.cpp index 5b924c9f92..55c8bdf6a4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_test.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" - #include "private/key_constants.hpp" #include "private/key_serializers.hpp" + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_update_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_update_test_live.cpp index 691e5793a5..3bfde0a8b3 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_update_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_update_test_live.cpp @@ -2,15 +2,15 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" - #include "key_client_base_test.hpp" #include #include -#include #include +#include + using namespace Azure::Security::KeyVault::Keys::Test; using namespace Azure; using namespace Azure::Security::KeyVault::Keys; diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_cryptographic_client_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_cryptographic_client_test_live.cpp index 9d67decca3..8dc23a23b4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_cryptographic_client_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_cryptographic_client_test_live.cpp @@ -2,11 +2,9 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" - -#include - #include "key_client_base_test.hpp" +#include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_rotation_policy_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_rotation_policy_test_live.cpp index 104616fc03..49ac6e81b2 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_rotation_policy_test_live.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_rotation_policy_test_live.cpp @@ -2,16 +2,17 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" - #include "key_client_base_test.hpp" #include "private/key_serializers.hpp" + #include #include #include -#include #include +#include + using namespace Azure::Security::KeyVault::Keys::Test; using namespace Azure; using namespace Azure::Security::KeyVault::Keys; diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_client_test.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_client_test.cpp index 7587463624..013dadf936 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_client_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_client_test.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: MIT #include "gtest/gtest.h" - #include "mocked_transport_adapter_test.hpp" #include diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_transport_adapter_test.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_transport_adapter_test.hpp index cd6cf66dc1..1277fa97c9 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_transport_adapter_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_transport_adapter_test.hpp @@ -7,8 +7,6 @@ * */ -#include - #include "./../../src/private/key_serializers.hpp" #include "./../../src/private/keyvault_protocol.hpp" #include "./../../src/private/package_version.hpp" @@ -20,6 +18,8 @@ #include #include +#include + namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace Test { namespace _detail { diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/ut/test_consts.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/test_consts.hpp index 55c7014d34..edd18a429d 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/ut/test_consts.hpp +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/test_consts.hpp @@ -8,6 +8,7 @@ */ #include + #include // cspell:disable diff --git a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_operations.hpp b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_operations.hpp index 270b641a41..8f5c355947 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_operations.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_operations.hpp @@ -9,10 +9,12 @@ #pragma once #include "azure/keyvault/secrets/keyvault_deleted_secret.hpp" #include "azure/keyvault/secrets/keyvault_secret.hpp" + #include #include #include #include + #include namespace Azure { namespace Security { namespace KeyVault { namespace Secrets { diff --git a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_options.hpp b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_options.hpp index 6b3e26a575..30967dfbea 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_options.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_options.hpp @@ -7,6 +7,7 @@ */ #pragma once #include "dll_import_export.hpp" + #include namespace Azure { namespace Security { namespace KeyVault { namespace Secrets { diff --git a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_secret_paged_response.hpp b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_secret_paged_response.hpp index 69639755b9..c92950d2f1 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_secret_paged_response.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_secret_paged_response.hpp @@ -10,7 +10,9 @@ #include "azure/keyvault/secrets/keyvault_deleted_secret.hpp" #include "azure/keyvault/secrets/keyvault_secret_properties.hpp" + #include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_secret_properties.hpp b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_secret_properties.hpp index 0973d53e0d..1a08f60be7 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_secret_properties.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/keyvault_secret_properties.hpp @@ -11,6 +11,7 @@ #include #include #include + #include namespace Azure { namespace Security { namespace KeyVault { namespace Secrets { diff --git a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/secret_client.hpp b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/secret_client.hpp index 473a060d53..c5df7bcf34 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/secret_client.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/secret_client.hpp @@ -15,9 +15,11 @@ #include "azure/keyvault/secrets/keyvault_secret.hpp" #include "azure/keyvault/secrets/keyvault_secret_paged_response.hpp" #include "dll_import_export.hpp" + #include #include #include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_operations.cpp b/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_operations.cpp index df82aee251..5625f599e4 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_operations.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_operations.cpp @@ -7,6 +7,7 @@ */ #include "azure/keyvault/secrets/keyvault_operations.hpp" + #include "azure/keyvault/secrets/secret_client.hpp" #include "private/secret_serializers.hpp" diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_protocol.cpp b/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_protocol.cpp index 12cc6c4028..3aa02cb870 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_protocol.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_protocol.cpp @@ -2,7 +2,9 @@ // SPDX-License-Identifier: MIT #include "private/keyvault_protocol.hpp" + #include "private/secret_constants.hpp" + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_secret_paged_response.cpp b/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_secret_paged_response.cpp index ff2617ebe9..822e779eee 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_secret_paged_response.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_secret_paged_response.cpp @@ -7,6 +7,7 @@ */ #include "azure/keyvault/secrets/keyvault_secret_paged_response.hpp" + #include "azure/keyvault/secrets/secret_client.hpp" using namespace Azure::Security::KeyVault::Secrets; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_secrets_common_request.cpp b/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_secrets_common_request.cpp index ed350bfed4..d616ad7841 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_secrets_common_request.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/keyvault_secrets_common_request.cpp @@ -5,6 +5,7 @@ #include #include + #include using namespace Azure::Security::KeyVault::Secrets; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/private/secret_serializers.hpp b/sdk/keyvault/azure-security-keyvault-secrets/src/private/secret_serializers.hpp index 9b9424e507..f2da060607 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/private/secret_serializers.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/private/secret_serializers.hpp @@ -12,8 +12,10 @@ #include "azure/keyvault/secrets/keyvault_deleted_secret.hpp" #include "azure/keyvault/secrets/keyvault_secret.hpp" #include "azure/keyvault/secrets/keyvault_secret_paged_response.hpp" + #include #include + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/secret_client.cpp b/sdk/keyvault/azure-security-keyvault-secrets/src/secret_client.cpp index 24f485c9db..15c069a308 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/secret_client.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/secret_client.cpp @@ -7,6 +7,7 @@ */ #include "azure/keyvault/secrets/secret_client.hpp" + #include "azure/keyvault/secrets/keyvault_operations.hpp" #include "private/keyvault_protocol.hpp" #include "private/keyvault_secrets_common_request.hpp" diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/secret_serializers.cpp b/sdk/keyvault/azure-security-keyvault-secrets/src/secret_serializers.cpp index a3435af6d1..b103738f9d 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/secret_serializers.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/secret_serializers.cpp @@ -7,7 +7,9 @@ */ #include "private/secret_serializers.hpp" + #include "private/secret_constants.hpp" + #include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/perf/inc/azure/keyvault/secrets/test/get_secret_test.hpp b/sdk/keyvault/azure-security-keyvault-secrets/test/perf/inc/azure/keyvault/secrets/test/get_secret_test.hpp index d169193115..56a755fb2d 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/perf/inc/azure/keyvault/secrets/test/get_secret_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/perf/inc/azure/keyvault/secrets/test/get_secret_test.hpp @@ -9,11 +9,10 @@ #pragma once -#include - #include #include #include +#include #include #include diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/perf/src/azure_security_keyvault_secrets_perf_test.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/perf/src/azure_security_keyvault_secrets_perf_test.cpp index 75d4376cf3..4cb18d3446 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/perf/src/azure_security_keyvault_secrets_perf_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/perf/src/azure_security_keyvault_secrets_perf_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/keyvault/secrets/test/get_secret_test.hpp" +#include + int main(int argc, char** argv) { diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/test-app/test_app.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/test-app/test_app.cpp index 972cd41887..16a647da9a 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/test-app/test_app.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/test-app/test_app.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/keyvault/secrets.hpp" + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/challenge_based_authentication_policy_test.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/challenge_based_authentication_policy_test.cpp index 80f1dbfa25..dab1a03665 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/challenge_based_authentication_policy_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/challenge_based_authentication_policy_test.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MIT #include "azure/keyvault/shared/keyvault_challenge_based_authentication_policy.hpp" - #include "azure/keyvault/shared/keyvault_shared.hpp" + #include #include diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_backup_deserialize_test.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_backup_deserialize_test.cpp index 070a36fa3c..a5cc799f88 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_backup_deserialize_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_backup_deserialize_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "secret_backup_deserialize_test.hpp" + #include "../src/private/secret_serializers.hpp" #include "azure/keyvault/secrets/secret_client.hpp" diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_backup_deserialize_test.hpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_backup_deserialize_test.hpp index 2a4c541ac7..7d4009443a 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_backup_deserialize_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_backup_deserialize_test.hpp @@ -3,11 +3,14 @@ #include "azure/keyvault/secrets/keyvault_deleted_secret.hpp" #include "azure/keyvault/secrets/keyvault_secret.hpp" + #include #include -#include + #include +#include + using namespace Azure::Security::KeyVault::Secrets; using namespace Azure::Core::Http::_internal; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_base_test.hpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_base_test.hpp index e78f8c2c13..5c4faddf4a 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_base_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_base_test.hpp @@ -6,12 +6,12 @@ * @brief The base class to construct and init a Key Vault client. * */ -#include - #include #include #include +#include + using namespace std::chrono_literals; namespace Azure { namespace Security { namespace KeyVault { namespace Secrets { namespace _test { diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp index 4327f910a7..7d2f351c10 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_client_test.cpp @@ -3,7 +3,9 @@ #include "azure/identity/client_secret_credential.hpp" #include "secret_client_base_test.hpp" + #include + #include using namespace std::chrono_literals; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_get_client_deserialize_test.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_get_client_deserialize_test.cpp index a710238bcd..9f308083eb 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_get_client_deserialize_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_get_client_deserialize_test.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MIT #include "secret_get_client_deserialize_test.hpp" -#include "../src/private/secret_serializers.hpp" +#include "../src/private/secret_serializers.hpp" #include "azure/keyvault/secrets/secret_client.hpp" using namespace Azure::Security::KeyVault::Secrets; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_get_client_deserialize_test.hpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_get_client_deserialize_test.hpp index 166dce9cf0..fadf700466 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_get_client_deserialize_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_get_client_deserialize_test.hpp @@ -3,11 +3,14 @@ #include "azure/keyvault/secrets/keyvault_deleted_secret.hpp" #include "azure/keyvault/secrets/keyvault_secret.hpp" + #include #include -#include + #include +#include + using namespace Azure::Security::KeyVault::Secrets; using namespace Azure::Core::Http::_internal; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_paged_deserialize_test.hpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_paged_deserialize_test.hpp index c3fbeae388..bcc578f040 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_paged_deserialize_test.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_paged_deserialize_test.hpp @@ -1,22 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "../src/private/secret_serializers.hpp" +#include "azure/keyvault/secrets/keyvault_secret_paged_response.hpp" +#include "azure/keyvault/secrets/secret_client.hpp" #include "private/secret_constants.hpp" #include "private/secret_serializers.hpp" -#include "../src/private/secret_serializers.hpp" -#include "azure/keyvault/secrets/secret_client.hpp" +#include +#include #include #include #include -#include "azure/keyvault/secrets/keyvault_secret_paged_response.hpp" -#include -#include #include -#include #include +#include + using namespace Azure::Security::KeyVault::Secrets; using namespace Azure::Core::Http::_internal; diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_set_parameters_serializer_test.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_set_parameters_serializer_test.cpp index 8ee85f998f..bd1fff48f5 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_set_parameters_serializer_test.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/ut/secret_set_parameters_serializer_test.cpp @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "private/secret_constants.hpp" -#include "private/secret_serializers.hpp" - #include "../src/private/secret_serializers.hpp" #include "azure/core/internal/json/json.hpp" #include "azure/core/internal/json/json_optional.hpp" #include "azure/core/internal/json/json_serializable.hpp" #include "azure/keyvault/secrets/secret_client.hpp" +#include "private/secret_constants.hpp" +#include "private/secret_serializers.hpp" #include "secret_get_client_deserialize_test.hpp" using namespace Azure::Security::KeyVault::Secrets; diff --git a/sdk/keyvault/tools/cleanup/src/cleanup.cpp b/sdk/keyvault/tools/cleanup/src/cleanup.cpp index c49f9afb84..de2aa286ef 100644 --- a/sdk/keyvault/tools/cleanup/src/cleanup.cpp +++ b/sdk/keyvault/tools/cleanup/src/cleanup.cpp @@ -19,6 +19,7 @@ #include #include #include + #include #include diff --git a/sdk/storage/assets.json b/sdk/storage/assets.json index 1f1a7dca6e..a258176d8f 100644 --- a/sdk/storage/assets.json +++ b/sdk/storage/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "cpp", "TagPrefix": "cpp/storage", - "Tag": "cpp/storage_d6f16e37a3" + "Tag": "cpp/storage_d053ec409e" } diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs.hpp index 98d75e56cb..c80fcd682d 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs.hpp @@ -8,8 +8,6 @@ #pragma once -#include - #include "azure/storage/blobs/append_blob_client.hpp" #include "azure/storage/blobs/blob_batch.hpp" #include "azure/storage/blobs/blob_client.hpp" @@ -24,3 +22,5 @@ #include "azure/storage/blobs/page_blob_client.hpp" #include "azure/storage/blobs/rest_client.hpp" #include "azure/storage/blobs/rtti.hpp" + +#include diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/append_blob_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/append_blob_client.hpp index 4abe08375a..d487e1a742 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/append_blob_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/append_blob_client.hpp @@ -3,11 +3,11 @@ #pragma once +#include "azure/storage/blobs/blob_client.hpp" + #include #include -#include "azure/storage/blobs/blob_client.hpp" - namespace Azure { namespace Storage { namespace Blobs { /** diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_batch.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_batch.hpp index 3655cab17b..b6809097cd 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_batch.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_batch.hpp @@ -3,15 +3,15 @@ #pragma once -#include -#include -#include - #include "azure/storage/blobs/blob_client.hpp" #include "azure/storage/blobs/blob_container_client.hpp" #include "azure/storage/blobs/blob_service_client.hpp" #include "azure/storage/blobs/deferred_response.hpp" +#include +#include +#include + namespace Azure { namespace Storage { namespace Blobs { namespace _detail { diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_client.hpp index a704d034e1..12c53c32ba 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_client.hpp @@ -3,16 +3,16 @@ #pragma once -#include -#include -#include -#include +#include "azure/storage/blobs/blob_options.hpp" +#include "azure/storage/blobs/blob_responses.hpp" #include #include -#include "azure/storage/blobs/blob_options.hpp" -#include "azure/storage/blobs/blob_responses.hpp" +#include +#include +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { class DataLakeFileSystemClient; diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_container_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_container_client.hpp index f77b34b94c..dee80d092d 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_container_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_container_client.hpp @@ -3,12 +3,12 @@ #pragma once +#include "azure/storage/blobs/blob_client.hpp" + #include #include #include -#include "azure/storage/blobs/blob_client.hpp" - namespace Azure { namespace Storage { namespace Blobs { class BlobLeaseClient; diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_lease_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_lease_client.hpp index 63d69685c3..7b364b2ee6 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_lease_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_lease_client.hpp @@ -3,13 +3,13 @@ #pragma once +#include "azure/storage/blobs/blob_client.hpp" +#include "azure/storage/blobs/blob_container_client.hpp" + #include #include #include -#include "azure/storage/blobs/blob_client.hpp" -#include "azure/storage/blobs/blob_container_client.hpp" - namespace Azure { namespace Storage { namespace Blobs { /** diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp index a1e4171be2..fc5535d45c 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp @@ -3,12 +3,7 @@ #pragma once -#include -#include -#include -#include -#include -#include +#include "azure/storage/blobs/rest_client.hpp" #include #include @@ -16,7 +11,12 @@ #include #include -#include "azure/storage/blobs/rest_client.hpp" +#include +#include +#include +#include +#include +#include namespace Azure { namespace Storage { namespace Blobs { diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp index b0bf4fdd64..8bc13bb655 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp @@ -3,16 +3,16 @@ #pragma once -#include -#include -#include -#include +#include "azure/storage/blobs/blob_options.hpp" #include #include #include -#include "azure/storage/blobs/blob_options.hpp" +#include +#include +#include +#include namespace Azure { namespace Storage { diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_sas_builder.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_sas_builder.hpp index 16c27507a3..e7f6044264 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_sas_builder.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_sas_builder.hpp @@ -3,11 +3,11 @@ #pragma once -#include +#include "azure/storage/blobs/blob_responses.hpp" #include -#include "azure/storage/blobs/blob_responses.hpp" +#include namespace Azure { namespace Storage { namespace Sas { diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_service_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_service_client.hpp index b433bdfd6e..5007297172 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_service_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_service_client.hpp @@ -3,13 +3,13 @@ #pragma once -#include -#include +#include "azure/storage/blobs/blob_container_client.hpp" #include #include -#include "azure/storage/blobs/blob_container_client.hpp" +#include +#include namespace Azure { namespace Storage { namespace Blobs { diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/block_blob_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/block_blob_client.hpp index 33b7b39d1b..1349e40526 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/block_blob_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/block_blob_client.hpp @@ -3,12 +3,12 @@ #pragma once +#include "azure/storage/blobs/blob_client.hpp" + #include #include #include -#include "azure/storage/blobs/blob_client.hpp" - namespace Azure { namespace Storage { namespace Files { namespace DataLake { class FileClient; }}}} // namespace Azure::Storage::Files::DataLake diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/deferred_response.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/deferred_response.hpp index bcce2f37ec..9016b95aa7 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/deferred_response.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/deferred_response.hpp @@ -3,10 +3,10 @@ #pragma once -#include - #include +#include + namespace Azure { namespace Storage { namespace Blobs { class BlobServiceBatch; diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/page_blob_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/page_blob_client.hpp index 80f90fa7bd..691aa57018 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/page_blob_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/page_blob_client.hpp @@ -3,12 +3,12 @@ #pragma once +#include "azure/storage/blobs/blob_client.hpp" + #include #include #include -#include "azure/storage/blobs/blob_client.hpp" - namespace Azure { namespace Storage { namespace Blobs { /** diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/rest_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/rest_client.hpp index de2b65f104..3a638afa24 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/rest_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/rest_client.hpp @@ -6,13 +6,6 @@ // Changes may cause incorrect behavior and will be lost if the code is regenerated. #pragma once -#include -#include -#include -#include -#include -#include - #include #include #include @@ -26,6 +19,13 @@ #include #include +#include +#include +#include +#include +#include +#include + namespace Azure { namespace Storage { namespace Blobs { namespace _detail { /** diff --git a/sdk/storage/azure-storage-blobs/samples/blob_getting_started.cpp b/sdk/storage/azure-storage-blobs/samples/blob_getting_started.cpp index 04886e4382..38fa26a789 100644 --- a/sdk/storage/azure-storage-blobs/samples/blob_getting_started.cpp +++ b/sdk/storage/azure-storage-blobs/samples/blob_getting_started.cpp @@ -3,12 +3,12 @@ #include "get_env.hpp" +#include + #include #include #include -#include - std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-blobs/samples/blob_list_operation.cpp b/sdk/storage/azure-storage-blobs/samples/blob_list_operation.cpp index 697615a68c..f27b35c192 100644 --- a/sdk/storage/azure-storage-blobs/samples/blob_list_operation.cpp +++ b/sdk/storage/azure-storage-blobs/samples/blob_list_operation.cpp @@ -3,12 +3,12 @@ #include "get_env.hpp" +#include + #include #include #include -#include - std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-blobs/samples/blob_query.cpp b/sdk/storage/azure-storage-blobs/samples/blob_query.cpp index f01c0de632..fab1b7bc2b 100644 --- a/sdk/storage/azure-storage-blobs/samples/blob_query.cpp +++ b/sdk/storage/azure-storage-blobs/samples/blob_query.cpp @@ -3,10 +3,10 @@ #include "get_env.hpp" -#include - #include +#include + std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-blobs/samples/blob_sas.cpp b/sdk/storage/azure-storage-blobs/samples/blob_sas.cpp index cbb43a2bbb..d851a2e609 100644 --- a/sdk/storage/azure-storage-blobs/samples/blob_sas.cpp +++ b/sdk/storage/azure-storage-blobs/samples/blob_sas.cpp @@ -3,13 +3,13 @@ #include "get_env.hpp" +#include +#include + #include #include #include -#include -#include - std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-blobs/samples/transactional_checksum.cpp b/sdk/storage/azure-storage-blobs/samples/transactional_checksum.cpp index 85bf8b6090..b725a8fe05 100644 --- a/sdk/storage/azure-storage-blobs/samples/transactional_checksum.cpp +++ b/sdk/storage/azure-storage-blobs/samples/transactional_checksum.cpp @@ -3,13 +3,13 @@ #include "get_env.hpp" +#include +#include + #include #include #include -#include -#include - std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-blobs/src/blob_batch.cpp b/sdk/storage/azure-storage-blobs/src/blob_batch.cpp index 40dcbc76c2..6ce10f6413 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_batch.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_batch.cpp @@ -3,11 +3,7 @@ #include "azure/storage/blobs/blob_batch.hpp" -#include -#include -#include -#include -#include +#include "private/package_version.hpp" #include #include @@ -17,7 +13,11 @@ #include #include -#include "private/package_version.hpp" +#include +#include +#include +#include +#include namespace Azure { namespace Storage { namespace Blobs { diff --git a/sdk/storage/azure-storage-blobs/src/blob_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_client.cpp index 9ee05b2c7f..7498bc51ff 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_client.cpp @@ -3,6 +3,11 @@ #include "azure/storage/blobs/blob_client.hpp" +#include "azure/storage/blobs/append_blob_client.hpp" +#include "azure/storage/blobs/block_blob_client.hpp" +#include "azure/storage/blobs/page_blob_client.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -17,12 +22,6 @@ #include #include -#include "azure/storage/blobs/append_blob_client.hpp" -#include "azure/storage/blobs/block_blob_client.hpp" -#include "azure/storage/blobs/page_blob_client.hpp" - -#include "private/package_version.hpp" - #include namespace Azure { namespace Storage { namespace Blobs { diff --git a/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp index 806a753aaf..4ed5fcc93d 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_container_client.cpp @@ -3,6 +3,12 @@ #include "azure/storage/blobs/blob_container_client.hpp" +#include "azure/storage/blobs/append_blob_client.hpp" +#include "azure/storage/blobs/blob_batch.hpp" +#include "azure/storage/blobs/block_blob_client.hpp" +#include "azure/storage/blobs/page_blob_client.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -13,13 +19,6 @@ #include #include -#include "azure/storage/blobs/append_blob_client.hpp" -#include "azure/storage/blobs/blob_batch.hpp" -#include "azure/storage/blobs/block_blob_client.hpp" -#include "azure/storage/blobs/page_blob_client.hpp" - -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Blobs { namespace { diff --git a/sdk/storage/azure-storage-blobs/src/blob_service_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_service_client.cpp index d6c3b428d2..a868bc62b3 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_service_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_service_client.cpp @@ -3,6 +3,9 @@ #include "azure/storage/blobs/blob_service_client.hpp" +#include "azure/storage/blobs/blob_batch.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -12,9 +15,6 @@ #include #include -#include "azure/storage/blobs/blob_batch.hpp" -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Blobs { BlobServiceClient BlobServiceClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp index 9aefdafc0e..44adb2657c 100644 --- a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp @@ -15,6 +15,8 @@ #include #endif +#include "private/avro_parser.hpp" + #include #include #include @@ -24,8 +26,6 @@ #include #include -#include "private/avro_parser.hpp" - namespace Azure { namespace Storage { namespace Blobs { BlockBlobClient BlockBlobClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-blobs/src/private/avro_parser.cpp b/sdk/storage/azure-storage-blobs/src/private/avro_parser.cpp index 5ff4846023..22822e85c6 100644 --- a/sdk/storage/azure-storage-blobs/src/private/avro_parser.cpp +++ b/sdk/storage/azure-storage-blobs/src/private/avro_parser.cpp @@ -3,12 +3,12 @@ #include "avro_parser.hpp" -#include -#include - #include #include +#include +#include + namespace Azure { namespace Storage { namespace Blobs { namespace _detail { namespace { diff --git a/sdk/storage/azure-storage-blobs/src/private/avro_parser.hpp b/sdk/storage/azure-storage-blobs/src/private/avro_parser.hpp index 0d6554053a..cd41e49910 100644 --- a/sdk/storage/azure-storage-blobs/src/private/avro_parser.hpp +++ b/sdk/storage/azure-storage-blobs/src/private/avro_parser.hpp @@ -3,13 +3,13 @@ #pragma once -#include -#include -#include +#include "azure/storage/blobs/blob_options.hpp" #include -#include "azure/storage/blobs/blob_options.hpp" +#include +#include +#include namespace Azure { namespace Storage { namespace Blobs { namespace _detail { enum class AvroDatumType diff --git a/sdk/storage/azure-storage-blobs/src/rest_client.cpp b/sdk/storage/azure-storage-blobs/src/rest_client.cpp index d89db5d144..aadb302899 100644 --- a/sdk/storage/azure-storage-blobs/src/rest_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/rest_client.cpp @@ -4,13 +4,6 @@ // // Code generated by Microsoft (R) AutoRest C++ Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -#include - -#include -#include -#include -#include - #include #include #include @@ -21,11 +14,17 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include +#include + namespace { std::string ListBlobContainersIncludeFlagsToString( const Azure::Storage::Blobs::Models::ListBlobContainersIncludeFlags& val) diff --git a/sdk/storage/azure-storage-blobs/test/fault-injector/azure_storage_blobs_fault_injector_test.cpp b/sdk/storage/azure-storage-blobs/test/fault-injector/azure_storage_blobs_fault_injector_test.cpp index 51eed8b7a8..03370e7a6c 100644 --- a/sdk/storage/azure-storage-blobs/test/fault-injector/azure_storage_blobs_fault_injector_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/fault-injector/azure_storage_blobs_fault_injector_test.cpp @@ -11,7 +11,6 @@ */ #include - #include #if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp index f218608384..a5a8464a2d 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp @@ -12,7 +12,6 @@ #include #include #include - #include #include diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_from_sas.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_from_sas.hpp index b96a19bc5f..030d8a0f62 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_from_sas.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_from_sas.hpp @@ -9,11 +9,11 @@ #pragma once +#include "azure/storage/blobs/test/blob_base_test.hpp" + #include #include -#include "azure/storage/blobs/test/blob_base_test.hpp" - #include #include #include diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_pipeline_only.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_pipeline_only.hpp index 3ba318a212..9d10277ff0 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_pipeline_only.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_pipeline_only.hpp @@ -10,12 +10,12 @@ #pragma once +#include "azure/storage/blobs/test/blob_base_test.hpp" + #include #include #include -#include "azure/storage/blobs/test/blob_base_test.hpp" - #include #include #include diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_test.hpp index f7d5b40ca6..77b6a90c2f 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_test.hpp @@ -9,11 +9,11 @@ #pragma once +#include "azure/storage/blobs/test/blob_base_test.hpp" + #include #include -#include "azure/storage/blobs/test/blob_base_test.hpp" - #include #include #include diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_transport_only.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_transport_only.hpp index e576b1d1cf..f6f966a7f8 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_transport_only.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_transport_only.hpp @@ -10,12 +10,12 @@ #pragma once +#include "azure/storage/blobs/test/blob_base_test.hpp" + #include #include #include -#include "azure/storage/blobs/test/blob_base_test.hpp" - #include #include #include diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/list_blob_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/list_blob_test.hpp index b938efd50b..0cb40cd464 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/list_blob_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/list_blob_test.hpp @@ -9,12 +9,12 @@ #pragma once +#include "azure/storage/blobs/test/blob_base_test.hpp" + #include #include #include -#include "azure/storage/blobs/test/blob_base_test.hpp" - #include #include #include diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/upload_blob_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/upload_blob_test.hpp index bcca1b4bce..b788e2762b 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/upload_blob_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/upload_blob_test.hpp @@ -9,12 +9,12 @@ #pragma once +#include "azure/storage/blobs/test/blob_base_test.hpp" + #include #include #include -#include "azure/storage/blobs/test/blob_base_test.hpp" - #include #include #include diff --git a/sdk/storage/azure-storage-blobs/test/perf/src/azure_storage_blobs_perf_test.cpp b/sdk/storage/azure-storage-blobs/test/perf/src/azure_storage_blobs_perf_test.cpp index 996f4e9607..c2edaadf39 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/src/azure_storage_blobs_perf_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/perf/src/azure_storage_blobs_perf_test.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "azure/storage/blobs/test/download_blob_from_sas.hpp" #include "azure/storage/blobs/test/download_blob_pipeline_only.hpp" #include "azure/storage/blobs/test/download_blob_test.hpp" +#include + #if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) #include "azure/storage/blobs/test/download_blob_transport_only.hpp" #endif diff --git a/sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.hpp index 797f57bc68..ac66302139 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.hpp @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "blob_container_client_test.hpp" #include "test/ut/test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class AppendBlobClientTest : public BlobContainerClientTest { diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_batch_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_batch_client_test.cpp index 0814f4de8d..c13348d0e9 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_batch_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_batch_client_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "blob_container_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { TEST_F(BlobContainerClientTest, BatchSubmitDelete_LIVEONLY_) diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp index 1dc17f88a8..18594d5617 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp @@ -3,14 +3,14 @@ #include "blob_container_client_test.hpp" -#include -#include - #include #include #include #include +#include +#include + namespace Azure { namespace Storage { namespace Blobs { namespace Models { bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs); diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.hpp index 3976f0b2f5..12ac676aee 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "blob_service_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class BlobContainerClientTest : public BlobServiceClientTest { diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp index f82e26b408..5c4ec92489 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "blob_container_client_test.hpp" + #include #include #include -#include "blob_container_client_test.hpp" - namespace Azure { namespace Storage { namespace Test { TEST_F(BlobContainerClientTest, BlobSasTest_LIVEONLY_) diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp index 0bd9e5d921..bd66dea38d 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include +#include "blob_service_client_test.hpp" #include #include -#include "blob_service_client_test.hpp" +#include namespace Azure { namespace Storage { namespace Blobs { namespace Models { diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.hpp index f3e30e6576..9f0cea4110 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "test/ut/test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class BlobServiceClientTest : public StorageTest { diff --git a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp index 38588144ee..c9764b245b 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp @@ -3,13 +3,13 @@ #include "block_blob_client_test.hpp" +#include +#include + #include #include #include -#include -#include - namespace Azure { namespace Storage { namespace Blobs { namespace Models { bool operator==(const BlobHttpHeaders& lhs, const BlobHttpHeaders& rhs) diff --git a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.hpp index 5b15b2a4d0..4e51d937ad 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "blob_container_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class BlockBlobClientTest : public BlobContainerClientTest { diff --git a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp index 0401e4dd51..28f3f6b7d5 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp @@ -3,14 +3,14 @@ #include "page_blob_client_test.hpp" -#include -#include - #include #include #include #include +#include +#include + namespace Azure { namespace Storage { namespace Blobs { namespace Models { bool operator==(const BlobHttpHeaders& lhs, const BlobHttpHeaders& rhs); diff --git a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.hpp index a9fb009c99..421e8d6555 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "blob_container_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class PageBlobClientTest : public BlobContainerClientTest { diff --git a/sdk/storage/azure-storage-blobs/test/ut/storage_retry_policy_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/storage_retry_policy_test.cpp index a18063b5b5..48d22f9ebc 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/storage_retry_policy_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/storage_retry_policy_test.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include -#include +#include "test/ut/test_base.hpp" #include -#include "test/ut/test_base.hpp" +#include +#include +#include namespace Azure { namespace Storage { namespace Test { diff --git a/sdk/storage/azure-storage-blobs/test/ut/storage_timeout_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/storage_timeout_test.cpp index 13c7d08026..7ab7bb73ce 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/storage_timeout_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/storage_timeout_test.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include -#include -#include +#include "test/ut/test_base.hpp" #include -#include "test/ut/test_base.hpp" +#include +#include +#include namespace Azure { namespace Storage { namespace Test { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/access_conditions.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/access_conditions.hpp index 968f9dce24..086c0868d4 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/access_conditions.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/access_conditions.hpp @@ -3,12 +3,12 @@ #pragma once -#include +#include "azure/storage/common/storage_common.hpp" #include #include -#include "azure/storage/common/storage_common.hpp" +#include namespace Azure { namespace Storage { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/account_sas_builder.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/account_sas_builder.hpp index 359f16a389..d5431c5113 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/account_sas_builder.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/account_sas_builder.hpp @@ -3,14 +3,14 @@ #pragma once -#include -#include +#include "azure/storage/common/internal/constants.hpp" +#include "azure/storage/common/storage_credential.hpp" #include #include -#include "azure/storage/common/internal/constants.hpp" -#include "azure/storage/common/storage_credential.hpp" +#include +#include namespace Azure { namespace Storage { namespace Sas { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp index e697b7e7cf..8d2a7a2a25 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp @@ -3,13 +3,13 @@ #pragma once +#include +#include + #include #include #include -#include -#include - namespace Azure { namespace Storage { /** diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/reliable_stream.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/reliable_stream.hpp index 3710d7cd53..2a34f2174f 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/reliable_stream.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/reliable_stream.hpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include +#include + #include #include #include -#include -#include - namespace Azure { namespace Storage { namespace _internal { // Options used by reliable stream diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/shared_key_policy.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/shared_key_policy.hpp index 8db6ede975..f8b1002a2f 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/shared_key_policy.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/shared_key_policy.hpp @@ -3,12 +3,12 @@ #pragma once -#include -#include +#include "azure/storage/common/storage_credential.hpp" #include -#include "azure/storage/common/storage_credential.hpp" +#include +#include namespace Azure { namespace Storage { namespace _internal { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_per_retry_policy.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_per_retry_policy.hpp index 9ab7248edc..a0645fc7f0 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_per_retry_policy.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_per_retry_policy.hpp @@ -3,10 +3,10 @@ #pragma once -#include - #include +#include + namespace Azure { namespace Storage { namespace _internal { class StoragePerRetryPolicy final : public Core::Http::Policies::HttpPolicy { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_service_version_policy.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_service_version_policy.hpp index 40401239e9..3be656fb21 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_service_version_policy.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_service_version_policy.hpp @@ -3,11 +3,11 @@ #pragma once +#include + #include #include -#include - namespace Azure { namespace Storage { namespace _internal { class StorageServiceVersionPolicy final : public Azure::Core::Http::Policies::HttpPolicy { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_switch_to_secondary_policy.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_switch_to_secondary_policy.hpp index 681ba8e22f..d6a1baa63f 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_switch_to_secondary_policy.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_switch_to_secondary_policy.hpp @@ -3,12 +3,12 @@ #pragma once -#include -#include +#include "azure/storage/common/dll_import_export.hpp" #include -#include "azure/storage/common/dll_import_export.hpp" +#include +#include namespace Azure { namespace Storage { namespace _internal { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_common.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_common.hpp index 776b1c4461..6a7f8c1d65 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_common.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_common.hpp @@ -3,6 +3,12 @@ #pragma once +#include "azure/storage/common/internal/constants.hpp" +#include "azure/storage/common/internal/storage_per_retry_policy.hpp" + +#include +#include + #include #include #include @@ -10,12 +16,6 @@ #include #include -#include -#include - -#include "azure/storage/common/internal/constants.hpp" -#include "azure/storage/common/internal/storage_per_retry_policy.hpp" - namespace Azure { namespace Storage { constexpr static const char* AccountEncryptionKey = "$account-encryption-key"; diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_credential.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_credential.hpp index 6ddc1dfbb1..ab8bc172c3 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_credential.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_credential.hpp @@ -3,12 +3,12 @@ #pragma once +#include + #include #include #include -#include - namespace Azure { namespace Storage { namespace Sas { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_exception.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_exception.hpp index f8a026480a..155027f639 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_exception.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_exception.hpp @@ -3,14 +3,14 @@ #pragma once +#include +#include + #include #include #include #include -#include -#include - namespace Azure { namespace Storage { /** diff --git a/sdk/storage/azure-storage-common/src/account_sas_builder.cpp b/sdk/storage/azure-storage-common/src/account_sas_builder.cpp index e3d436a5cb..00d474300a 100644 --- a/sdk/storage/azure-storage-common/src/account_sas_builder.cpp +++ b/sdk/storage/azure-storage-common/src/account_sas_builder.cpp @@ -3,10 +3,10 @@ #include "azure/storage/common/account_sas_builder.hpp" -#include - #include "azure/storage/common/crypt.hpp" +#include + namespace Azure { namespace Storage { namespace Sas { namespace { constexpr static const char* SasVersion = "2022-11-02"; diff --git a/sdk/storage/azure-storage-common/src/crypt.cpp b/sdk/storage/azure-storage-common/src/crypt.cpp index 89d24dd086..e6618aaf7f 100644 --- a/sdk/storage/azure-storage-common/src/crypt.cpp +++ b/sdk/storage/azure-storage-common/src/crypt.cpp @@ -21,13 +21,13 @@ #include #endif -#include -#include -#include +#include "azure/storage/common/storage_common.hpp" #include -#include "azure/storage/common/storage_common.hpp" +#include +#include +#include namespace Azure { namespace Storage { diff --git a/sdk/storage/azure-storage-common/src/file_io.cpp b/sdk/storage/azure-storage-common/src/file_io.cpp index 96cb8e1792..137a726fc0 100644 --- a/sdk/storage/azure-storage-common/src/file_io.cpp +++ b/sdk/storage/azure-storage-common/src/file_io.cpp @@ -7,9 +7,10 @@ #if defined(AZ_PLATFORM_POSIX) #include +#include + #include #include -#include #endif #if defined(AZ_PLATFORM_WINDOWS) diff --git a/sdk/storage/azure-storage-common/src/shared_key_policy.cpp b/sdk/storage/azure-storage-common/src/shared_key_policy.cpp index c6546502a0..80ab00c394 100644 --- a/sdk/storage/azure-storage-common/src/shared_key_policy.cpp +++ b/sdk/storage/azure-storage-common/src/shared_key_policy.cpp @@ -3,12 +3,12 @@ #include "azure/storage/common/internal/shared_key_policy.hpp" -#include +#include "azure/storage/common/crypt.hpp" #include #include -#include "azure/storage/common/crypt.hpp" +#include namespace Azure { namespace Storage { namespace _internal { diff --git a/sdk/storage/azure-storage-common/src/storage_exception.cpp b/sdk/storage/azure-storage-common/src/storage_exception.cpp index d1f43129c8..7b53a6594a 100644 --- a/sdk/storage/azure-storage-common/src/storage_exception.cpp +++ b/sdk/storage/azure-storage-common/src/storage_exception.cpp @@ -3,13 +3,13 @@ #include "azure/storage/common/storage_exception.hpp" -#include +#include "azure/storage/common/internal/constants.hpp" +#include "azure/storage/common/internal/xml_wrapper.hpp" #include #include -#include "azure/storage/common/internal/constants.hpp" -#include "azure/storage/common/internal/xml_wrapper.hpp" +#include namespace Azure { namespace Storage { StorageException StorageException::CreateFromResponse( diff --git a/sdk/storage/azure-storage-common/src/xml_wrapper.cpp b/sdk/storage/azure-storage-common/src/xml_wrapper.cpp index 4190240c45..cebb54a769 100644 --- a/sdk/storage/azure-storage-common/src/xml_wrapper.cpp +++ b/sdk/storage/azure-storage-common/src/xml_wrapper.cpp @@ -3,13 +3,13 @@ #include "azure/storage/common/internal/xml_wrapper.hpp" +#include + #include #include #include #include -#include - #if defined(AZ_PLATFORM_WINDOWS) #if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN diff --git a/sdk/storage/azure-storage-common/test/ut/crypt_functions_test.cpp b/sdk/storage/azure-storage-common/test/ut/crypt_functions_test.cpp index c01c23e3a7..1ccef9f1f6 100644 --- a/sdk/storage/azure-storage-common/test/ut/crypt_functions_test.cpp +++ b/sdk/storage/azure-storage-common/test/ut/crypt_functions_test.cpp @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include +#include "test_base.hpp" #include -#include "test_base.hpp" +#include namespace Azure { namespace Storage { namespace Test { diff --git a/sdk/storage/azure-storage-common/test/ut/metadata_test.cpp b/sdk/storage/azure-storage-common/test/ut/metadata_test.cpp index 89c3521f9b..72909da74f 100644 --- a/sdk/storage/azure-storage-common/test/ut/metadata_test.cpp +++ b/sdk/storage/azure-storage-common/test/ut/metadata_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { TEST(MetadataTest, CaseInsensitive) diff --git a/sdk/storage/azure-storage-common/test/ut/storage_credential_test.cpp b/sdk/storage/azure-storage-common/test/ut/storage_credential_test.cpp index 913a658726..d05fbe03f9 100644 --- a/sdk/storage/azure-storage-common/test/ut/storage_credential_test.cpp +++ b/sdk/storage/azure-storage-common/test/ut/storage_credential_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { TEST(StorageCredentialTest, DefaultHostCorrect) diff --git a/sdk/storage/azure-storage-common/test/ut/test_base.cpp b/sdk/storage/azure-storage-common/test/ut/test_base.cpp index 98c2b08cc6..6a075ce738 100644 --- a/sdk/storage/azure-storage-common/test/ut/test_base.cpp +++ b/sdk/storage/azure-storage-common/test/ut/test_base.cpp @@ -3,6 +3,10 @@ #include "test_base.hpp" +#include +#include +#include + #include #include #include @@ -15,10 +19,6 @@ #include #include -#include -#include -#include - namespace Azure { namespace Storage { namespace Blobs { namespace Models { bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs) diff --git a/sdk/storage/azure-storage-common/test/ut/test_base.hpp b/sdk/storage/azure-storage-common/test/ut/test_base.hpp index 3955b896ca..c9c0a2c653 100644 --- a/sdk/storage/azure-storage-common/test/ut/test_base.hpp +++ b/sdk/storage/azure-storage-common/test/ut/test_base.hpp @@ -3,23 +3,23 @@ #pragma once -#include - -#include -#include -#include -#include -#include - #include #include #include #include +#include #include #include #include #include #include + +#include +#include +#include +#include +#include + #include namespace Azure { namespace Storage { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake.hpp index aaa0f7ae82..76290debd7 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake.hpp @@ -8,8 +8,6 @@ #pragma once -#include - #include "azure/storage/files/datalake/datalake_directory_client.hpp" #include "azure/storage/files/datalake/datalake_file_client.hpp" #include "azure/storage/files/datalake/datalake_file_system_client.hpp" @@ -22,3 +20,5 @@ #include "azure/storage/files/datalake/dll_import_export.hpp" #include "azure/storage/files/datalake/rest_client.hpp" #include "azure/storage/files/datalake/rtti.hpp" + +#include diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp index d8d2f4defd..02ce16dbfa 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp @@ -3,18 +3,18 @@ #pragma once -#include -#include -#include +#include "azure/storage/files/datalake/datalake_options.hpp" +#include "azure/storage/files/datalake/datalake_path_client.hpp" +#include "azure/storage/files/datalake/datalake_responses.hpp" #include #include #include #include -#include "azure/storage/files/datalake/datalake_options.hpp" -#include "azure/storage/files/datalake/datalake_path_client.hpp" -#include "azure/storage/files/datalake/datalake_responses.hpp" +#include +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp index 40dc3856b8..2806c0222d 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp @@ -3,9 +3,9 @@ #pragma once -#include -#include -#include +#include "azure/storage/files/datalake/datalake_options.hpp" +#include "azure/storage/files/datalake/datalake_path_client.hpp" +#include "azure/storage/files/datalake/datalake_responses.hpp" #include #include @@ -13,9 +13,9 @@ #include #include -#include "azure/storage/files/datalake/datalake_options.hpp" -#include "azure/storage/files/datalake/datalake_path_client.hpp" -#include "azure/storage/files/datalake/datalake_responses.hpp" +#include +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_system_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_system_client.hpp index 4e390b13b5..41f5438f38 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_system_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_system_client.hpp @@ -3,8 +3,9 @@ #pragma once -#include -#include +#include "azure/storage/files/datalake/datalake_options.hpp" +#include "azure/storage/files/datalake/datalake_responses.hpp" +#include "azure/storage/files/datalake/datalake_service_client.hpp" #include #include @@ -12,9 +13,8 @@ #include #include -#include "azure/storage/files/datalake/datalake_options.hpp" -#include "azure/storage/files/datalake/datalake_responses.hpp" -#include "azure/storage/files/datalake/datalake_service_client.hpp" +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_lease_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_lease_client.hpp index 014ea7aab8..4ab0788652 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_lease_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_lease_client.hpp @@ -3,12 +3,12 @@ #pragma once -#include +#include "azure/storage/files/datalake/datalake_file_system_client.hpp" +#include "azure/storage/files/datalake/datalake_path_client.hpp" #include -#include "azure/storage/files/datalake/datalake_file_system_client.hpp" -#include "azure/storage/files/datalake/datalake_path_client.hpp" +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp index 5318df89ed..bfac843431 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp @@ -3,17 +3,17 @@ #pragma once -#include -#include -#include -#include +#include "azure/storage/blobs/rest_client.hpp" +#include "azure/storage/files/datalake/rest_client.hpp" #include #include #include -#include "azure/storage/blobs/rest_client.hpp" -#include "azure/storage/files/datalake/rest_client.hpp" +#include +#include +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_path_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_path_client.hpp index 497b36ac0a..b7e767b36d 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_path_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_path_client.hpp @@ -3,10 +3,9 @@ #pragma once -#include -#include -#include -#include +#include "azure/storage/files/datalake/datalake_file_system_client.hpp" +#include "azure/storage/files/datalake/datalake_options.hpp" +#include "azure/storage/files/datalake/datalake_responses.hpp" #include #include @@ -14,9 +13,10 @@ #include #include -#include "azure/storage/files/datalake/datalake_file_system_client.hpp" -#include "azure/storage/files/datalake/datalake_options.hpp" -#include "azure/storage/files/datalake/datalake_responses.hpp" +#include +#include +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp index 0c5e14e04c..fa018f046d 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp @@ -3,13 +3,13 @@ #pragma once -#include -#include -#include +#include "azure/storage/files/datalake/datalake_options.hpp" #include -#include "azure/storage/files/datalake/datalake_options.hpp" +#include +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_sas_builder.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_sas_builder.hpp index dba43e533e..d093252c5a 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_sas_builder.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_sas_builder.hpp @@ -3,14 +3,14 @@ #pragma once -#include -#include -#include +#include "azure/storage/files/datalake/datalake_responses.hpp" #include #include -#include "azure/storage/files/datalake/datalake_responses.hpp" +#include +#include +#include namespace Azure { namespace Storage { namespace Sas { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_service_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_service_client.hpp index 1cb927ff3f..8c5d0abff6 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_service_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_service_client.hpp @@ -3,8 +3,8 @@ #pragma once -#include -#include +#include "azure/storage/files/datalake/datalake_options.hpp" +#include "azure/storage/files/datalake/datalake_responses.hpp" #include #include @@ -12,8 +12,8 @@ #include #include -#include "azure/storage/files/datalake/datalake_options.hpp" -#include "azure/storage/files/datalake/datalake_responses.hpp" +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp index 8cf70b3eb8..47c70e2cbc 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp @@ -6,10 +6,6 @@ // Changes may cause incorrect behavior and will be lost if the code is regenerated. #pragma once -#include -#include -#include - #include #include #include @@ -21,6 +17,10 @@ #include #include +#include +#include +#include + namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace _detail { /** diff --git a/sdk/storage/azure-storage-files-datalake/samples/datalake_getting_started.cpp b/sdk/storage/azure-storage-files-datalake/samples/datalake_getting_started.cpp index 67f9810a1d..127ffab8bf 100644 --- a/sdk/storage/azure-storage-files-datalake/samples/datalake_getting_started.cpp +++ b/sdk/storage/azure-storage-files-datalake/samples/datalake_getting_started.cpp @@ -3,12 +3,12 @@ #include "get_env.hpp" +#include + #include #include #include -#include - std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp index ec704e1513..c496089b1c 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp @@ -3,6 +3,9 @@ #include "azure/storage/files/datalake/datalake_directory_client.hpp" +#include "azure/storage/files/datalake/datalake_file_client.hpp" +#include "private/datalake_utilities.hpp" + #include #include #include @@ -10,9 +13,6 @@ #include #include -#include "azure/storage/files/datalake/datalake_file_client.hpp" -#include "private/datalake_utilities.hpp" - namespace Azure { namespace Storage { namespace Files { namespace DataLake { DataLakeDirectoryClient DataLakeDirectoryClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp index 6edca7ea3e..898d964da1 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp @@ -3,15 +3,15 @@ #include "azure/storage/files/datalake/datalake_file_client.hpp" +#include "private/datalake_constants.hpp" +#include "private/datalake_utilities.hpp" + #include #include #include #include #include -#include "private/datalake_constants.hpp" -#include "private/datalake_utilities.hpp" - namespace Azure { namespace Storage { namespace Files { namespace DataLake { DataLakeFileClient DataLakeFileClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_file_system_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_file_system_client.cpp index 5e7b089490..1760d99d77 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_file_system_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_file_system_client.cpp @@ -3,6 +3,13 @@ #include "azure/storage/files/datalake/datalake_file_system_client.hpp" +#include "azure/storage/files/datalake/datalake_directory_client.hpp" +#include "azure/storage/files/datalake/datalake_file_client.hpp" +#include "azure/storage/files/datalake/datalake_path_client.hpp" +#include "private/datalake_constants.hpp" +#include "private/datalake_utilities.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -13,13 +20,6 @@ #include #include -#include "azure/storage/files/datalake/datalake_directory_client.hpp" -#include "azure/storage/files/datalake/datalake_file_client.hpp" -#include "azure/storage/files/datalake/datalake_path_client.hpp" -#include "private/datalake_constants.hpp" -#include "private/datalake_utilities.hpp" -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Files { namespace DataLake { DataLakeFileSystemClient DataLakeFileSystemClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp index fd7a884ce5..536f120010 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp @@ -3,6 +3,10 @@ #include "azure/storage/files/datalake/datalake_path_client.hpp" +#include "private/datalake_constants.hpp" +#include "private/datalake_utilities.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -13,10 +17,6 @@ #include #include -#include "private/datalake_constants.hpp" -#include "private/datalake_utilities.hpp" -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Files { namespace DataLake { DataLakePathClient DataLakePathClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_service_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_service_client.cpp index fd344115c4..0aa2c20db6 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_service_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_service_client.cpp @@ -3,6 +3,10 @@ #include "azure/storage/files/datalake/datalake_service_client.hpp" +#include "azure/storage/files/datalake/datalake_file_system_client.hpp" +#include "private/datalake_utilities.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -13,10 +17,6 @@ #include #include -#include "azure/storage/files/datalake/datalake_file_system_client.hpp" -#include "private/datalake_utilities.hpp" -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Files { namespace DataLake { DataLakeServiceClient DataLakeServiceClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp index 76a96546bb..c54447d6c9 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp @@ -3,10 +3,10 @@ #include "private/datalake_utilities.hpp" -#include - #include "private/datalake_constants.hpp" +#include + namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace _detail { const static std::string DfsEndPointIdentifier = ".dfs."; diff --git a/sdk/storage/azure-storage-files-datalake/src/private/datalake_utilities.hpp b/sdk/storage/azure-storage-files-datalake/src/private/datalake_utilities.hpp index d0d006882d..0788cff31d 100644 --- a/sdk/storage/azure-storage-files-datalake/src/private/datalake_utilities.hpp +++ b/sdk/storage/azure-storage-files-datalake/src/private/datalake_utilities.hpp @@ -3,13 +3,13 @@ #pragma once -#include +#include "azure/storage/files/datalake/datalake_options.hpp" #include #include #include -#include "azure/storage/files/datalake/datalake_options.hpp" +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace _detail { diff --git a/sdk/storage/azure-storage-files-datalake/src/rest_client.cpp b/sdk/storage/azure-storage-files-datalake/src/rest_client.cpp index 6aaf59f61b..b0451ec914 100644 --- a/sdk/storage/azure-storage-files-datalake/src/rest_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/rest_client.cpp @@ -4,11 +4,6 @@ // // Code generated by Microsoft (R) AutoRest C++ Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -#include - -#include -#include - #include #include #include @@ -23,6 +18,10 @@ #include #include #include +#include + +#include +#include namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace Models { diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_directory_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_directory_client_test.cpp index b891792a4b..30ba4321be 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_directory_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_directory_client_test.cpp @@ -3,12 +3,12 @@ #include "datalake_directory_client_test.hpp" -#include -#include - #include #include +#include +#include + namespace Azure { namespace Storage { namespace Test { void DataLakeDirectoryClientTest::SetUp() diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_directory_client_test.hpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_directory_client_test.hpp index c80ab4c3c7..0164d64e1b 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_directory_client_test.hpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_directory_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "datalake_path_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class DataLakeDirectoryClientTest : public DataLakePathClientTest { diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp index a8574dbf8f..bc4e7a3257 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp @@ -3,16 +3,16 @@ #include "datalake_file_client_test.hpp" +#include +#include +#include + #include #include #include #include #include -#include -#include -#include - namespace Azure { namespace Storage { namespace Blobs { namespace Models { bool operator==(const BlobHttpHeaders& lhs, const BlobHttpHeaders& rhs) diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.hpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.hpp index 9a57c2276f..af62fce95f 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.hpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "datalake_file_system_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class DataLakeFileClientTest : public DataLakeFileSystemClientTest { diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp index 9b6f255704..69a4b77fdb 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp @@ -3,12 +3,12 @@ #include "datalake_file_system_client_test.hpp" -#include - #include #include #include +#include + namespace Azure { namespace Storage { namespace Blobs { namespace Models { bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs); diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.hpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.hpp index 359e38784a..2240b7cdae 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.hpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "datalake_service_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class DataLakeFileSystemClientTest : public DataLakeServiceClientTest { diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.cpp index d6213cef87..0246ca2ef3 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.cpp @@ -3,11 +3,11 @@ #include "datalake_path_client_test.hpp" +#include + #include #include -#include - namespace Azure { namespace Storage { namespace Test { void DataLakePathClientTest::SetUp() diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.hpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.hpp index 004e8aea41..54d94069ec 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.hpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "datalake_file_system_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class DataLakePathClientTest : public DataLakeFileSystemClientTest { diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_sas_test.cpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_sas_test.cpp index 234d54cd09..f477c7f396 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_sas_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_sas_test.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "datalake_file_system_client_test.hpp" + #include #include #include -#include "datalake_file_system_client_test.hpp" - #include namespace Azure { namespace Storage { namespace Test { diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_service_client_test.hpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_service_client_test.hpp index 408e426166..aa88bca13d 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_service_client_test.hpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_service_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "test/ut/test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class DataLakeServiceClientTest : public Azure::Storage::Test::StorageTest { diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp index fe99ed8c9a..887f9c41cf 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp @@ -8,8 +8,6 @@ #pragma once -#include - #include "azure/storage/files/shares/dll_import_export.hpp" #include "azure/storage/files/shares/rest_client.hpp" #include "azure/storage/files/shares/rtti.hpp" @@ -22,3 +20,5 @@ #include "azure/storage/files/shares/share_responses.hpp" #include "azure/storage/files/shares/share_sas_builder.hpp" #include "azure/storage/files/shares/share_service_client.hpp" + +#include diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp index 9223ae3cfc..279e5317d2 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp @@ -6,13 +6,6 @@ // Changes may cause incorrect behavior and will be lost if the code is regenerated. #pragma once -#include -#include -#include -#include -#include -#include - #include #include #include @@ -26,6 +19,13 @@ #include #include +#include +#include +#include +#include +#include +#include + namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace _detail { /** diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp index c832291420..3f5bbb63aa 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp @@ -3,15 +3,15 @@ #pragma once -#include -#include +#include "azure/storage/files/shares/share_options.hpp" +#include "azure/storage/files/shares/share_responses.hpp" +#include "azure/storage/files/shares/share_service_client.hpp" #include #include -#include "azure/storage/files/shares/share_options.hpp" -#include "azure/storage/files/shares/share_responses.hpp" -#include "azure/storage/files/shares/share_service_client.hpp" +#include +#include namespace Azure { namespace Storage { namespace Files { namespace Shares { diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_directory_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_directory_client.hpp index 182a689b8b..cc1a9727c3 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_directory_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_directory_client.hpp @@ -3,16 +3,16 @@ #pragma once -#include -#include +#include "azure/storage/files/shares/share_client.hpp" +#include "azure/storage/files/shares/share_options.hpp" +#include "azure/storage/files/shares/share_responses.hpp" #include #include #include -#include "azure/storage/files/shares/share_client.hpp" -#include "azure/storage/files/shares/share_options.hpp" -#include "azure/storage/files/shares/share_responses.hpp" +#include +#include namespace Azure { namespace Storage { namespace Files { namespace Shares { diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp index ee77fcf8b5..f79a28cad8 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp @@ -3,17 +3,17 @@ #pragma once -#include -#include +#include "azure/storage/files/shares/share_client.hpp" +#include "azure/storage/files/shares/share_directory_client.hpp" +#include "azure/storage/files/shares/share_options.hpp" +#include "azure/storage/files/shares/share_responses.hpp" #include #include #include -#include "azure/storage/files/shares/share_client.hpp" -#include "azure/storage/files/shares/share_directory_client.hpp" -#include "azure/storage/files/shares/share_options.hpp" -#include "azure/storage/files/shares/share_responses.hpp" +#include +#include namespace Azure { namespace Storage { namespace Files { namespace Shares { diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_lease_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_lease_client.hpp index 44b4a19632..1cf2b34414 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_lease_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_lease_client.hpp @@ -3,13 +3,13 @@ #pragma once +#include "azure/storage/files/shares/share_client.hpp" +#include "azure/storage/files/shares/share_file_client.hpp" + #include #include #include -#include "azure/storage/files/shares/share_client.hpp" -#include "azure/storage/files/shares/share_file_client.hpp" - namespace Azure { namespace Storage { namespace Files { namespace Shares { /** diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp index 6f39304ddf..a332519f1e 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp @@ -3,15 +3,15 @@ #pragma once -#include -#include -#include +#include "azure/storage/files/shares/rest_client.hpp" #include #include #include -#include "azure/storage/files/shares/rest_client.hpp" +#include +#include +#include /* cSpell:ignore dacl */ diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp index d2c219caf5..8f28f7af72 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp @@ -3,13 +3,13 @@ #pragma once +#include "azure/storage/files/shares/share_constants.hpp" +#include "azure/storage/files/shares/share_options.hpp" + #include #include #include -#include "azure/storage/files/shares/share_constants.hpp" -#include "azure/storage/files/shares/share_options.hpp" - namespace Azure { namespace Storage { namespace Files { namespace Shares { class ShareServiceClient; diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_sas_builder.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_sas_builder.hpp index e25171a6ac..9817077943 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_sas_builder.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_sas_builder.hpp @@ -3,13 +3,13 @@ #pragma once -#include -#include - #include #include #include +#include +#include + namespace Azure { namespace Storage { namespace Sas { /** diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_service_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_service_client.hpp index 8fca51c3a0..d639b00c27 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_service_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_service_client.hpp @@ -3,15 +3,15 @@ #pragma once -#include -#include +#include "azure/storage/files/shares/share_options.hpp" +#include "azure/storage/files/shares/share_responses.hpp" #include #include #include -#include "azure/storage/files/shares/share_options.hpp" -#include "azure/storage/files/shares/share_responses.hpp" +#include +#include namespace Azure { namespace Storage { namespace Files { namespace Shares { diff --git a/sdk/storage/azure-storage-files-shares/samples/file_share_getting_started.cpp b/sdk/storage/azure-storage-files-shares/samples/file_share_getting_started.cpp index 5a7cf241e6..aad9cb3546 100644 --- a/sdk/storage/azure-storage-files-shares/samples/file_share_getting_started.cpp +++ b/sdk/storage/azure-storage-files-shares/samples/file_share_getting_started.cpp @@ -3,12 +3,12 @@ #include "get_env.hpp" +#include + #include #include #include -#include - std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp index a8881dda0c..865cb0eb62 100644 --- a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp @@ -4,14 +4,6 @@ // // Code generated by Microsoft (R) AutoRest C++ Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -#include - -#include -#include -#include -#include -#include - #include #include #include @@ -26,6 +18,13 @@ #include #include #include +#include + +#include +#include +#include +#include +#include namespace { std::string ListSharesIncludeFlagsToString( diff --git a/sdk/storage/azure-storage-files-shares/src/share_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_client.cpp index d9acab2b17..55db776b67 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_client.cpp @@ -3,6 +3,10 @@ #include "azure/storage/files/shares/share_client.hpp" +#include "azure/storage/files/shares/share_directory_client.hpp" +#include "azure/storage/files/shares/share_file_client.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -13,11 +17,6 @@ #include #include -#include "azure/storage/files/shares/share_directory_client.hpp" -#include "azure/storage/files/shares/share_file_client.hpp" - -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareClient ShareClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp index 08e78d96b5..33398431fa 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp @@ -3,6 +3,9 @@ #include "azure/storage/files/shares/share_directory_client.hpp" +#include "azure/storage/files/shares/share_file_client.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -13,10 +16,6 @@ #include #include -#include "azure/storage/files/shares/share_file_client.hpp" - -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareDirectoryClient ShareDirectoryClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index 6f56d65c67..7748cb24c4 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -3,6 +3,9 @@ #include "azure/storage/files/shares/share_file_client.hpp" +#include "azure/storage/files/shares/share_constants.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -18,10 +21,6 @@ #include #include -#include "azure/storage/files/shares/share_constants.hpp" - -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareFileClient ShareFileClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-shares/src/share_responses.cpp b/sdk/storage/azure-storage-files-shares/src/share_responses.cpp index 4a2e78ccdc..807bf5a2bc 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_responses.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_responses.cpp @@ -3,11 +3,11 @@ #include "azure/storage/files/shares/share_responses.hpp" -#include - #include "azure/storage/files/shares/share_directory_client.hpp" #include "azure/storage/files/shares/share_file_client.hpp" +#include + namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace Models { ShareFileHandleAccessRights::ShareFileHandleAccessRights(const std::string& value) diff --git a/sdk/storage/azure-storage-files-shares/src/share_sas_builder.cpp b/sdk/storage/azure-storage-files-shares/src/share_sas_builder.cpp index 448fba6057..09b561ef7d 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_sas_builder.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_sas_builder.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/storage/files/shares/share_sas_builder.hpp" + #include "azure/storage/files/shares/rest_client.hpp" #include diff --git a/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp index 89340f519a..f0d4309698 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp @@ -3,6 +3,9 @@ #include "azure/storage/files/shares/share_service_client.hpp" +#include "azure/storage/files/shares/share_client.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -13,10 +16,6 @@ #include #include -#include "azure/storage/files/shares/share_client.hpp" - -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareServiceClient ShareServiceClient::CreateFromConnectionString( const std::string& connectionString, diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp index 5a18a1ecc4..a7e42b605d 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp @@ -3,12 +3,12 @@ #include "share_client_test.hpp" +#include + #include #include #include -#include - namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace Models { bool operator==( diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.hpp b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.hpp index c54d80b301..29c5e5c5bb 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.hpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "share_service_client_test.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class FileShareClientTest : public FileShareServiceClientTest { diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.hpp b/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.hpp index 1ab9fdccbb..9742bea8e5 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.hpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.hpp @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "share_client_test.hpp" #include "test/ut/test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class FileShareDirectoryClientTest : public FileShareClientTest { diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_file_attributes_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_file_attributes_test.cpp index 69f2c4eac5..3df20f369e 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_file_attributes_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_file_attributes_test.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "test/ut/test_base.hpp" - #include "azure/storage/files/shares/rest_client.hpp" +#include "test/ut/test_base.hpp" namespace Azure { namespace Storage { namespace Test { diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp index 7b9ec9c1a8..536984b2fd 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp @@ -3,16 +3,16 @@ #include "share_file_client_test.hpp" -#include -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include + namespace Azure { namespace Storage { namespace Test { void FileShareFileClientTest::SetUp() diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.hpp b/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.hpp index 9c0451cb4b..86edcdf8f6 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.hpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.hpp @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "share_directory_client_test.hpp" #include "test/ut/test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class FileShareFileClientTest : public FileShareDirectoryClientTest { diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_sas_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_sas_test.cpp index b121f7defb..b18a8f3e00 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_sas_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_sas_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "share_client_test.hpp" +#include + #include namespace Azure { namespace Storage { namespace Test { diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.hpp b/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.hpp index ab042aabb1..09eb986c7a 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.hpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "test/ut/test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class FileShareServiceClientTest : public Azure::Storage::Test::StorageTest { diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues.hpp index 294cd425c6..7d39e1b8e6 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues.hpp @@ -8,8 +8,6 @@ #pragma once -#include - #include "azure/storage/queues/dll_import_export.hpp" #include "azure/storage/queues/queue_client.hpp" #include "azure/storage/queues/queue_options.hpp" @@ -18,3 +16,5 @@ #include "azure/storage/queues/queue_service_client.hpp" #include "azure/storage/queues/rest_client.hpp" #include "azure/storage/queues/rtti.hpp" + +#include diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_client.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_client.hpp index 2670e66817..98bee74bc3 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_client.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_client.hpp @@ -8,13 +8,13 @@ #pragma once -#include -#include +#include "azure/storage/queues/queue_options.hpp" #include #include -#include "azure/storage/queues/queue_options.hpp" +#include +#include namespace Azure { namespace Storage { namespace Queues { diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_options.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_options.hpp index bb157bb0ae..2e268d0034 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_options.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_options.hpp @@ -8,13 +8,13 @@ #pragma once -#include -#include +#include "azure/storage/queues/rest_client.hpp" #include #include -#include "azure/storage/queues/rest_client.hpp" +#include +#include namespace Azure { namespace Storage { namespace Queues { diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_responses.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_responses.hpp index fab8f91959..25d35a22d6 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_responses.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_responses.hpp @@ -8,13 +8,13 @@ #pragma once -#include -#include +#include "azure/storage/queues/queue_options.hpp" +#include "azure/storage/queues/rest_client.hpp" #include -#include "azure/storage/queues/queue_options.hpp" -#include "azure/storage/queues/rest_client.hpp" +#include +#include namespace Azure { namespace Storage { namespace Queues { diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_sas_builder.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_sas_builder.hpp index b6fcead3e3..6c4e7a98c2 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_sas_builder.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_sas_builder.hpp @@ -8,13 +8,13 @@ #pragma once -#include -#include - #include #include #include +#include +#include + namespace Azure { namespace Storage { namespace Sas { /** diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_service_client.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_service_client.hpp index 8c9685b3ed..c459b223bc 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_service_client.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/queue_service_client.hpp @@ -8,15 +8,15 @@ #pragma once -#include -#include +#include "azure/storage/queues/queue_client.hpp" +#include "azure/storage/queues/queue_options.hpp" +#include "azure/storage/queues/queue_responses.hpp" #include #include -#include "azure/storage/queues/queue_client.hpp" -#include "azure/storage/queues/queue_options.hpp" -#include "azure/storage/queues/queue_responses.hpp" +#include +#include namespace Azure { namespace Storage { namespace Queues { diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/rest_client.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/rest_client.hpp index c7347f8a1b..4d016f256c 100644 --- a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/rest_client.hpp +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/rest_client.hpp @@ -6,12 +6,6 @@ // Changes may cause incorrect behavior and will be lost if the code is regenerated. #pragma once -#include -#include -#include -#include -#include - #include #include #include @@ -21,6 +15,12 @@ #include #include +#include +#include +#include +#include +#include + namespace Azure { namespace Storage { namespace Queues { namespace _detail { /** diff --git a/sdk/storage/azure-storage-queues/samples/queue_encode_message.cpp b/sdk/storage/azure-storage-queues/samples/queue_encode_message.cpp index b4d8904a39..3c16c2de95 100644 --- a/sdk/storage/azure-storage-queues/samples/queue_encode_message.cpp +++ b/sdk/storage/azure-storage-queues/samples/queue_encode_message.cpp @@ -3,14 +3,14 @@ #include "get_env.hpp" +#include +#include + #include #include #include #include -#include -#include - std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-queues/samples/queue_getting_started.cpp b/sdk/storage/azure-storage-queues/samples/queue_getting_started.cpp index d621571a73..00b8311c38 100644 --- a/sdk/storage/azure-storage-queues/samples/queue_getting_started.cpp +++ b/sdk/storage/azure-storage-queues/samples/queue_getting_started.cpp @@ -3,13 +3,13 @@ #include "get_env.hpp" +#include + #include #include #include #include -#include - std::string GetConnectionString() { const static std::string ConnectionString = ""; diff --git a/sdk/storage/azure-storage-queues/src/queue_client.cpp b/sdk/storage/azure-storage-queues/src/queue_client.cpp index c96c8bbcd7..3b55818480 100644 --- a/sdk/storage/azure-storage-queues/src/queue_client.cpp +++ b/sdk/storage/azure-storage-queues/src/queue_client.cpp @@ -3,6 +3,8 @@ #include "azure/storage/queues/queue_client.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -12,8 +14,6 @@ #include #include -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Queues { QueueClient QueueClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-queues/src/queue_service_client.cpp b/sdk/storage/azure-storage-queues/src/queue_service_client.cpp index 882aaba5ab..4ebd5a297b 100644 --- a/sdk/storage/azure-storage-queues/src/queue_service_client.cpp +++ b/sdk/storage/azure-storage-queues/src/queue_service_client.cpp @@ -3,6 +3,8 @@ #include "azure/storage/queues/queue_service_client.hpp" +#include "private/package_version.hpp" + #include #include #include @@ -11,8 +13,6 @@ #include #include -#include "private/package_version.hpp" - namespace Azure { namespace Storage { namespace Queues { QueueServiceClient QueueServiceClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-queues/src/rest_client.cpp b/sdk/storage/azure-storage-queues/src/rest_client.cpp index 495b3fcb0c..9e2d30af8f 100644 --- a/sdk/storage/azure-storage-queues/src/rest_client.cpp +++ b/sdk/storage/azure-storage-queues/src/rest_client.cpp @@ -4,12 +4,6 @@ // // Code generated by Microsoft (R) AutoRest C++ Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -#include - -#include -#include -#include - #include #include #include @@ -21,6 +15,11 @@ #include #include #include +#include + +#include +#include +#include namespace { std::string ListQueuesIncludeFlagsToString( diff --git a/sdk/storage/azure-storage-queues/test/ut/queue_client_messages_test.cpp b/sdk/storage/azure-storage-queues/test/ut/queue_client_messages_test.cpp index 93f8dbb45b..a9a516e5e7 100644 --- a/sdk/storage/azure-storage-queues/test/ut/queue_client_messages_test.cpp +++ b/sdk/storage/azure-storage-queues/test/ut/queue_client_messages_test.cpp @@ -35,13 +35,13 @@ namespace Azure { namespace Storage { namespace Test { const std::string message = "message content."; Queues::EnqueueMessageOptions enqueueOptions; enqueueOptions.VisibilityTimeout = std::chrono::seconds(1); - enqueueOptions.TimeToLive = std::chrono::seconds(2); + enqueueOptions.TimeToLive = std::chrono::seconds(3); auto res = queueClient.EnqueueMessage(message, enqueueOptions).Value; EXPECT_TRUE(queueClient.PeekMessages().Value.Messages.empty()); - TestSleep(std::chrono::milliseconds(1200)); + TestSleep(std::chrono::milliseconds(1100)); EXPECT_FALSE(queueClient.PeekMessages().Value.Messages.empty()); - TestSleep(std::chrono::milliseconds(1200)); + TestSleep(std::chrono::milliseconds(2000)); EXPECT_TRUE(queueClient.PeekMessages().Value.Messages.empty()); enqueueOptions = Queues::EnqueueMessageOptions(); diff --git a/sdk/storage/azure-storage-queues/test/ut/queue_client_test.hpp b/sdk/storage/azure-storage-queues/test/ut/queue_client_test.hpp index f08cfe468b..ca89db3b59 100644 --- a/sdk/storage/azure-storage-queues/test/ut/queue_client_test.hpp +++ b/sdk/storage/azure-storage-queues/test/ut/queue_client_test.hpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "test/ut/test_base.hpp" +#include + namespace Azure { namespace Storage { namespace Test { class QueueClientTest : public Azure::Storage::Test::StorageTest { diff --git a/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp b/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp index 06cfb47e34..08d329f866 100644 --- a/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp +++ b/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "queue_client_test.hpp" +#include + #include namespace Azure { namespace Storage { namespace Test { diff --git a/sdk/storage/azure-storage-queues/test/ut/queue_service_client_test.cpp b/sdk/storage/azure-storage-queues/test/ut/queue_service_client_test.cpp index 1be6664b5a..68c993c39b 100644 --- a/sdk/storage/azure-storage-queues/test/ut/queue_service_client_test.cpp +++ b/sdk/storage/azure-storage-queues/test/ut/queue_service_client_test.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include +#include "test/ut/test_base.hpp" #include #include -#include "test/ut/test_base.hpp" +#include namespace Azure { namespace Storage { namespace Queues { namespace Models { diff --git a/sdk/template/azure-template/inc/azure/template/template_client.hpp b/sdk/template/azure-template/inc/azure/template/template_client.hpp index 6ee21c0f31..651414fb26 100644 --- a/sdk/template/azure-template/inc/azure/template/template_client.hpp +++ b/sdk/template/azure-template/inc/azure/template/template_client.hpp @@ -5,6 +5,7 @@ #include #include + #include namespace Azure { namespace Template { diff --git a/sdk/template/azure-template/test/ut/template_test.cpp b/sdk/template/azure-template/test/ut/template_test.cpp index 5e07d27bd0..da76c9ef8d 100644 --- a/sdk/template/azure-template/test/ut/template_test.cpp +++ b/sdk/template/azure-template/test/ut/template_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include +#include + using namespace Azure::Template; TEST(Template, Basic) { TemplateClient templateClient; }