3using System.Security.Authentication;
15using Microsoft.VisualStudio.TestTools.UnitTesting;
18using TestClass = NUnit.Framework.TestFixtureAttribute;
19using TestMethod = NUnit.Framework.TestAttribute;
20using TestCategory = NUnit.Framework.CategoryAttribute;
28 private const string TestCategory =
"API Utilities";
36 Assert.Inconclusive(
"RUN_OFFLINE = true");
40 [TestMethod, TestCategory(TestCategory)]
45 AssertApi.ExceptionThrown<ArgumentException>(() => mock.Get());
46 AssertApi.ExceptionThrown<ArgumentException>(() => mock.Put());
47 AssertApi.ExceptionThrown<ArgumentException>(() => mock.PollUntilReady());
48 AssertApi.ExceptionThrown<ArgumentException>(() => mock.
data.LargeFileUpload(
null));
57 AssertApi.ExceptionThrown<ArgumentException>(() => mock_lv.Get());
69#pragma warning disable 618
70 AssertApi.ExceptionThrown<ArgumentException>(() => mock_lv.back_allocations(
null));
71#pragma warning restore 618
74 [TestMethod, TestCategory(TestCategory)]
82 [TestMethod, TestCategory(TestCategory)]
90 [TestMethod, TestCategory(TestCategory)]
96 new WebException(
"Could not create SSL/TLS secure channel"));
99 AssertApi.ExceptionThrown<AuthenticationException>(
103 [TestMethod, TestCategory(TestCategory)]
113 "non_existant_endpoint", Method.HEAD, returnRawResponse:
true);
117 [TestMethod, TestCategory(TestCategory)]
123 badAuthParameters.
AddParameter(
"Authorization",
"BadCredentials", ParameterType.HttpHeader);
124 AssertApi.ExceptionThrown<AuthenticationException>(
126 exception => Assert.IsTrue(exception.Message.StartsWith(
127 "The current request included an authentication token (BadCredentials) " +
128 "which was rejected by the server, and which differs from the currently " +
129 "configured default authentication token"),
Create a test class that takes care of setting the server URL and cleaning up after each unit test.
void AddCommonTestInitializeAction(Action action)
Exposes sample resource objects, with built-in methods for injecting dependencies.
static string Valid_NonExistant_UUID
void Test_API_Utilities_GetAuthenticationStatus_Authenticated()
void Test_API_Utilities_TryHandleAuthenticationErrors_NoAuthenticationError()
void Test_API_ValidateResourceId()
void Test_API_Utilities_TryPromptForAuthentication_Authenticated()
void Test_API_Utilities_TryHandleAuthenticationErrors_Temp_SSL_Error()
TestSuite_API_Utilities()
void Test_API_Utilities_TryHandleAuthenticationErrors_CustomAuthenticationError()
Retrieve settings from environment variables if they exist, or the project settings file otherwise.
static bool RUN_OFFLINE
Controls whether tests that normally require a connection to the server should be allowed to try to r...
static MockResponse Error(Exception requestException, ResponseStatus status=ResponseStatus.Error)
Create a mock response with the specified error.
static MockResponse Completed(HttpStatusCode httpStatus, ResponseStatus status=ResponseStatus.Completed)
Create a mock response with the specified error.
A custom exception class that includes the RestSharp.IRestResponse that generated the exception,...
API methods / requests made available to the user.
static IAccessToken AuthenticationToken
The AccessToken storing authentication information for requests made to the server.
static volatile int MaxRequestRetries
When a temporary communication failure occurs (such as a socket error or an authentication failure fo...
static void TryPromptForAuthentication()
Invoke the AuthenticationRequested event, which requests authentication credentials for the server....
static bool TryHandleAuthenticationErrors(IRestResponse response, int sequentialAttempts=0)
Checks an IRestResponse object for authentication errors, then invokes configured authentication dele...
static AuthenticationStatus GetAuthenticationStatus(bool force_request=false)
Determines whether we are currently authenticated against the server with the global default Authenti...
static IRestResponse ExecuteRestRequest(string resource, Method method, IEnumerable< Parameter > requestParameters=null, int? timeout=null, bool returnRawResponse=false, Action< Stream > responseStreamReader=null)
Perform a REST request on the server.
Represents the Analysis of a Layer.
Representation of a single loss set with an associated event loss table.
LargeDataSubResource data
An endpoint for accessing or modifying the data file attached to this resource.
Optional parameters which can be specified for co-metrics requests.
static new CoMetricsOptions Default
The default co-metrics request options used when none are specified.
Optional parameters which can be specified for exceedance probability requests.
static new ExceedanceProbabilityOptions Default
The default exceedance probability request options used when none are specified.
Optional parameters which can be specified for all metrics requests.
static new MetricsOptions Default
The default metrics request options used when none are specified.
Optional parameters which can be specified for yelt download requests.
static new YELTOptions Default
The default yelt request options used when none are specified.
A probability range used to dictate the set of ordered trial losses in a loss distribution that shoul...
static ProbabilityWindow All
Returns a window representing the full probability range [0, 1], such that all trial losses will be i...
Helper class which makes it easier to build a set of request parameters.
RequestParameters AddParameter(Parameter parameter)
Adds the specified parameter to this list and returns the list.
AccessTokenStatus status
The AccessToken's current AccessTokenStatus (unauthorized / valid).
Represents the Analysis of a Layer.
AccessTokenStatus
An AccessToken's status (unauthorized / valid).
AuthenticationStatus
The status of authentication against the current server.