public async Task TestAuthorizeAccountSuccess() { var client = new UnauthenticatedB2Client(new Uri(TestEnvironment.B2ApiUrl)); var req = new AuthorizeAccountV1Request(TestEnvironment.GetTestAccountId(), TestEnvironment.GetTestAccountKey()); var result = await client.PerformAuthenticationRequestAsync(B2Apis.AuthorizeAccountV1, req); Assert.That(result.AccountId, Is.EqualTo(TestEnvironment.GetTestAccountId())); Assert.That(result.AuthorizationToken, Is.Not.Null); Assert.That(result.DownloadUrl, Is.Not.Null); }
public void TestErrorResponseFromApiCall() { var client = new UnauthenticatedB2Client(new Uri(TestEnvironment.B2ApiUrl)); var req = new AuthorizeAccountV1Request("nonsense", "nonsense"); var exception = Assert.ThrowsAsync <B2Exception>( async() => await client.PerformAuthenticationRequestAsync(new AuthorizeAccountV1Api(), req)); var response = exception.ErrorResponse; Assert.That(response.StatusCode, Is.EqualTo(401U)); }
public async Task TestListBucketsV1Success() { var client = new UnauthenticatedB2Client(new Uri(TestEnvironment.B2ApiUrl)); var req = new AuthorizeAccountV1Request(TestEnvironment.GetTestAccountId(), TestEnvironment.GetTestAccountKey()); var authedClient = client.AuthenticateWithResponse( await client.PerformAuthenticationRequestAsync(B2Apis.AuthorizeAccountV1, req)); var result = await authedClient.PerformApiRequestAsync(B2Apis.ListBucketsV1, new ListBucketsV1Request(TestEnvironment.GetTestAccountId())); Assert.That(result.Buckets, Is.Not.Null); }