From a0740e034da73f4b218db9cd832d785a26010f07 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 28 Nov 2022 10:41:34 -0800 Subject: [PATCH 01/11] Add CI pipeline step and script that validates all files in the repo contain ASCII-only bytes and no UTF-8 BOM --- eng/pipelines/templates/jobs/ci.tests.yml | 25 ++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index b5778797e0..ed40096cd3 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -108,7 +108,7 @@ jobs: - template: /eng/pipelines/templates/steps/vcpkg.yml # Validate all the files are formatted correctly according to the - # .clang-format file. This step runs on linux only only and assumes that + # .clang-format file. This step runs on linux only and assumes that # clang-format-11 is installed. - bash: | # Run clang-format recursively on each source and header file within the repo sdk folder. @@ -132,6 +132,29 @@ jobs: displayName: Validate Clang Format condition: and(succeededOrFailed(), eq(variables['CHECK_CLANG_FORMAT'], 1)) + # Validate all the files are saved as ASCII only without a UTF-8 BOM. + - bash: | + # Run grep recursive excluding git folder and known expected files and save a file with results. + grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude "grepResults" . > grepResults + + # Display results to console. + cat grepResults + + # Each result will produce one line, count how many lines were found. + files_with_non_ascii=($(wc -l < grepResults)) + + # Show info about the total files that needs attention. + echo Files found with non-ASCII characters: $files_with_non_ascii + + # Remove the grepResults file. + rm grepResults + + # Return the count. When greater than 0, the step will fail. + exit $files_with_non_ascii + + displayName: Validate Characters are ASCII + condition: and(succeededOrFailed(), eq(variables['CHECK_ASCII_CHARACTERS'], 1)) + - ${{ each artifact in parameters.Artifacts }}: - template: /eng/common/pipelines/templates/steps/set-test-pipeline-version.yml parameters: From e600ed2cfa662a21328ea44289682d1eb72d45be Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 28 Nov 2022 10:45:45 -0800 Subject: [PATCH 02/11] Update platform-matrix.json to turn on CHECK_ASCII_CHARACTERS --- eng/pipelines/templates/stages/platform-matrix.json | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/pipelines/templates/stages/platform-matrix.json b/eng/pipelines/templates/stages/platform-matrix.json index 8c6315f643..7f46ce5326 100644 --- a/eng/pipelines/templates/stages/platform-matrix.json +++ b/eng/pipelines/templates/stages/platform-matrix.json @@ -176,6 +176,7 @@ "BuildSettings": { "clang-11": { "CHECK_CLANG_FORMAT": "1" + "CHECK_ASCII_CHARACTERS": "1" }, "included_release": { "CMAKE_BUILD_TYPE": "Release" From 52714086b064003ab722d10d1243516cc8ca0c10 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 28 Nov 2022 11:13:35 -0800 Subject: [PATCH 03/11] Fix missing comma in json. --- eng/pipelines/templates/stages/platform-matrix.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/stages/platform-matrix.json b/eng/pipelines/templates/stages/platform-matrix.json index 7f46ce5326..412cf6b7f4 100644 --- a/eng/pipelines/templates/stages/platform-matrix.json +++ b/eng/pipelines/templates/stages/platform-matrix.json @@ -175,7 +175,7 @@ }, "BuildSettings": { "clang-11": { - "CHECK_CLANG_FORMAT": "1" + "CHECK_CLANG_FORMAT": "1", "CHECK_ASCII_CHARACTERS": "1" }, "included_release": { From b84f4b139d885392506663cc7a47ff29f251ef39 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 28 Nov 2022 11:24:48 -0800 Subject: [PATCH 04/11] Update indentation in the ci.test.yml for the bash script --- eng/pipelines/templates/jobs/ci.tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index ed40096cd3..100afc1901 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -132,8 +132,8 @@ jobs: displayName: Validate Clang Format condition: and(succeededOrFailed(), eq(variables['CHECK_CLANG_FORMAT'], 1)) - # Validate all the files are saved as ASCII only without a UTF-8 BOM. - - bash: | + # Validate all the files are saved as ASCII only without a UTF-8 BOM. + - bash: | # Run grep recursive excluding git folder and known expected files and save a file with results. grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude "grepResults" . > grepResults From ba207c17f609fdbdc82027846cb76ad45a14a41b Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 28 Nov 2022 13:00:30 -0800 Subject: [PATCH 05/11] Exclude the .github folder and test recording json files. --- eng/pipelines/templates/jobs/ci.tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 100afc1901..71bd67d074 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -135,7 +135,7 @@ jobs: # Validate all the files are saved as ASCII only without a UTF-8 BOM. - bash: | # Run grep recursive excluding git folder and known expected files and save a file with results. - grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude "grepResults" . > grepResults + grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "recordings" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude "grepResults" . > grepResults # Display results to console. cat grepResults From c4aae6722a79121396f6424c256fc35a358ad9a2 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 16 Jan 2023 17:08:46 -0800 Subject: [PATCH 06/11] Remove "recordings" exclusion since it doesn't exist anymore. --- eng/pipelines/templates/jobs/ci.tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 71bd67d074..19e2b9b5ca 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -135,7 +135,7 @@ jobs: # Validate all the files are saved as ASCII only without a UTF-8 BOM. - bash: | # Run grep recursive excluding git folder and known expected files and save a file with results. - grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "recordings" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude "grepResults" . > grepResults + grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude "grepResults" . > grepResults # Display results to console. cat grepResults From ae5083acd744147da29d9b0f1c659d9ee7a5dfac Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 16 Jan 2023 17:56:50 -0800 Subject: [PATCH 07/11] Fixed UTF-8 with BOM and other non-ASCII character issues within the files in the repo. --- CMakeSettings.json | 2 +- doc/LibcurlTransportAdapter.md | 14 +- .../azure-core/test/ut/proxy_tests/readme.md | 4 +- .../administration/settings_client.hpp | 2 +- .../settings_client_options.hpp | 2 +- .../src/keyvault_settings_common_request.cpp | 2 +- .../src/private/administration_constants.hpp | 2 +- .../keyvault_settings_common_request.hpp | 2 +- .../test/ut/settings_client_test.cpp | 2 +- .../CMakeSettings.json | 2 +- .../inc/azure/keyvault/certificates.hpp | 2 +- .../certificates/certificate_client.hpp | 2 +- .../certificate_client_models.hpp | 2 +- .../certificate_client_operations.hpp | 2 +- .../certificate_client_options.hpp | 2 +- .../src/certificate_client.cpp | 990 +++++++++--------- .../src/certificate_client_operations.cpp | 2 +- .../src/certificate_serializers.cpp | 2 +- .../keyvault_certificates_common_request.cpp | 2 +- .../src/private/certificate_constants.hpp | 2 +- .../src/private/certificate_serializers.hpp | 2 +- .../keyvault_certificates_common_request.hpp | 2 +- .../test/ut/certificate_client_base_test.hpp | 2 +- .../test/ut/certificate_client_test.cpp | 2 +- .../src/keyvault_secrets_common_request.cpp | 2 +- .../keyvault_secrets_common_request.hpp | 2 +- .../sample2_backup_restore.cpp | 2 +- .../sample3_delete_recover.cpp | 2 +- .../test/ut/datalake_path_client_test.cpp | 2 +- 29 files changed, 530 insertions(+), 530 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index b242dbc1ae..c2f34101c9 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,4 +1,4 @@ -{ +{ "configurations": [ { "name": "x64-DebugWithTests", diff --git a/doc/LibcurlTransportAdapter.md b/doc/LibcurlTransportAdapter.md index 6aeec04199..75ff1c9456 100644 --- a/doc/LibcurlTransportAdapter.md +++ b/doc/LibcurlTransportAdapter.md @@ -86,7 +86,7 @@ Most of the libcurl handle configuration becomes useless when the handle is chan The most tedious task, while speaking raw HTTP, is reading and parsing responses. As mentioned before, the main purpose of using the poor man's substitute (custom protocol) to re-implement HTTP (even though libcurl provides HTTP support natively) is to enable an Azure SDK client to start a download operation and let customers to decide when to pull chunks of data from the response (directly from the network socket, without any intermediate buffers or using callback functions). -An HTTP request is nothing but a string with a specific format, it has special text delimiters to distinguish between the request line, headers and body. As soon as the server receives and parses the request, it would trigger an operation and eventually produce a response. The response needs to be HTTP formatted using text delimiters to indicate where the headers section starts and where it ends. Then the server will start sending small parts of it. On the client side, calling _curl_easy_recv()_ will get any bytes that have arrived. As soon as the function pulls the bytes from the socket, the socket will receive more data that will be written on top of the previous data. The function _curl_easy_recv()_ is a way to tell the OS, _“Hey, I got this data, you can write on top of it now"_. +An HTTP request is nothing but a string with a specific format, it has special text delimiters to distinguish between the request line, headers and body. As soon as the server receives and parses the request, it would trigger an operation and eventually produce a response. The response needs to be HTTP formatted using text delimiters to indicate where the headers section starts and where it ends. Then the server will start sending small parts of it. On the client side, calling _curl_easy_recv()_ will get any bytes that have arrived. As soon as the function pulls the bytes from the socket, the socket will receive more data that will be written on top of the previous data. The function _curl_easy_recv()_ is a way to tell the OS, _"Hey, I got this data, you can write on top of it now"_. Based on how _curl_easy_recv()_ behaves, and what the Azure SDK client is expecting, the libculTransportAdapter must keep calling _curl_easy_recv()_ until it finds the text delimiter that indicates the start of the HTTP body. When calling _curl_easy_recv()_, one of its input parameters is how many bytes to read from the socket. However, if there are not as many bytes in the socket at requested, the function will just get as much as it can. For example, if 1kb is requested to be pulled from the socket, the actual returned bytes might be 1kb (if that amount was ready in the socket) or less (if there were only 1023 bytes or less in the socket). This brings an interesting design question, how many bytes should the transport adapter request on every call to _curl_easy_recv()_? @@ -121,14 +121,14 @@ There are a few more variables to take into consideration. The HTTP protocol def Calling _curl_easy_send()_ is a similar experience. It takes an input parameter which defines how much data to put into the network socket, and it returns how many bytes it was able to send. The LTA (libcurl transport adapter) implements an upload operation by calling _curl_easy_send()_ sequentially until all bytes are sent. The hardest thing to deal with, during an upload operation, is the speed that it takes the operating system to send bytes through the network. The OS sends bytes to the server and lets the socket in a state where it can take more data to be sent. The call to _curl_easy_send()_ returns as soon as the data is written to the socket, so, immediately calling the function again to send more data will most likely cause function to find the socket busy, because the OS is performing the I/O operation. This is another unfortunate side effect of using libcurl with custom protocol. By using the proper way, libcurl abstracts away all the operations between the application and the operating system sockets. -When working on Unix systems (Linux and macOS), the LTA needs to import `sys/socket.h` . And when running for Windows, `winsock2h.h` is imported. These headers are used to check for socket updates, especially to poll for state change. That’s how the LTA knows when a socket is ready to be used. +When working on Unix systems (Linux and macOS), the LTA needs to import `sys/socket.h` . And when running for Windows, `winsock2h.h` is imported. These headers are used to check for socket updates, especially to poll for state change. That's how the LTA knows when a socket is ready to be used. On the eyes of a customer, the LTA should provide the same level of experience, regardless of what libcurl mode it uses. If it is using custom protocol or proper way to consume libcurl, there should be no distinguish. This brings a complex challenge for the LTA. In terms of maintainability, libcurl will fix and maintain the code to support HTTP only for the proper mode. By using custom-protocol, LTA is manually implementing and supporting things that might have been already fixed in the past by the libcurl community. An example of a scenario like this can be found within the LTA Windows implementation, where _setsockopt()_ method must be called before writing to a socket to ensure the uploading chunk size of data is not reduced by Windows. The LTA goes as deep as the TCP implementation details to provide this patch. The side effect if this patch is not applied makes the LTA complete an upload operation __four times slower__ than using libcurl proper mode. And the adventure for discovering this patch requires running the proper mode, step by step (debugger), identifying the call stack deltas against the custom protocol mode. Or browsing the git commit history from libcurl, looking for tags like windows, performance, socket and/or uploading data. Trying to isolate related changes. ### Connection pool -There’s yet one more unfortunate detail for using libcurl with custom protocol, and that’s supporting the HTTP `keep alive` feature. Keep alive feature provides a huge performance improvement when using a secured connection (TLS). When a connection uses TLS to secure the data, there’s a time-consuming process where the server and the client both authenticate themselves and interchange valid certificates. This process starts with a handshake and completes when both server and client agree on how to encode and decode messages between them. Depending on the network speed, the entire process could take up to two seconds. If the request and response interchanged in the secured channel is just a few bytes, securing the connection could take more time than the actual data transferring. The keep alive feature is a mechanism to re-use a connection channel. In the case of a secured channel, an application can use the same connection to send requests, one after another, saving time and resources of securing a new connection for each request. +There's yet one more unfortunate detail for using libcurl with custom protocol, and that's supporting the HTTP `keep alive` feature. Keep alive feature provides a huge performance improvement when using a secured connection (TLS). When a connection uses TLS to secure the data, there's a time-consuming process where the server and the client both authenticate themselves and interchange valid certificates. This process starts with a handshake and completes when both server and client agree on how to encode and decode messages between them. Depending on the network speed, the entire process could take up to two seconds. If the request and response interchanged in the secured channel is just a few bytes, securing the connection could take more time than the actual data transferring. The keep alive feature is a mechanism to re-use a connection channel. In the case of a secured channel, an application can use the same connection to send requests, one after another, saving time and resources of securing a new connection for each request. -Libcurl can automatically support the keep alive feature when using the proper mode. When _curl_easy_init(handle)_ is called, libcurl first check if there is already an open connection for the request described in the handle. Once the request is performed, libcurl will keep the connection open for some time in case there’s a new request for the same server. Nevertheless, if a libcurl handle is configured for custom protocol, libcurl does not provide a keep alive feature. +Libcurl can automatically support the keep alive feature when using the proper mode. When _curl_easy_init(handle)_ is called, libcurl first check if there is already an open connection for the request described in the handle. Once the request is performed, libcurl will keep the connection open for some time in case there's a new request for the same server. Nevertheless, if a libcurl handle is configured for custom protocol, libcurl does not provide a keep alive feature. The keep alive feature for libcurl is provided by the Azure SDK library directly. The library provides three main components to ensure keep alive connections for libcurl. The first one is the libcurl connection class, which is a wrapper for a libcurl handle. The second component is the pool of libcurl connections, which is a collection where connections can go in and out to be re-used. And the last component is a pool cleaner agent, which removes old connections from the pool. More details about each component are in the next paragraphs. @@ -141,11 +141,11 @@ The libcurl connection is typically wrapped within another container. In the cas #### Connection Pool -The connection pool is a global and static singleton object. The pool provides an API to request a connection. Based on the set of options requested, the pool will search if there´s a connection which is not expired and was created with the same options. If one connection is found, it is moved out of the pool. When a libcurl connection owner (like the body stream from the LTA) goes out of scope, its destructor asks the pool to move the connection back to the pool. The connection needs to satisfy some requirements before it comes back to the pool, such as: +The connection pool is a global and static singleton object. The pool provides an API to request a connection. Based on the set of options requested, the pool will search if there's a connection which is not expired and was created with the same options. If one connection is found, it is moved out of the pool. When a libcurl connection owner (like the body stream from the LTA) goes out of scope, its destructor asks the pool to move the connection back to the pool. The connection needs to satisfy some requirements before it comes back to the pool, such as: - The last message from the server is not an error message. A server would typically close a connection when the HTTP status code returned to the client is not within the two hundred codes. - The connection is in a state where there are still bytes from the server response to be read from the socket. A connection should read an entire response before it can send a new request. -- When the connection has been inactive and out of the pool for a long time, most likely it’s shut down and it won’t be moved back to the pool. +- When the connection has been inactive and out of the pool for a long time, most likely it's shut down and it won't be moved back to the pool. The connection pool contains a `mutex` for moving connections in and out of the pool. Multiple threads can request or return a libcurl connection at the same time. The pool uses a Last-in-First-out mechanism to move connections, making it certain to re-use the connections with less time seating in the pool. @@ -156,5 +156,5 @@ The connection pool is responsible for creating and initializing a libcurl handl Whenever a libcurl connection is returned to the pool, the Pool Cleaner Agent (PCA) is started (if it is not already running). PCA is a thread which runs every 90 seconds while there are connections seating in the pool. Every time PCA runs, it checks connections, starting from the oldest connection returned to the pool. Since the connection pool works as one stack, the oldest connection is at the bottom. PCA will remove the connections which have expired. As soon as it finds a non-expired connection, PCA switch to inspect another index, until all indexes are reviewed. -PCA goes to sleep for 90 seconds only if a non-expired connection was found. If all connections were expired and removed, PCA is terminated and won’t be started again until a connection is moved to the pool. +PCA goes to sleep for 90 seconds only if a non-expired connection was found. If all connections were expired and removed, PCA is terminated and won't be started again until a connection is moved to the pool. PCA prevents applications from keeping expired connections objects in memory. A common scenario where the importance of the PCA can be observed is if the application needs to create a hundred connections and use them all at the same time. Eventually, all the connections would return to the pool and if the Azure SDK client is not used anymore by the application, there would be a hundred expired connections in heap memory until the application ends. diff --git a/sdk/core/azure-core/test/ut/proxy_tests/readme.md b/sdk/core/azure-core/test/ut/proxy_tests/readme.md index 0e23b8764b..d8f2eca10a 100644 --- a/sdk/core/azure-core/test/ut/proxy_tests/readme.md +++ b/sdk/core/azure-core/test/ut/proxy_tests/readme.md @@ -203,7 +203,7 @@ RawContent : HTTP/1.1 200 OK Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: * Content-Length: 964 - Content-Type: application/js… + Content-Type: application/json Headers : {[Date, System.String[]], [Server, System.String[]], [Access-Control-Allow-Credentials, System.String[]], [Access-Control-Allow-Origin, System.String[]]...} Images : {} @@ -530,7 +530,7 @@ RawContent : HTTP/1.1 200 OK Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: * Content-Length: 967 - Content-Type: application/js� + Content-Type: application/json Headers : {[Date, System.String[]], [Server, System.String[]], [Access-Control-Allow-Credentials, System.String[]], [Access-Control-Allow-Origin, System.String[]]...} Images : {} 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 e6226e7456..d881929a71 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 9544e705a6..21ac0e7caa 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 b78716d0ea..41b161fd29 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include "private/keyvault_settings_common_request.hpp" diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/private/administration_constants.hpp b/sdk/keyvault/azure-security-keyvault-administration/src/private/administration_constants.hpp index 6c028f6368..70b0ba244f 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/private/administration_constants.hpp +++ b/sdk/keyvault/azure-security-keyvault-administration/src/private/administration_constants.hpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** diff --git a/sdk/keyvault/azure-security-keyvault-administration/src/private/keyvault_settings_common_request.hpp b/sdk/keyvault/azure-security-keyvault-administration/src/private/keyvault_settings_common_request.hpp index 4adbcc6601..8c95477225 100644 --- a/sdk/keyvault/azure-security-keyvault-administration/src/private/keyvault_settings_common_request.hpp +++ b/sdk/keyvault/azure-security-keyvault-administration/src/private/keyvault_settings_common_request.hpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 96ca975f9d..304896114c 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,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include diff --git a/sdk/keyvault/azure-security-keyvault-certificates/CMakeSettings.json b/sdk/keyvault/azure-security-keyvault-certificates/CMakeSettings.json index 8d56896fe0..6d213fa11f 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/CMakeSettings.json +++ b/sdk/keyvault/azure-security-keyvault-certificates/CMakeSettings.json @@ -1,4 +1,4 @@ -{ +{ "configurations": [ { "name": "x64-DebugWithTests", 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 ef41801aaf..0ad17566ea 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 a68be07a7e..3999b8ab1c 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 90ca697118..289aa0c344 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** diff --git a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_operations.hpp b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_operations.hpp index b54e9e6170..482a4fe254 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_operations.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/certificate_client_operations.hpp @@ -1,4 +1,4 @@ - + // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT 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 54465aa921..6d5fcc69fd 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 2158bba2d4..85aa863db6 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_client.cpp @@ -1,495 +1,495 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include "azure/keyvault/certificates/certificate_client.hpp" - -#include "azure/keyvault/shared/keyvault_shared.hpp" -#include "private/certificate_constants.hpp" -#include "private/certificate_serializers.hpp" -#include "private/keyvault_certificates_common_request.hpp" -#include "private/package_version.hpp" -#include - -#include -#include -#include -#include - -#include -#include -#include - -using namespace Azure::Security::KeyVault::Certificates; -using namespace Azure::Security::KeyVault::Certificates::_detail; -using namespace Azure; -using namespace Azure::Core; -using namespace Azure::Core::Http; -using namespace Azure::Core::Http::Policies; -using namespace Azure::Core::Http::Policies::_internal; -using namespace Azure::Core::Http::_internal; -using namespace Azure::Security::KeyVault::_detail; - -namespace { -} // namespace - -std::unique_ptr CertificateClient::SendRequest( - Azure::Core::Http::Request& request, - Azure::Core::Context const& context) const -{ - return KeyVaultCertificatesCommonRequest::SendRequest(*m_pipeline, request, context); -} - -Request CertificateClient::CreateRequest( - HttpMethod method, - std::vector const& path, - Azure::Core::IO::BodyStream* content) const -{ - return KeyVaultCertificatesCommonRequest::CreateRequest( - m_vaultUrl, m_apiVersion, method, path, content); -} - -Request CertificateClient::ContinuationTokenRequest( - std::vector const& path, - const Azure::Nullable& NextPageToken) const -{ - if (NextPageToken) - { - // Using a continuation token requires to send the request to the continuation token URL instead - // of the default URL which is used only for the first page. - Azure::Core::Url nextPageUrl(NextPageToken.Value()); - return Request(HttpMethod::Get, nextPageUrl); - } - return CreateRequest(HttpMethod::Get, path); -} - -CertificateClient::CertificateClient( - std::string const& vaultUrl, - std::shared_ptr credential, - CertificateClientOptions options) - : m_vaultUrl(vaultUrl), m_apiVersion(options.ApiVersion) -{ - auto apiVersion = options.ApiVersion; - - std::vector> perRetrypolicies; - { - Azure::Core::Credentials::TokenRequestContext tokenContext; - tokenContext.Scopes = {_internal::UrlScope::GetScopeFromUrl(m_vaultUrl)}; - - perRetrypolicies.emplace_back( - std::make_unique(credential, std::move(tokenContext))); - } - std::vector> perCallpolicies; - - m_pipeline = std::make_shared( - options, - KeyVaultServicePackageName, - PackageVersion::ToString(), - std::move(perRetrypolicies), - std::move(perCallpolicies)); -} - -Response CertificateClient::GetCertificate( - std::string const& certificateName, - Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, certificateName}); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = _detail::KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Response CertificateClient::GetCertificateVersion( - std::string const& certificateName, - std::string const& certificateVersion, - Context const& context) const -{ - // Request with no payload - std::vector path{{CertificatesPath, certificateName, certificateVersion}}; - - auto request = CreateRequest(HttpMethod::Get, std::move(path)); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = _detail::KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -CreateCertificateOperation CertificateClient::StartCreateCertificate( - std::string const& certificateName, - CertificateCreateOptions const& options, - Azure::Core::Context const& context) const -{ - auto payload = CertificateCreateOptionsSerializer::Serialize(options); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request = CreateRequest( - HttpMethod::Post, - {CertificatesPath, certificateName, CertificatesCreatePath}, - &payloadStream); - - auto rawResponse = SendRequest(request, context); - auto value = _detail::CertificateOperationSerializer::Deserialize(*rawResponse); - - return CreateCertificateOperation(value.Name, std::make_shared(*this)); -} - -Response CertificateClient::GetDeletedCertificate( - std::string const& certificateName, - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Get, {DeletedCertificatesPath, certificateName}); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = DeletedCertificateSerializer::Deserialize(certificateName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::GetIssuer( - std::string const& issuerName, - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, IssuersPath, issuerName}); - auto rawResponse = SendRequest(request, context); - - auto value = CertificateIssuerSerializer::Deserialize(issuerName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::DeleteIssuer( - std::string const& issuerName, - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Delete, {CertificatesPath, IssuersPath, issuerName}); - auto rawResponse = SendRequest(request, context); - - auto value = CertificateIssuerSerializer::Deserialize(issuerName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::CreateIssuer( - std::string const& issuerName, - CertificateIssuer const& certificateIssuer, - Azure::Core::Context const& context) const -{ - auto payload = CertificateIssuerSerializer::Serialize(certificateIssuer); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request - = CreateRequest(HttpMethod::Put, {CertificatesPath, IssuersPath, issuerName}, &payloadStream); - - auto rawResponse = SendRequest(request, context); - auto value = CertificateIssuerSerializer::Deserialize(issuerName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::UpdateIssuer( - std::string const& issuerName, - CertificateIssuer const& certificateIssuer, - Azure::Core::Context const& context) const -{ - auto payload = CertificateIssuerSerializer::Serialize(certificateIssuer); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request = CreateRequest( - HttpMethod::Patch, {CertificatesPath, IssuersPath, issuerName}, &payloadStream); - - auto rawResponse = SendRequest(request, context); - auto value = CertificateIssuerSerializer::Deserialize(issuerName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Response CertificateClient::GetContacts( - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, ContactsPath}); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = CertificateContactsSerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Response CertificateClient::DeleteContacts( - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Delete, {CertificatesPath, ContactsPath}); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = CertificateContactsSerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Response CertificateClient::SetContacts( - std::vector const& contacts, - Azure::Core::Context const& context) const -{ - auto payload = CertificateContactsSerializer::Serialize(contacts); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request = CreateRequest(HttpMethod::Put, {CertificatesPath, ContactsPath}, &payloadStream); - - auto rawResponse = SendRequest(request, context); - auto value = CertificateContactsSerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::GetPendingCertificateOperation( - std::string const& certificateName, - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, certificateName, PendingPath}); - auto rawResponse = SendRequest(request, context); - - auto value = CertificateOperationSerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response -CertificateClient::CancelPendingCertificateOperation( - std::string const& certificateName, - Azure::Core::Context const& context) const -{ - CertificateOperationUpdateOptions option; - option.CancelationRequested = true; - auto payload = CertificateOperationUpdateOptionSerializer::Serialize(option); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request = CreateRequest( - HttpMethod::Patch, {CertificatesPath, certificateName, PendingPath}, &payloadStream); - auto rawResponse = SendRequest(request, context); - - auto value = CertificateOperationSerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response -CertificateClient::DeletePendingCertificateOperation( - std::string const& certificateName, - Azure::Core::Context const& context) const -{ - auto request - = CreateRequest(HttpMethod::Delete, {CertificatesPath, certificateName, PendingPath}); - auto rawResponse = SendRequest(request, context); - - auto value = CertificateOperationSerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Response CertificateClient::PurgeDeletedCertificate( - std::string const& certificateName, - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Delete, {DeletedCertificatesPath, certificateName}); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - PurgedCertificate value; - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -DeleteCertificateOperation CertificateClient::StartDeleteCertificate( - std::string const& certificateName, - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Delete, {CertificatesPath, certificateName}); - - auto rawResponse = SendRequest(request, context); - auto value = DeletedCertificate(); - value.Properties.Name = certificateName; - auto responseT = Azure::Response(std::move(value), std::move(rawResponse)); - return DeleteCertificateOperation( - std::make_shared(*this), std::move(responseT)); -} - -RecoverDeletedCertificateOperation CertificateClient::StartRecoverDeletedCertificate( - std::string const& certificateName, - Azure::Core::Context const& context) const -{ - auto request - = CreateRequest(HttpMethod::Post, {DeletedCertificatesPath, certificateName, RecoverPath}); - - auto rawResponse = SendRequest(request, context); - auto value = KeyVaultCertificateWithPolicy(); - value.Properties.Name = certificateName; - auto responseT - = Azure::Response(std::move(value), std::move(rawResponse)); - return RecoverDeletedCertificateOperation( - std::make_shared(*this), std::move(responseT)); -} -Azure::Response CertificateClient::GetCertificatePolicy( - std::string const& certificateName, - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, certificateName, PolicyPath}); - auto rawResponse = SendRequest(request, context); - - auto value = CertificatePolicySerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::UpdateCertificatePolicy( - std::string const& certificateName, - CertificatePolicy const& certificatePolicy, - Azure::Core::Context const& context) const -{ - auto payload = CertificatePolicySerializer::Serialize(certificatePolicy); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - auto request = CreateRequest( - HttpMethod::Patch, {CertificatesPath, certificateName, PolicyPath}, &payloadStream); - auto rawResponse = SendRequest(request, context); - - auto value = CertificatePolicySerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::BackupCertificate( - std::string certificateName, - Azure::Core::Context const& context) const -{ - auto request = CreateRequest(HttpMethod::Post, {CertificatesPath, certificateName, BackupPath}); - auto rawResponse = SendRequest(request, context); - - auto value = BackupCertificateSerializer::Deserialize(*rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::RestoreCertificateBackup( - std::vector const& certificateBackup, - Azure::Core::Context const& context) const -{ - auto payload = BackupCertificateSerializer::Serialize(certificateBackup); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request = CreateRequest(HttpMethod::Post, {CertificatesPath, RestorePath}, &payloadStream); - - auto rawResponse = SendRequest(request, context); - auto value = KeyVaultCertificateSerializer::Deserialize("", *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} -CertificatePropertiesPagedResponse CertificateClient::GetPropertiesOfCertificates( - GetPropertiesOfCertificatesOptions const& options, - Azure::Core::Context const& context) const -{ - (void)options; - // Request and settings - auto request = ContinuationTokenRequest({CertificatesPath}, options.NextPageToken); - if (options.IncludePending) - { - request.GetUrl().AppendQueryParameter( - IncludePendingQuery, options.IncludePending.Value() ? TrueQueryValue : FalseQueryValue); - } - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = CertificatePropertiesPagedResponseSerializer::Deserialize(*rawResponse); - return CertificatePropertiesPagedResponse( - std::move(value), std::move(rawResponse), std::make_unique(*this)); -} - -CertificatePropertiesPagedResponse CertificateClient::GetPropertiesOfCertificateVersions( - std::string const& certificateName, - GetPropertiesOfCertificateVersionsOptions const& options, - Azure::Core::Context const& context) const -{ - // Request and settings - auto request = ContinuationTokenRequest( - {CertificatesPath, certificateName, VersionsPath}, options.NextPageToken); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = CertificatePropertiesPagedResponseSerializer::Deserialize(*rawResponse); - return CertificatePropertiesPagedResponse( - std::move(value), std::move(rawResponse), std::make_unique(*this)); -} - -IssuerPropertiesPagedResponse CertificateClient::GetPropertiesOfIssuers( - GetPropertiesOfIssuersOptions const& options, - Azure::Core::Context const& context) const -{ - // Request and settings - auto request = ContinuationTokenRequest({CertificatesPath, IssuersPath}, options.NextPageToken); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = IssuerPropertiesPagedResponseSerializer::Deserialize(*rawResponse); - return IssuerPropertiesPagedResponse( - std::move(value), std::move(rawResponse), std::make_unique(*this)); -} - -DeletedCertificatesPagedResponse CertificateClient::GetDeletedCertificates( - GetDeletedCertificatesOptions const& options, - Azure::Core::Context const& context) const -{ - // Request and settings - auto request = ContinuationTokenRequest({DeletedCertificatesPath}, options.NextPageToken); - - // Send and parse respone - auto rawResponse = SendRequest(request, context); - auto value = DeletedCertificatesPagedResponseSerializer::Deserialize(*rawResponse); - return DeletedCertificatesPagedResponse( - std::move(value), std::move(rawResponse), std::make_unique(*this)); -} - -Azure::Response CertificateClient::ImportCertificate( - std::string const& certificateName, - ImportCertificateOptions const& options, - Azure::Core::Context const& context) const -{ - auto payload = ImportCertificateOptionsSerializer::Serialize(options); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request = CreateRequest( - HttpMethod::Post, {CertificatesPath, certificateName, ImportPath}, &payloadStream); - - auto rawResponse = SendRequest(request, context); - auto value = KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::MergeCertificate( - std::string const& certificateName, - MergeCertificateOptions const& options, - Azure::Core::Context const& context) const -{ - auto payload = MergeCertificateOptionsSerializer::Serialize(options); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request = CreateRequest( - HttpMethod::Post, - {CertificatesPath, certificateName, PendingPath, MergePath}, - &payloadStream); - - auto rawResponse = SendRequest(request, context); - auto value = KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} - -Azure::Response CertificateClient::UpdateCertificateProperties( - std::string const& certificateName, - std::string const& certificateVersion, - CertificateProperties const& certificateProperties, - Azure::Core::Context const& context) const -{ - auto payload = CertificateUpdateOptionsSerializer::Serialize(certificateProperties); - Azure::Core::IO::MemoryBodyStream payloadStream( - reinterpret_cast(payload.data()), payload.size()); - - auto request = CreateRequest( - HttpMethod::Patch, {CertificatesPath, certificateName, certificateVersion}, &payloadStream); - - auto rawResponse = SendRequest(request, context); - auto value = KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); - return Azure::Response(std::move(value), std::move(rawResponse)); -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "azure/keyvault/certificates/certificate_client.hpp" + +#include "azure/keyvault/shared/keyvault_shared.hpp" +#include "private/certificate_constants.hpp" +#include "private/certificate_serializers.hpp" +#include "private/keyvault_certificates_common_request.hpp" +#include "private/package_version.hpp" +#include + +#include +#include +#include +#include + +#include +#include +#include + +using namespace Azure::Security::KeyVault::Certificates; +using namespace Azure::Security::KeyVault::Certificates::_detail; +using namespace Azure; +using namespace Azure::Core; +using namespace Azure::Core::Http; +using namespace Azure::Core::Http::Policies; +using namespace Azure::Core::Http::Policies::_internal; +using namespace Azure::Core::Http::_internal; +using namespace Azure::Security::KeyVault::_detail; + +namespace { +} // namespace + +std::unique_ptr CertificateClient::SendRequest( + Azure::Core::Http::Request& request, + Azure::Core::Context const& context) const +{ + return KeyVaultCertificatesCommonRequest::SendRequest(*m_pipeline, request, context); +} + +Request CertificateClient::CreateRequest( + HttpMethod method, + std::vector const& path, + Azure::Core::IO::BodyStream* content) const +{ + return KeyVaultCertificatesCommonRequest::CreateRequest( + m_vaultUrl, m_apiVersion, method, path, content); +} + +Request CertificateClient::ContinuationTokenRequest( + std::vector const& path, + const Azure::Nullable& NextPageToken) const +{ + if (NextPageToken) + { + // Using a continuation token requires to send the request to the continuation token URL instead + // of the default URL which is used only for the first page. + Azure::Core::Url nextPageUrl(NextPageToken.Value()); + return Request(HttpMethod::Get, nextPageUrl); + } + return CreateRequest(HttpMethod::Get, path); +} + +CertificateClient::CertificateClient( + std::string const& vaultUrl, + std::shared_ptr credential, + CertificateClientOptions options) + : m_vaultUrl(vaultUrl), m_apiVersion(options.ApiVersion) +{ + auto apiVersion = options.ApiVersion; + + std::vector> perRetrypolicies; + { + Azure::Core::Credentials::TokenRequestContext tokenContext; + tokenContext.Scopes = {_internal::UrlScope::GetScopeFromUrl(m_vaultUrl)}; + + perRetrypolicies.emplace_back( + std::make_unique(credential, std::move(tokenContext))); + } + std::vector> perCallpolicies; + + m_pipeline = std::make_shared( + options, + KeyVaultServicePackageName, + PackageVersion::ToString(), + std::move(perRetrypolicies), + std::move(perCallpolicies)); +} + +Response CertificateClient::GetCertificate( + std::string const& certificateName, + Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, certificateName}); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = _detail::KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Response CertificateClient::GetCertificateVersion( + std::string const& certificateName, + std::string const& certificateVersion, + Context const& context) const +{ + // Request with no payload + std::vector path{{CertificatesPath, certificateName, certificateVersion}}; + + auto request = CreateRequest(HttpMethod::Get, std::move(path)); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = _detail::KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +CreateCertificateOperation CertificateClient::StartCreateCertificate( + std::string const& certificateName, + CertificateCreateOptions const& options, + Azure::Core::Context const& context) const +{ + auto payload = CertificateCreateOptionsSerializer::Serialize(options); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request = CreateRequest( + HttpMethod::Post, + {CertificatesPath, certificateName, CertificatesCreatePath}, + &payloadStream); + + auto rawResponse = SendRequest(request, context); + auto value = _detail::CertificateOperationSerializer::Deserialize(*rawResponse); + + return CreateCertificateOperation(value.Name, std::make_shared(*this)); +} + +Response CertificateClient::GetDeletedCertificate( + std::string const& certificateName, + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Get, {DeletedCertificatesPath, certificateName}); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = DeletedCertificateSerializer::Deserialize(certificateName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::GetIssuer( + std::string const& issuerName, + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, IssuersPath, issuerName}); + auto rawResponse = SendRequest(request, context); + + auto value = CertificateIssuerSerializer::Deserialize(issuerName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::DeleteIssuer( + std::string const& issuerName, + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Delete, {CertificatesPath, IssuersPath, issuerName}); + auto rawResponse = SendRequest(request, context); + + auto value = CertificateIssuerSerializer::Deserialize(issuerName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::CreateIssuer( + std::string const& issuerName, + CertificateIssuer const& certificateIssuer, + Azure::Core::Context const& context) const +{ + auto payload = CertificateIssuerSerializer::Serialize(certificateIssuer); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request + = CreateRequest(HttpMethod::Put, {CertificatesPath, IssuersPath, issuerName}, &payloadStream); + + auto rawResponse = SendRequest(request, context); + auto value = CertificateIssuerSerializer::Deserialize(issuerName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::UpdateIssuer( + std::string const& issuerName, + CertificateIssuer const& certificateIssuer, + Azure::Core::Context const& context) const +{ + auto payload = CertificateIssuerSerializer::Serialize(certificateIssuer); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request = CreateRequest( + HttpMethod::Patch, {CertificatesPath, IssuersPath, issuerName}, &payloadStream); + + auto rawResponse = SendRequest(request, context); + auto value = CertificateIssuerSerializer::Deserialize(issuerName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Response CertificateClient::GetContacts( + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, ContactsPath}); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = CertificateContactsSerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Response CertificateClient::DeleteContacts( + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Delete, {CertificatesPath, ContactsPath}); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = CertificateContactsSerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Response CertificateClient::SetContacts( + std::vector const& contacts, + Azure::Core::Context const& context) const +{ + auto payload = CertificateContactsSerializer::Serialize(contacts); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request = CreateRequest(HttpMethod::Put, {CertificatesPath, ContactsPath}, &payloadStream); + + auto rawResponse = SendRequest(request, context); + auto value = CertificateContactsSerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::GetPendingCertificateOperation( + std::string const& certificateName, + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, certificateName, PendingPath}); + auto rawResponse = SendRequest(request, context); + + auto value = CertificateOperationSerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response +CertificateClient::CancelPendingCertificateOperation( + std::string const& certificateName, + Azure::Core::Context const& context) const +{ + CertificateOperationUpdateOptions option; + option.CancelationRequested = true; + auto payload = CertificateOperationUpdateOptionSerializer::Serialize(option); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request = CreateRequest( + HttpMethod::Patch, {CertificatesPath, certificateName, PendingPath}, &payloadStream); + auto rawResponse = SendRequest(request, context); + + auto value = CertificateOperationSerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response +CertificateClient::DeletePendingCertificateOperation( + std::string const& certificateName, + Azure::Core::Context const& context) const +{ + auto request + = CreateRequest(HttpMethod::Delete, {CertificatesPath, certificateName, PendingPath}); + auto rawResponse = SendRequest(request, context); + + auto value = CertificateOperationSerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Response CertificateClient::PurgeDeletedCertificate( + std::string const& certificateName, + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Delete, {DeletedCertificatesPath, certificateName}); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + PurgedCertificate value; + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +DeleteCertificateOperation CertificateClient::StartDeleteCertificate( + std::string const& certificateName, + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Delete, {CertificatesPath, certificateName}); + + auto rawResponse = SendRequest(request, context); + auto value = DeletedCertificate(); + value.Properties.Name = certificateName; + auto responseT = Azure::Response(std::move(value), std::move(rawResponse)); + return DeleteCertificateOperation( + std::make_shared(*this), std::move(responseT)); +} + +RecoverDeletedCertificateOperation CertificateClient::StartRecoverDeletedCertificate( + std::string const& certificateName, + Azure::Core::Context const& context) const +{ + auto request + = CreateRequest(HttpMethod::Post, {DeletedCertificatesPath, certificateName, RecoverPath}); + + auto rawResponse = SendRequest(request, context); + auto value = KeyVaultCertificateWithPolicy(); + value.Properties.Name = certificateName; + auto responseT + = Azure::Response(std::move(value), std::move(rawResponse)); + return RecoverDeletedCertificateOperation( + std::make_shared(*this), std::move(responseT)); +} +Azure::Response CertificateClient::GetCertificatePolicy( + std::string const& certificateName, + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, certificateName, PolicyPath}); + auto rawResponse = SendRequest(request, context); + + auto value = CertificatePolicySerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::UpdateCertificatePolicy( + std::string const& certificateName, + CertificatePolicy const& certificatePolicy, + Azure::Core::Context const& context) const +{ + auto payload = CertificatePolicySerializer::Serialize(certificatePolicy); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + auto request = CreateRequest( + HttpMethod::Patch, {CertificatesPath, certificateName, PolicyPath}, &payloadStream); + auto rawResponse = SendRequest(request, context); + + auto value = CertificatePolicySerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::BackupCertificate( + std::string certificateName, + Azure::Core::Context const& context) const +{ + auto request = CreateRequest(HttpMethod::Post, {CertificatesPath, certificateName, BackupPath}); + auto rawResponse = SendRequest(request, context); + + auto value = BackupCertificateSerializer::Deserialize(*rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::RestoreCertificateBackup( + std::vector const& certificateBackup, + Azure::Core::Context const& context) const +{ + auto payload = BackupCertificateSerializer::Serialize(certificateBackup); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request = CreateRequest(HttpMethod::Post, {CertificatesPath, RestorePath}, &payloadStream); + + auto rawResponse = SendRequest(request, context); + auto value = KeyVaultCertificateSerializer::Deserialize("", *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} +CertificatePropertiesPagedResponse CertificateClient::GetPropertiesOfCertificates( + GetPropertiesOfCertificatesOptions const& options, + Azure::Core::Context const& context) const +{ + (void)options; + // Request and settings + auto request = ContinuationTokenRequest({CertificatesPath}, options.NextPageToken); + if (options.IncludePending) + { + request.GetUrl().AppendQueryParameter( + IncludePendingQuery, options.IncludePending.Value() ? TrueQueryValue : FalseQueryValue); + } + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = CertificatePropertiesPagedResponseSerializer::Deserialize(*rawResponse); + return CertificatePropertiesPagedResponse( + std::move(value), std::move(rawResponse), std::make_unique(*this)); +} + +CertificatePropertiesPagedResponse CertificateClient::GetPropertiesOfCertificateVersions( + std::string const& certificateName, + GetPropertiesOfCertificateVersionsOptions const& options, + Azure::Core::Context const& context) const +{ + // Request and settings + auto request = ContinuationTokenRequest( + {CertificatesPath, certificateName, VersionsPath}, options.NextPageToken); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = CertificatePropertiesPagedResponseSerializer::Deserialize(*rawResponse); + return CertificatePropertiesPagedResponse( + std::move(value), std::move(rawResponse), std::make_unique(*this)); +} + +IssuerPropertiesPagedResponse CertificateClient::GetPropertiesOfIssuers( + GetPropertiesOfIssuersOptions const& options, + Azure::Core::Context const& context) const +{ + // Request and settings + auto request = ContinuationTokenRequest({CertificatesPath, IssuersPath}, options.NextPageToken); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = IssuerPropertiesPagedResponseSerializer::Deserialize(*rawResponse); + return IssuerPropertiesPagedResponse( + std::move(value), std::move(rawResponse), std::make_unique(*this)); +} + +DeletedCertificatesPagedResponse CertificateClient::GetDeletedCertificates( + GetDeletedCertificatesOptions const& options, + Azure::Core::Context const& context) const +{ + // Request and settings + auto request = ContinuationTokenRequest({DeletedCertificatesPath}, options.NextPageToken); + + // Send and parse respone + auto rawResponse = SendRequest(request, context); + auto value = DeletedCertificatesPagedResponseSerializer::Deserialize(*rawResponse); + return DeletedCertificatesPagedResponse( + std::move(value), std::move(rawResponse), std::make_unique(*this)); +} + +Azure::Response CertificateClient::ImportCertificate( + std::string const& certificateName, + ImportCertificateOptions const& options, + Azure::Core::Context const& context) const +{ + auto payload = ImportCertificateOptionsSerializer::Serialize(options); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request = CreateRequest( + HttpMethod::Post, {CertificatesPath, certificateName, ImportPath}, &payloadStream); + + auto rawResponse = SendRequest(request, context); + auto value = KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::MergeCertificate( + std::string const& certificateName, + MergeCertificateOptions const& options, + Azure::Core::Context const& context) const +{ + auto payload = MergeCertificateOptionsSerializer::Serialize(options); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request = CreateRequest( + HttpMethod::Post, + {CertificatesPath, certificateName, PendingPath, MergePath}, + &payloadStream); + + auto rawResponse = SendRequest(request, context); + auto value = KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} + +Azure::Response CertificateClient::UpdateCertificateProperties( + std::string const& certificateName, + std::string const& certificateVersion, + CertificateProperties const& certificateProperties, + Azure::Core::Context const& context) const +{ + auto payload = CertificateUpdateOptionsSerializer::Serialize(certificateProperties); + Azure::Core::IO::MemoryBodyStream payloadStream( + reinterpret_cast(payload.data()), payload.size()); + + auto request = CreateRequest( + HttpMethod::Patch, {CertificatesPath, certificateName, certificateVersion}, &payloadStream); + + auto rawResponse = SendRequest(request, context); + auto value = KeyVaultCertificateSerializer::Deserialize(certificateName, *rawResponse); + return Azure::Response(std::move(value), std::move(rawResponse)); +} 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 06b6bdcfac..0d6d72971b 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,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// 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" 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 e2b4c5a104..83fc81e982 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_serializers.cpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/certificate_serializers.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include 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 5b4b3d7415..840173cd9f 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include "private/keyvault_certificates_common_request.hpp" diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/private/certificate_constants.hpp b/sdk/keyvault/azure-security-keyvault-certificates/src/private/certificate_constants.hpp index 8e8750aa1d..fe87359b7d 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/private/certificate_constants.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/private/certificate_constants.hpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 34742b5d0d..414c2d6ea5 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/private/keyvault_certificates_common_request.hpp b/sdk/keyvault/azure-security-keyvault-certificates/src/private/keyvault_certificates_common_request.hpp index acaf42fade..33dc6715f7 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/private/keyvault_certificates_common_request.hpp +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/private/keyvault_certificates_common_request.hpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 142f72d630..36005af5a8 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 849919c8e9..bb6295d1ea 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,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include 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 6931cf6859..ed350bfed4 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include "private/keyvault_secrets_common_request.hpp" diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/private/keyvault_secrets_common_request.hpp b/sdk/keyvault/azure-security-keyvault-secrets/src/private/keyvault_secrets_common_request.hpp index a7d7454049..fd73a28e6f 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/private/keyvault_secrets_common_request.hpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/private/keyvault_secrets_common_request.hpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2_backup_restore.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2_backup_restore.cpp index d5c1cab98b..2fe8637ecd 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2_backup_restore.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample2-backup-restore/sample2_backup_restore.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** diff --git a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover/sample3_delete_recover.cpp b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover/sample3_delete_recover.cpp index 35be06a372..6197db18f7 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover/sample3_delete_recover.cpp +++ b/sdk/keyvault/azure-security-keyvault-secrets/test/samples/sample3-delete-recover/sample3_delete_recover.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** 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 efdb41e9e0..0dd105a694 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include "datalake_path_client_test.hpp" From 7ba5c3e94b9ce6b334759aa758ea4b69843e737a Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 16 Jan 2023 18:19:18 -0800 Subject: [PATCH 08/11] Exclude nlohmann json tests from ASCII validation check. --- eng/pipelines/templates/jobs/ci.tests.yml | 2 +- .../test/ut/settings_client_base_test.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 18f74e7772..8c76ffc1af 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -135,7 +135,7 @@ jobs: # Validate all the files are saved as ASCII only without a UTF-8 BOM. - bash: | # Run grep recursive excluding git folder and known expected files and save a file with results. - grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude "grepResults" . > grepResults + grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude-dir "nlohmann-json-test" --exclude "grepResults" . > grepResults # Display results to console. cat grepResults 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 e7f113b8a1..f7e03cd280 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** From e77ee6cf3dd3cca13b28077596d675b64eea443f Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 16 Jan 2023 18:26:26 -0800 Subject: [PATCH 09/11] Log an intro to the CI console for the validation step. --- eng/pipelines/templates/jobs/ci.tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 8c76ffc1af..74132bc9ab 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -134,6 +134,8 @@ jobs: # Validate all the files are saved as ASCII only without a UTF-8 BOM. - bash: | + echo Validate that the files in the repo contain only ASCII characters, saved as UTF-8, without a BOM at the start. + # Run grep recursive excluding git folder and known expected files and save a file with results. grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude-dir "nlohmann-json-test" --exclude "grepResults" . > grepResults From bee644a5622b5ed7ad1266a2a72a392573d92f1c Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 16 Jan 2023 18:40:33 -0800 Subject: [PATCH 10/11] Remove codecoverage.cmake exclusion. --- eng/pipelines/templates/jobs/ci.tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 74132bc9ab..2c3398685d 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -137,7 +137,7 @@ jobs: echo Validate that the files in the repo contain only ASCII characters, saved as UTF-8, without a BOM at the start. # Run grep recursive excluding git folder and known expected files and save a file with results. - grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude "*CodeCoverage.cmake*" --exclude-dir "nlohmann-json-test" --exclude "grepResults" . > grepResults + grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude-dir "nlohmann-json-test" --exclude "grepResults" . > grepResults # Display results to console. cat grepResults From 5e5d9c2a9141be89d09192afe3942987f812d132 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 16 Jan 2023 18:43:45 -0800 Subject: [PATCH 11/11] Remove exclusion for docs and tools directories. --- eng/pipelines/templates/jobs/ci.tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 2c3398685d..997ddeea8d 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -137,7 +137,7 @@ jobs: echo Validate that the files in the repo contain only ASCII characters, saved as UTF-8, without a BOM at the start. # Run grep recursive excluding git folder and known expected files and save a file with results. - grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "docs" --exclude-dir "tools" --exclude-dir "nlohmann-json-test" --exclude "grepResults" . > grepResults + grep -I -P -n "[^\x00-\x7F]" -r --exclude-dir ".git" --exclude-dir ".github" --exclude-dir "vcpkg_installed" --exclude-dir "_deps" --exclude-dir "nlohmann-json-test" --exclude "grepResults" . > grepResults # Display results to console. cat grepResults