From 78ebc74362f807f9ce39eeada78e2a51d3e3fade Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 12:05:24 -0500 Subject: [PATCH 01/14] Release kv/internal --- sdk/keyvault/internal/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 sdk/keyvault/internal/README.md diff --git a/sdk/keyvault/internal/README.md b/sdk/keyvault/internal/README.md new file mode 100644 index 000000000000..67c2af73d8fd --- /dev/null +++ b/sdk/keyvault/internal/README.md @@ -0,0 +1,3 @@ +# Internal for Key Vault SDKs + +This module contains shared code for all the Key Vault SDKs, mainly the challenge authentication policy. \ No newline at end of file From ce1613f85497c29b96ba76a1d35f58e884d80034 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 14:02:25 -0500 Subject: [PATCH 02/14] adding eng/config entry --- eng/config.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eng/config.json b/eng/config.json index e0900edfd5a8..3526a577d84e 100644 --- a/eng/config.json +++ b/eng/config.json @@ -33,9 +33,13 @@ "CoverageGoal": 0.0 }, { - "Name": "internal", + "Name": "sdk/internal", "CoverageGoal": 0.70 }, + { + "Name": "sdk/keyvault/internal", + "CoverageGoal": 0.30 + }, { "Name": "messaging", "CoverageGoal": 0.10 From 1169fc4c19a7f2b4f2b3479e91271b23f4db5564 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 14:15:02 -0500 Subject: [PATCH 03/14] adding ci.yml file --- sdk/keyvault/internal/ci.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sdk/keyvault/internal/ci.yml diff --git a/sdk/keyvault/internal/ci.yml b/sdk/keyvault/internal/ci.yml new file mode 100644 index 000000000000..d72c650135e4 --- /dev/null +++ b/sdk/keyvault/internal/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/keyvault/internal + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/keyvault/internal + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'keyvault/internal' + RunLiveTests: false From b0d40cc4ef9b2d7ab62fd93c0fbb3ee7b1e7aabc Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 14:40:28 -0500 Subject: [PATCH 04/14] trying to expand coverage --- eng/config.json | 2 +- eng/tools/internal/coverage/coverage.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/config.json b/eng/config.json index 3526a577d84e..91b036765330 100644 --- a/eng/config.json +++ b/eng/config.json @@ -33,7 +33,7 @@ "CoverageGoal": 0.0 }, { - "Name": "sdk/internal", + "Name": "internal", "CoverageGoal": 0.70 }, { diff --git a/eng/tools/internal/coverage/coverage.go b/eng/tools/internal/coverage/coverage.go index e9c8701f513f..977ca52f077c 100644 --- a/eng/tools/internal/coverage/coverage.go +++ b/eng/tools/internal/coverage/coverage.go @@ -67,10 +67,11 @@ func readConfigData(coverageConfig string) *codeCoverage { } // This supports doing a single package at a time. If this needs to be expanded in the future -// this method will have to return a []*float64 for each packages goal +// this method will have to return a []float64 for each packages goal func findCoverageGoal(covFiles []string, configData *codeCoverage) float64 { for _, covFile := range covFiles { for _, p := range configData.Packages { + fmt.Println(covFile, p.Name) if strings.Contains(covFile, p.Name) { return p.CoverageGoal } From 60ae07cb3dba1df5eab022aa1c46534b11d1f05f Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 15:02:07 -0500 Subject: [PATCH 05/14] renaming to ci.keyvault.yml --- sdk/keyvault/internal/{ci.yml => ci.keyvault.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sdk/keyvault/internal/{ci.yml => ci.keyvault.yml} (100%) diff --git a/sdk/keyvault/internal/ci.yml b/sdk/keyvault/internal/ci.keyvault.yml similarity index 100% rename from sdk/keyvault/internal/ci.yml rename to sdk/keyvault/internal/ci.keyvault.yml From 93a0ac5f21cd5ef705bb4692d9a50ab5c485fa15 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 17:01:03 -0500 Subject: [PATCH 06/14] configure Name --- eng/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/config.json b/eng/config.json index 91b036765330..6f9ea93c65a5 100644 --- a/eng/config.json +++ b/eng/config.json @@ -37,8 +37,8 @@ "CoverageGoal": 0.70 }, { - "Name": "sdk/keyvault/internal", - "CoverageGoal": 0.30 + "Name": "keyvault/internal", + "CoverageGoal": 0.40 }, { "Name": "messaging", From 3eaf0bd9dbb4275c76fcd72734db991466e825bf Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 17:18:23 -0500 Subject: [PATCH 07/14] fixing issues --- eng/config.json | 8 ++++---- eng/tools/internal/coverage/coverage.go | 14 +++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/eng/config.json b/eng/config.json index 6f9ea93c65a5..ec2cdc5e6860 100644 --- a/eng/config.json +++ b/eng/config.json @@ -32,14 +32,14 @@ "Name": "eng/tools", "CoverageGoal": 0.0 }, - { - "Name": "internal", - "CoverageGoal": 0.70 - }, { "Name": "keyvault/internal", "CoverageGoal": 0.40 }, + { + "Name": "internal", + "CoverageGoal": 0.70 + }, { "Name": "messaging", "CoverageGoal": 0.10 diff --git a/eng/tools/internal/coverage/coverage.go b/eng/tools/internal/coverage/coverage.go index 977ca52f077c..b31964769167 100644 --- a/eng/tools/internal/coverage/coverage.go +++ b/eng/tools/internal/coverage/coverage.go @@ -68,13 +68,10 @@ func readConfigData(coverageConfig string) *codeCoverage { // This supports doing a single package at a time. If this needs to be expanded in the future // this method will have to return a []float64 for each packages goal -func findCoverageGoal(covFiles []string, configData *codeCoverage) float64 { - for _, covFile := range covFiles { - for _, p := range configData.Packages { - fmt.Println(covFile, p.Name) - if strings.Contains(covFile, p.Name) { - return p.CoverageGoal - } +func findCoverageGoal(covFile string, configData *codeCoverage) float64 { + for _, p := range configData.Packages { + if strings.Contains(covFile, p.Name) { + return p.CoverageGoal } } fmt.Println("WARNING: Could not find a coverage goal, defaulting to 95%.") @@ -101,7 +98,6 @@ func parseCoverageFiles(coverageFiles []string) []float64 { coverageValues := make([]float64, 0) for _, coverageFile := range coverageFiles { - fmt.Println(coverageFile) xmlFile, err := os.Open(coverageFile) check(err) defer xmlFile.Close() @@ -129,7 +125,7 @@ func CheckCoverage(serviceDir string, coverageConfig string, searchDirectory str } configData := readConfigData(coverageConfig) - coverageGoal := findCoverageGoal([]string{serviceDir}, configData) + coverageGoal := findCoverageGoal(serviceDir, configData) fmt.Printf("Failing if the coverage is below %.2f\n", coverageGoal) From 84b80294561cbeac5123a6708e885a7bfdceec93 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 17:20:31 -0500 Subject: [PATCH 08/14] undoing change to internal/coverage --- eng/tools/internal/coverage/coverage.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/eng/tools/internal/coverage/coverage.go b/eng/tools/internal/coverage/coverage.go index b31964769167..e9c8701f513f 100644 --- a/eng/tools/internal/coverage/coverage.go +++ b/eng/tools/internal/coverage/coverage.go @@ -67,11 +67,13 @@ func readConfigData(coverageConfig string) *codeCoverage { } // This supports doing a single package at a time. If this needs to be expanded in the future -// this method will have to return a []float64 for each packages goal -func findCoverageGoal(covFile string, configData *codeCoverage) float64 { - for _, p := range configData.Packages { - if strings.Contains(covFile, p.Name) { - return p.CoverageGoal +// this method will have to return a []*float64 for each packages goal +func findCoverageGoal(covFiles []string, configData *codeCoverage) float64 { + for _, covFile := range covFiles { + for _, p := range configData.Packages { + if strings.Contains(covFile, p.Name) { + return p.CoverageGoal + } } } fmt.Println("WARNING: Could not find a coverage goal, defaulting to 95%.") @@ -98,6 +100,7 @@ func parseCoverageFiles(coverageFiles []string) []float64 { coverageValues := make([]float64, 0) for _, coverageFile := range coverageFiles { + fmt.Println(coverageFile) xmlFile, err := os.Open(coverageFile) check(err) defer xmlFile.Close() @@ -125,7 +128,7 @@ func CheckCoverage(serviceDir string, coverageConfig string, searchDirectory str } configData := readConfigData(coverageConfig) - coverageGoal := findCoverageGoal(serviceDir, configData) + coverageGoal := findCoverageGoal([]string{serviceDir}, configData) fmt.Printf("Failing if the coverage is below %.2f\n", coverageGoal) From 8a6a369bea25d37b677f2286b24c8941d4b85f78 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 17:26:31 -0500 Subject: [PATCH 09/14] add license --- sdk/keyvault/internal/LICENSE.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sdk/keyvault/internal/LICENSE.txt diff --git a/sdk/keyvault/internal/LICENSE.txt b/sdk/keyvault/internal/LICENSE.txt new file mode 100644 index 000000000000..d1ca00f20a89 --- /dev/null +++ b/sdk/keyvault/internal/LICENSE.txt @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE \ No newline at end of file From c7a37ba7a9426b97f0d2f1aac18184a3b27b2d9b Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 17:47:00 -0500 Subject: [PATCH 10/14] adding changelog date --- sdk/keyvault/internal/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/keyvault/internal/CHANGELOG.md b/sdk/keyvault/internal/CHANGELOG.md index f6cc0dfd45c0..b553a334c59b 100644 --- a/sdk/keyvault/internal/CHANGELOG.md +++ b/sdk/keyvault/internal/CHANGELOG.md @@ -1,4 +1,4 @@ # Release History -## 0.1.0 (Unreleased) +## 0.1.0 (2021-11-09) * This is the initial release of the `internal` library for KeyVault From 0a8d3382d1d4826a41d21a13d8a1ea0b4c7578a9 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 18:26:21 -0500 Subject: [PATCH 11/14] add a constant for version --- sdk/keyvault/internal/constants.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sdk/keyvault/internal/constants.go diff --git a/sdk/keyvault/internal/constants.go b/sdk/keyvault/internal/constants.go new file mode 100644 index 000000000000..313555068370 --- /dev/null +++ b/sdk/keyvault/internal/constants.go @@ -0,0 +1,11 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package internal + +const ( + version = "0.1.0" //nolint +) \ No newline at end of file From 817518b17961117e8695490563e6c5efabd36ab5 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 8 Nov 2021 18:35:01 -0500 Subject: [PATCH 12/14] formatting --- sdk/keyvault/internal/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/keyvault/internal/constants.go b/sdk/keyvault/internal/constants.go index 313555068370..d832a81e2ddb 100644 --- a/sdk/keyvault/internal/constants.go +++ b/sdk/keyvault/internal/constants.go @@ -8,4 +8,4 @@ package internal const ( version = "0.1.0" //nolint -) \ No newline at end of file +) From 6db61f11705e70cfa745ba9d5a50d4c9d184c38b Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Mon, 8 Nov 2021 17:09:43 -0800 Subject: [PATCH 13/14] Update sdk/keyvault/internal/constants.go --- sdk/keyvault/internal/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/keyvault/internal/constants.go b/sdk/keyvault/internal/constants.go index d832a81e2ddb..50d5a8adbcd1 100644 --- a/sdk/keyvault/internal/constants.go +++ b/sdk/keyvault/internal/constants.go @@ -7,5 +7,5 @@ package internal const ( - version = "0.1.0" //nolint + version = "v0.1.0" //nolint ) From ce61558e7b2a11532e4a8c12baf02b96c4128bc0 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 9 Nov 2021 10:47:15 -0500 Subject: [PATCH 14/14] fixing tests ignoring errors --- .../internal/challenge_policy_test.go | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sdk/keyvault/internal/challenge_policy_test.go b/sdk/keyvault/internal/challenge_policy_test.go index bb8fa392f47f..ebc466b0bed8 100644 --- a/sdk/keyvault/internal/challenge_policy_test.go +++ b/sdk/keyvault/internal/challenge_policy_test.go @@ -10,6 +10,8 @@ import ( "fmt" "net/http" "testing" + + "github.com/stretchr/testify/require" ) var fakeTenant = "00000000-0000-0000-0000-000000000000" @@ -41,7 +43,8 @@ func TestFindScopeAndTenant(t *testing.T) { "WWW-Authenticate", fmt.Sprintf(authResource, fakeTenant, mhsmResource), ) - p.findScopeAndTenant(&resp) + err := p.findScopeAndTenant(&resp) + require.NoError(t, err) if *p.scope != mhsmScope { t.Fatalf("scope was not properly parsed, got %s, expected %s", *p.scope, mhsmScope) } @@ -53,7 +56,8 @@ func TestFindScopeAndTenant(t *testing.T) { "WWW-Authenticate", fmt.Sprintf(authResourceScope, fakeTenant, resource, scope), ) - p.findScopeAndTenant(&resp) + err = p.findScopeAndTenant(&resp) + require.NoError(t, err) if *p.scope != scope { t.Fatalf("scope was not properly parsed, got %s, expected %s", *p.scope, scope) } @@ -65,7 +69,8 @@ func TestFindScopeAndTenant(t *testing.T) { "WWW-Authenticate", fmt.Sprintf(authScope, fakeTenant, scope), ) - p.findScopeAndTenant(&resp) + err = p.findScopeAndTenant(&resp) + require.NoError(t, err) if *p.scope != scope { t.Fatalf("scope was not properly parsed, got %s, expected %s", *p.scope, scope) } @@ -77,7 +82,8 @@ func TestFindScopeAndTenant(t *testing.T) { "WWW-Authenticate", fmt.Sprintf(resourceScopeAuth, mhsmResource, mhsmScope, fakeTenant), ) - p.findScopeAndTenant(&resp) + err = p.findScopeAndTenant(&resp) + require.NoError(t, err) if *p.scope != mhsmScope { t.Fatalf("scope was not properly parsed, got %s, expected %s", *p.scope, "https://vault.azure.net/.default") } @@ -89,7 +95,8 @@ func TestFindScopeAndTenant(t *testing.T) { "WWW-Authenticate", "Bearer authorization=\"https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000\", unimportantkey=\"unimportantvalue\" resource=\"https://vault.azure.net/.default\"", ) - p.findScopeAndTenant(&resp) + err = p.findScopeAndTenant(&resp) + require.NoError(t, err) if *p.scope != scope { t.Fatalf("scope was not properly parsed, got %s, expected %s", *p.scope, scope) } @@ -101,7 +108,8 @@ func TestFindScopeAndTenant(t *testing.T) { "WWW-Authenticate", "Bearer authorization=\"https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000\", unimportantkey=\"unimportantvalue\" resource=\"https://vault.azure.net/.default\" fakekey=\"fakevalue\" ", ) - p.findScopeAndTenant(&resp) + err = p.findScopeAndTenant(&resp) + require.NoError(t, err) if *p.scope != "https://vault.azure.net/.default" { t.Fatalf("scope was not properly parsed, got %s, expected %s", *p.scope, "https://vault.azure.net/.default") }