diff --git a/eng/config.json b/eng/config.json index e0900edfd5a8..ec2cdc5e6860 100644 --- a/eng/config.json +++ b/eng/config.json @@ -32,6 +32,10 @@ "Name": "eng/tools", "CoverageGoal": 0.0 }, + { + "Name": "keyvault/internal", + "CoverageGoal": 0.40 + }, { "Name": "internal", "CoverageGoal": 0.70 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 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 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 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") } diff --git a/sdk/keyvault/internal/ci.keyvault.yml b/sdk/keyvault/internal/ci.keyvault.yml new file mode 100644 index 000000000000..d72c650135e4 --- /dev/null +++ b/sdk/keyvault/internal/ci.keyvault.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 diff --git a/sdk/keyvault/internal/constants.go b/sdk/keyvault/internal/constants.go new file mode 100644 index 000000000000..50d5a8adbcd1 --- /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 = "v0.1.0" //nolint +)