< Summary

Class:Azure.Identity.LinuxVisualStudioCodeAdapter
Assembly:Azure.Identity
File(s):C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\LinuxVisualStudioCodeAdapter.cs
Covered lines:0
Uncovered lines:16
Coverable lines:16
Total lines:45
Line coverage:0% (0 of 16)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-0%100%
GetUserSettingsPath()-0%100%
GetCredentials(...)-0%100%
LookupPassword(...)-0%100%
GetLibsecretSchema()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\LinuxVisualStudioCodeAdapter.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.IO;
 6using System.Runtime.InteropServices;
 7using Azure.Core;
 8
 9namespace Azure.Identity
 10{
 11    internal sealed class LinuxVisualStudioCodeAdapter : IVisualStudioCodeAdapter
 12    {
 013        private static readonly string s_userSettingsJsonPath = Path.Combine(Environment.GetFolderPath(Environment.Speci
 14
 015        public string GetUserSettingsPath() => s_userSettingsJsonPath;
 16
 17        public string GetCredentials(string serviceName, string accountName)
 18        {
 019            Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName));
 020            Argument.AssertNotNullOrEmpty(accountName, nameof(accountName));
 21
 022            IntPtr schemaPtr = GetLibsecretSchema();
 23
 24            try
 25            {
 026                return LookupPassword(schemaPtr, serviceName, accountName);
 27            }
 28            finally
 29            {
 030                LinuxNativeMethods.secret_schema_unref(schemaPtr);
 031            }
 032        }
 33
 34        private static string LookupPassword(in IntPtr schemaPtr, string serviceName, string accountName)
 035            => LinuxNativeMethods.secret_password_lookup_sync(schemaPtr, IntPtr.Zero, "service", serviceName, "account",
 36
 37        private static IntPtr GetLibsecretSchema()
 038            => LinuxNativeMethods.secret_schema_new("org.freedesktop.Secret.Generic",
 039                LinuxNativeMethods.SecretSchemaFlags.SECRET_SCHEMA_DONT_MATCH_NAME,
 040                "service",
 041                LinuxNativeMethods.SecretSchemaAttributeType.SECRET_SCHEMA_ATTRIBUTE_STRING,
 042                "account",
 043                LinuxNativeMethods.SecretSchemaAttributeType.SECRET_SCHEMA_ATTRIBUTE_STRING);
 44    }
 45}