Skip to content

Commit

Permalink
fix: simplify base urls usage (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwwoda committed Apr 7, 2022
1 parent 0909fb2 commit f8e7344
Show file tree
Hide file tree
Showing 33 changed files with 95 additions and 248 deletions.
5 changes: 0 additions & 5 deletions Box.V2.Test/AuthRepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class AuthRepositoryTest : BoxResourceManagerTest
{

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
[ExpectedException(typeof(BoxAPIException))]
public async Task AuthenticateLive_InvalidAuthCode_Exception()
{
Expand All @@ -32,7 +31,6 @@ public async Task AuthenticateLive_InvalidAuthCode_Exception()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task Authenticate_ValidResponse_ValidSession()
{
// Arrange
Expand All @@ -54,7 +52,6 @@ public async Task Authenticate_ValidResponse_ValidSession()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
[ExpectedException(typeof(BoxAPIException))]
public async Task Authenticate_ErrorResponse_Exception()
{
Expand All @@ -71,7 +68,6 @@ public async Task Authenticate_ErrorResponse_Exception()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task RefreshSession_ValidResponse_ValidSession()
{
// Arrange
Expand All @@ -93,7 +89,6 @@ public async Task RefreshSession_ValidResponse_ValidSession()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task RefreshSession_MultipleThreadsSameAccessToken_SameSession()
{

Expand Down
4 changes: 0 additions & 4 deletions Box.V2.Test/BoxCCGAuthTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public BoxCCGAuthTest()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetAdminToken_ValidSession()
{
// Arrange
Expand Down Expand Up @@ -63,7 +62,6 @@ public async Task GetAdminToken_ValidSession()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetUserToken_ValidSession()
{
// Arrange
Expand Down Expand Up @@ -92,7 +90,6 @@ public async Task GetUserToken_ValidSession()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public void UserClient_ShouldReturnUserClientWithSession()
{
// Act
Expand All @@ -105,7 +102,6 @@ public void UserClient_ShouldReturnUserClientWithSession()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public void AdminClient_ShouldReturnAdminClientWithSession()
{
// Act
Expand Down
5 changes: 0 additions & 5 deletions Box.V2.Test/BoxCollaborationsManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public BoxCollaborationsManagerTest()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task AddCollaboration_ValidResponse_ValidCollaboration()
{
/*** Arrange ***/
Expand Down Expand Up @@ -56,7 +55,6 @@ public async Task AddCollaboration_ValidResponse_ValidCollaboration()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task EditCollaboration_ValidResponse_ValidCollaboration()
{
/*** Arrange ***/
Expand Down Expand Up @@ -85,7 +83,6 @@ public async Task EditCollaboration_ValidResponse_ValidCollaboration()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetCollaboration_ValidResponse_ValidCollaboration()
{
/*** Arrange ***/
Expand All @@ -109,7 +106,6 @@ public async Task GetCollaboration_ValidResponse_ValidCollaboration()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetPendingCollaboration_ValidResponse_ValidEntries()
{
/*** Arrange ***/
Expand Down Expand Up @@ -167,7 +163,6 @@ public async Task GetPendingCollaboration_ValidResponse_ValidEntries()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task DeleteCollaboration_ValidResponse_CollaborationDeleted()
{
/*** Arrange ***/
Expand Down
4 changes: 0 additions & 4 deletions Box.V2.Test/BoxCollectionsManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public BoxCollectionsManagerTest()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task CreateOrDeleteCollectionsForFolder_ValidResponse()
{
/*** Arrange ***/
Expand Down Expand Up @@ -146,7 +145,6 @@ public async Task CreateOrDeleteCollectionsForFolder_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task CreateOrDeleteCollectionsForFile_ValidResponse()
{
/*** Arrange ***/
Expand Down Expand Up @@ -265,7 +263,6 @@ public async Task CreateOrDeleteCollectionsForFile_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetCollections_ValidResponse()
{
/*** Arrange ***/
Expand Down Expand Up @@ -318,7 +315,6 @@ public async Task GetCollections_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetCollectionItems_ValidResponse()
{
/*** Arrange ***/
Expand Down
4 changes: 0 additions & 4 deletions Box.V2.Test/BoxCommentsManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public BoxCommentsManagerTest()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task AddComment_ValidResponse_ValidComment()
{
/*** Arrange ***/
Expand Down Expand Up @@ -56,7 +55,6 @@ public async Task AddComment_ValidResponse_ValidComment()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetCommentInformation_ValidResponse_ValidComment()
{
/*** Arrange ***/
Expand All @@ -82,7 +80,6 @@ public async Task GetCommentInformation_ValidResponse_ValidComment()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task UpdateComment_ValidResponse_ValidComment()
{
/*** Arrange ***/
Expand Down Expand Up @@ -114,7 +111,6 @@ public async Task UpdateComment_ValidResponse_ValidComment()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task DeleteComment_ValidResponse_CommentDeleted()
{
/*** Arrange ***/
Expand Down
47 changes: 34 additions & 13 deletions Box.V2.Test/BoxConfigTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Box.V2.Config;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand All @@ -7,7 +8,6 @@ namespace Box.V2.Test
public class BoxConfigTest : BoxResourceManagerTest
{
[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public void BoxConfig_SetUriString()
{
const string JsonString =
Expand All @@ -17,7 +17,7 @@ public void BoxConfig_SetUriString()
'clientSecret': 'cre-123',
'appAuth': {
'publicKeyID': 'kid-123',
'privateKey': 'DUMMY',
'privateKey': 'testKey',
'passphrase': 'password'
},
},
Expand All @@ -27,17 +27,16 @@ public void BoxConfig_SetUriString()
var config = BoxConfigBuilder
.CreateFromJsonString(JsonString)
.Build();
Assert.AreEqual(config.BoxApiUri, new System.Uri(Constants.BoxApiUriString));
Assert.AreEqual(config.BoxApiUri, new Uri(Constants.BoxApiUriString));

var exampleUri = new System.Uri("https://example.com/");
var exampleUri = new Uri("https://example.com/");
config = BoxConfigBuilder.CreateFromJsonString(JsonString)
.SetBoxApiUri(exampleUri)
.Build();
Assert.AreEqual(config.BoxApiUri, exampleUri);
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public void BoxConfig_CreateFromString()
{
const string JsonString =
Expand All @@ -47,7 +46,7 @@ public void BoxConfig_CreateFromString()
'clientSecret': 'cre-123',
'appAuth': {
'publicKeyID': 'kid-123',
'privateKey': 'DUMMY',
'privateKey': 'testKey',
'passphrase': 'password'
},
},
Expand All @@ -60,23 +59,45 @@ public void BoxConfig_CreateFromString()
Assert.AreEqual(config.ClientId, "cid-123");
Assert.AreEqual(config.ClientSecret, "cre-123");
Assert.AreEqual(config.JWTPublicKeyId, "kid-123");
Assert.AreEqual(config.JWTPrivateKey, "DUMMY");
Assert.AreEqual(config.JWTPrivateKey, "testKey");
Assert.AreEqual(config.EnterpriseId, "eid-123");
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public void BoxConfig_SetAuthTokenUriString()
{
var boxConfig = new BoxConfigBuilder("", "", "", "", "", "")
var boxConfig = new BoxConfigBuilder("", "")
.Build();
Assert.AreEqual(boxConfig.BoxAuthTokenApiUri, new System.Uri(Constants.BoxAuthTokenApiUriString));
Assert.AreEqual(boxConfig.BoxAuthTokenApiUri, new Uri(Constants.BoxAuthTokenApiUriString));

var exampleUri = new System.Uri("https://example.com/");
var newConfig = new BoxConfigBuilder("", "", "", "", "", "")
var exampleUri = new Uri("https://example.com/token");
var newConfig = new BoxConfigBuilder("", "")
.SetBoxTokenApiUri(exampleUri)
.Build();
Assert.AreEqual(newConfig.BoxAuthTokenApiUri, exampleUri);
Assert.AreEqual(newConfig.BoxAuthTokenApiUri.ToString(), exampleUri + "/");
}

[TestMethod]
public void BoxConfig_SetBoxApiHostUri()
{
var exampleUri = new Uri("https://example.com/base");
var newConfig = new BoxConfigBuilder("", "")
.SetBoxApiHostUri(exampleUri)
.Build();

Assert.AreEqual(newConfig.BoxApiHostUri.ToString(), exampleUri + "/");
}

[TestMethod]
public void BoxConfig_SetBoxAccountApiHostUri()
{
var exampleUri = new Uri("https://example.com/account");
var newConfig = new BoxConfigBuilder("", "")
.SetBoxAccountApiHostUri(exampleUri)
.Build();

Assert.AreEqual(newConfig.BoxAccountApiHostUri.ToString(), exampleUri + "/");
Assert.AreEqual(newConfig.AuthCodeBaseUri.ToString(), exampleUri + "/" + "oauth2/authorize");
}
}
}
9 changes: 0 additions & 9 deletions Box.V2.Test/BoxEventsManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public BoxEventsManagerTest()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task EnterpriseEventsAsync_DateEncodingUTC_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"group_id\":\"942617509\",\"group_name\":\"Groupies\"},\"created_by\":{\"type\":\"user\",\"id\":\"11111\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"action_by\":{\"type\":\"user\",\"id\":\"12345\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"GROUP_EDITED\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand All @@ -46,7 +45,6 @@ public async Task EnterpriseEventsAsync_DateEncodingUTC_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetGroupEvents_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"group_id\":\"942617509\",\"group_name\":\"Groupies\"},\"created_by\":{\"type\":\"user\",\"id\":\"11111\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"GROUP_EDITED\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand All @@ -70,7 +68,6 @@ public async Task GetGroupEvents_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetUserEventsFile_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"file_id\":\"283257336425\",\"file_name\":\"ScreenShot2018-03-12at5.44.00PM.png\",\"user_id\":\"285663442\",\"user_name\":\"foo\",\"parent\":{\"type\":\"folder\",\"name\":\"AllFiles\",\"id\":\"0\"}},\"created_by\":{\"type\":\"user\",\"id\":\"11111\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"COLLABORATION_INVITE\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand All @@ -94,7 +91,6 @@ public async Task GetUserEventsFile_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetUserEventsFolder_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"folder_id\":\"47846340014\",\"folder_name\":\"SharedWithServiceAccount\",\"user_id\":\"182069272\",\"user_name\":\"MattWiller\",\"parent\":{\"type\":\"folder\",\"name\":\"AllFiles\",\"id\":\"0\"}},\"created_by\":{\"type\":\"user\",\"id\":\"11111\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"COLLABORATION_INVITE\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand All @@ -118,7 +114,6 @@ public async Task GetUserEventsFolder_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetGroupEventsFolder_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"folder_id\":\"47846340014\",\"folder_name\":\"SharedWithServiceAccount\",\"group_id\":\"182069272\",\"group_name\":\"TestGroup\",\"parent\":{\"type\":\"folder\",\"name\":\"AllFiles\",\"id\":\"0\"}},\"created_by\":{\"type\":\"user\",\"id\":\"275035869\",\"name\":\"MattWiller\",\"login\":\"mwiller + [email protected]\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"COLLABORATION_INVITE\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand All @@ -142,7 +137,6 @@ public async Task GetGroupEventsFolder_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetGroupEventsFile_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"file_id\":\"47846340014\",\"file_name\":\"test-picture.jpg\",\"group_id\":\"182069272\",\"group_name\":\"TestGroup\"},\"created_by\":{\"type\":\"user\",\"id\":\"11111\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"COLLABORATION_INVITE\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand All @@ -166,7 +160,6 @@ public async Task GetGroupEventsFile_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetApplications_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"type\":\"application\",\"name\":\"AppUsersSample\",\"api_key\":\"9aktq31ca981fk2wc1dml6y1douxscx9\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"COLLABORATION_INVITE\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand All @@ -189,7 +182,6 @@ public async Task GetApplications_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetWebLinkEvents_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"item_type\":\"web_link\",\"item_id\":\"77777\",\"item_name\":\"My Bookmark\",\"parent\":{\"type\":\"folder\",\"name\":\"Web Sites I Like\",\"id\":\"22222\"}},\"created_by\":{\"type\":\"user\",\"id\":\"33333\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"SHARE\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand All @@ -215,7 +207,6 @@ public async Task GetWebLinkEvents_ValidResponse()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task EnterpriseEventsStreamingAsync_ValidResponse()
{
var responseString = "{\"chunk_size\": 1, \"next_stream_position\": 123, \"entries\": [{\"source\":{\"group_id\":\"942617509\",\"group_name\":\"Groupies\"},\"created_by\":{\"type\":\"user\",\"id\":\"11111\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"action_by\":{\"type\":\"user\",\"id\":\"12345\",\"name\":\"Test User\",\"login\":\"[email protected]\"},\"created_at\":\"2018-03-16T15:12:52-07:00\",\"event_id\":\"85c57bf3-bc15-4d24-93bc-955c796217c8\",\"event_type\":\"GROUP_EDITED\",\"ip_address\":\"UnknownIP\",\"type\":\"event\",\"session_id\":null,\"additional_details\":null}]}";
Expand Down
4 changes: 0 additions & 4 deletions Box.V2.Test/BoxFileRequestsManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public BoxFileRequestsManagerTest()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task GetFileRequestById_Success()
{
/*** Arrange ***/
Expand Down Expand Up @@ -64,7 +63,6 @@ public async Task GetFileRequestById_Success()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task CopyFileRequest_Success()
{
/*** Arrange ***/
Expand Down Expand Up @@ -118,7 +116,6 @@ public async Task CopyFileRequest_Success()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task UpdateFileRequest_Success()
{
/*** Arrange ***/
Expand Down Expand Up @@ -171,7 +168,6 @@ public async Task UpdateFileRequest_Success()
}

[TestMethod]
[TestCategory("CI-UNIT-TEST")]
public async Task DeleteFileRequest_Success()
{
/*** Arrange ***/
Expand Down
Loading

0 comments on commit f8e7344

Please sign in to comment.