55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Openstack.Common;
|
|
using Openstack.Identity;
|
|
using Openstack.Storage;
|
|
|
|
namespace Openstack.Test.Identity
|
|
{
|
|
[TestClass]
|
|
public class IdentityServiceClientDefinitionTests
|
|
{
|
|
public IOpenstackCredential GetValidCredentials()
|
|
{
|
|
var endpoint = new Uri("https://someidentityendpoint:35357/v2.0/tokens");
|
|
var userName = "TestUser";
|
|
var password = "RandomPassword".ConvertToSecureString();
|
|
var tenantId = "12345";
|
|
|
|
return new OpenstackCredential(endpoint, userName, password, tenantId);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void CanSupportVersion2()
|
|
{
|
|
var client = new IdentityServiceClientDefinition();
|
|
|
|
Assert.IsTrue(client.IsSupported(GetValidCredentials()));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void CannotSupportVersion1()
|
|
{
|
|
var endpoint = new Uri("https://someidentityendpoint:35357/v1.0/tokens");
|
|
var userName = "TestUser";
|
|
var password = "RandomPassword".ConvertToSecureString();
|
|
var tenantId = "12345";
|
|
|
|
var creds = new OpenstackCredential(endpoint, userName, password, tenantId);
|
|
|
|
var client = new IdentityServiceClientDefinition();
|
|
|
|
Assert.IsFalse(client.IsSupported(creds));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Version2Supported()
|
|
{
|
|
var client = new IdentityServiceClientDefinition();
|
|
Assert.IsTrue(client.ListSupportedVersions().Contains("2.0.0.0"));
|
|
}
|
|
}
|
|
}
|