-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'reconfigure-unittests'
- Loading branch information
Showing
15 changed files
with
382 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace CG.Web.MegaApiClient.Tests.Context | ||
{ | ||
using System.Dynamic; | ||
using System.IO; | ||
using Newtonsoft.Json; | ||
|
||
[CollectionDefinition(nameof(AuthenticatedTestContext))] | ||
public class AuthenticatedLoginTestsCollection : ICollectionFixture<AuthenticatedTestContext>, ICollectionFixture<AuthenticatedAsyncTestContext> { } | ||
|
||
public class AuthenticatedTestContext : TestContext, IDisposable | ||
{ | ||
private const string MegaApiClientPasswordEnvironment = "MEGAAPICLIENT_PASSWORD"; | ||
internal const string UsernameAccountV1 = "[email protected]"; | ||
internal const string UsernameAccountV2 = "[email protected]"; | ||
internal static readonly string Password = Environment.GetEnvironmentVariable(MegaApiClientPasswordEnvironment); | ||
internal const string MasterKeyHashV1 = "Q7LYmSw2Et4GjL9KWZKcq1oEzC1dX3wZDEdhS3YJICk"; | ||
internal const string MasterKeyHashV2 = "pRYA3b7JExchAvcTPaGpgl5h9U42iKncvXhPku7YIcA"; | ||
|
||
internal const string FileLinkLegacy = "https://mega.nz/#!bkwkHC7D!AWJuto8_fhleAI2WG0RvACtKkL_s9tAtvBXXDUp2bQk"; | ||
internal const string FileLink = "https://mega.nz/file/bkwkHC7D#AWJuto8_fhleAI2WG0RvACtKkL_s9tAtvBXXDUp2bQk"; | ||
internal const string FolderLinkLegacy = "https://mega.nz/#F!e1ogxQ7T!ee4Q_ocD1bSLmNeg9B6kBw"; | ||
internal const string FolderLink = "https://mega.nz/folder/e1ogxQ7T#ee4Q_ocD1bSLmNeg9B6kBw"; | ||
internal const string FileId = "P8BBzaTS"; | ||
internal const int FileSize = 523265; | ||
internal const string FolderId = "e5IjHLLJ"; | ||
internal const string SubFolderId = "CghQlTCa"; | ||
internal const string SubFolderFileId = "TlBDQIQY"; | ||
internal const int SubFolderFileSize = 112916; | ||
|
||
/* | ||
Storage layout | ||
+-Root (bsxVBKLL) | ||
| +-SharedFolder (e5IjHLLJ) (Outgoing Share) | ||
| |-SharedFile.jpg (P8BBzaTS) | ||
| +-SharedSubFolder (CghQlTCa) (Outgoing Share) | ||
| |-SharedFileUpSideDown.jpg (TlBDQIQY) | ||
+-Trash (j0wEGbTZ) | ||
+-Inbox (zhITTbIJ) | ||
+-Contacts | ||
+-SharedRemoteFolder (b0I0QDhA) (Incoming Share) | ||
|-SharedRemoteFile.jpg (e5wjkSJB) | ||
+-SharedRemoteSubFolder (KhZSWI7C) (Incoming Share / Subfolder of SharedRemoteFolder) | ||
|-SharedRemoteSubFile.jpg (HtonzYYY) | ||
+-SharedRemoteSubSubFolder (z1YCibCT) | ||
*/ | ||
|
||
private readonly string[] systemNodes = | ||
{ | ||
"bsxVBKLL", // Root | ||
"j0wEGbTZ", // Trash | ||
"zhITTbIJ", // Inbox | ||
}; | ||
|
||
private readonly string[] permanentFoldersRootNodes = | ||
{ | ||
FolderId // SharedFolder | ||
}; | ||
internal static readonly string InputsJson = File.ReadAllText("Data\\inputs.json"); | ||
|
||
private readonly string[] permanentFoldersNodes = | ||
static AuthenticatedTestContext() | ||
{ | ||
SubFolderId, // SharedSubFolder | ||
}; | ||
|
||
private readonly string[] permanentRemoteFoldersNodes = | ||
{ | ||
"b0I0QDhA", // SharedRemoteFolder | ||
"KhZSWI7C", // SharedRemoteSubFolder | ||
"z1YCibCT", // SharedRemoteSubSubFolder | ||
}; | ||
|
||
private readonly string[] permanentFilesNodes = | ||
{ | ||
FileId, // SharedFile.jpg | ||
SubFolderFileId, // SharedFileUpSideDown.jpg | ||
}; | ||
Inputs = JsonConvert.DeserializeObject<ExpandoObject>(InputsJson); | ||
} | ||
|
||
private readonly string[] permanentRemoteFilesNodes = | ||
{ | ||
"e5wjkSJB", // SharedRemoteFile.jpg | ||
"HtonzYYY", // SharedRemoteSubFile.jpg | ||
}; | ||
private const string MegaApiClientPasswordEnvironment = "MEGAAPICLIENT_PASSWORD"; | ||
internal static readonly string Password = Environment.GetEnvironmentVariable(MegaApiClientPasswordEnvironment); | ||
|
||
public string PermanentFilesNode | ||
{ | ||
get { return this.permanentFilesNodes[0]; } | ||
} | ||
internal static dynamic Inputs { get; } | ||
|
||
public virtual void Dispose() | ||
{ | ||
|
@@ -96,22 +33,31 @@ public virtual void Dispose() | |
protected override void ConnectClient(IMegaApiClient client) | ||
{ | ||
Assert.False(string.IsNullOrEmpty(Password), $"Environment variable {MegaApiClientPasswordEnvironment} not set."); | ||
client.Login(UsernameAccountV1, Password); | ||
client.Login(Inputs.UsernameAccount, Password); | ||
} | ||
|
||
protected override IEnumerable<string> GetProtectedNodes() | ||
{ | ||
return this.systemNodes | ||
.Concat(this.permanentFoldersRootNodes) | ||
.Concat(this.permanentFoldersNodes) | ||
.Concat(this.permanentFilesNodes) | ||
.Concat(this.permanentRemoteFoldersNodes) | ||
.Concat(this.permanentRemoteFilesNodes); | ||
return new string[] | ||
{ | ||
Inputs.Root.Id, | ||
Inputs.Trash.Id, | ||
Inputs.Inbox.Id, | ||
Inputs.SharedFolder.Id, | ||
Inputs.SharedSubFolder.Id, | ||
Inputs.SharedFile.Id, | ||
Inputs.SharedFileUpSideDown.Id, | ||
Inputs.SharedRemoteFolder.Id, | ||
Inputs.SharedRemoteSubFolder.Id, | ||
Inputs.SharedRemoteSubSubFolder.Id, | ||
Inputs.SharedRemoteFile.Id, | ||
Inputs.SharedRemoteSubFile.Id | ||
}; | ||
} | ||
|
||
protected override IEnumerable<string> GetPermanentNodes() | ||
{ | ||
return this.permanentFoldersRootNodes; | ||
return new string[] { Inputs.SharedFolder.Id }; | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"UsernameAccount": "[email protected]", | ||
"TotalQuota": 21474836480, | ||
|
||
"_comment_MasterKeyHash": "Hash of the master key (check GetRecoveryKeyAfterLogin_Succeeds to generate the hash from the masterkey)", | ||
"MasterKeyHash": "AqZH2MufH0VgX-qcv9rQ2zoPQxxhxsMGEyRfeVrYWHk", | ||
|
||
"_comment_StorageLayout": [ | ||
"+-Root", | ||
"| +-SharedFolder (Outgoing Share)", | ||
"| |-SharedFile.jpg", | ||
"| +-SharedSubFolder (Outgoing Share)", | ||
"| |-SharedFileUpSideDown.jpg", | ||
",+-Trash", | ||
",+-Inbox", | ||
",+-Contacts", | ||
", +-SharedRemoteFolder (Incoming Share)", | ||
", |-SharedRemoteFile.jpg", | ||
", +-SharedRemoteSubFolder (Incoming Share / Subfolder of SharedRemoteFolder)", | ||
", |-SharedRemoteSubFile.jpg", | ||
", +-SharedRemoteSubSubFolder" | ||
], | ||
|
||
"FileLink": "https://mega.nz/file/W0UAgJaK#XOYyTETrIy8daz3_dw3fdh6Hh8EFEdrnbyoop1r9R6g", | ||
"FolderLink": "https://mega.nz/folder/e4diDZ7T#iJnegBO_m6OXBQp27lHCrg", | ||
|
||
"Root": { | ||
"Id": "39FwkLpK", | ||
"CreationDate": "2021-09-24T17:18:01.0000000+08:00" | ||
}, | ||
|
||
"Trash": { | ||
"Id": "npM2zZiJ", | ||
"CreationDate": "2021-09-24T17:18:01.0000000+08:00" | ||
}, | ||
|
||
"Inbox": { | ||
"Id": "iwEglZbZ", | ||
"CreationDate": "2021-09-24T17:18:01.0000000+08:00" | ||
}, | ||
|
||
"SharedFolder": { | ||
"Id": "G5NikTgR", | ||
"CreationDate": "2021-09-24T17:23:48.0000000+08:00" | ||
}, | ||
|
||
"SharedFile": { | ||
"Id": "KlVgwR4B", | ||
"Size": 523265, | ||
"CreationDate": "2021-09-24T17:24:21.0000000+08:00", | ||
"ModificationDate": "2021-02-28T22:11:37.0000000+08:00", | ||
"Thumbnail": { | ||
"Id": "Br9xX2hAYqw", | ||
"AttributeId": 882 | ||
}, | ||
"Preview": { | ||
"Id": "IoZ69cbG8pk", | ||
"AttributeId": 704 | ||
} | ||
}, | ||
|
||
"SharedSubFolder": { | ||
"Id": "zwNiSB7J", | ||
"CreationDate": "2021-09-24T17:25:24.0000000+08:00" | ||
}, | ||
|
||
"SharedFileUpSideDown": { | ||
"Id": "y5cSkZrZ", | ||
"Size": 112916, | ||
"CreationDate": "2021-09-24T17:25:57.0000000+08:00", | ||
"ModificationDate": "2021-09-24T17:22:20.0000000+08:00" | ||
}, | ||
|
||
"SharedRemoteFolder": { | ||
"ParentId": "zoUwhLYR", | ||
"Id": "20d2XLIS", | ||
"CreationDate": "2021-09-26T14:27:29.0000000+08:00" | ||
}, | ||
|
||
"SharedRemoteSubFolder": { | ||
"Id": "HgU2GRDB", | ||
"CreationDate": "2021-09-26T14:28:36.0000000+08:00" | ||
}, | ||
|
||
"SharedRemoteSubSubFolder": { | ||
"Id": "bxMQkZhI", | ||
"CreationDate": "2021-09-26T14:29:11.0000000+08:00" | ||
}, | ||
|
||
"SharedRemoteFile": { | ||
"Id": "qgFmnRDI", | ||
"Size": 523265, | ||
"CreationDate": "2021-09-26T14:28:31.0000000+08:00", | ||
"ModificationDate": "2021-02-28T22:11:37.0000000+08:00" | ||
}, | ||
|
||
"SharedRemoteSubFile": { | ||
"Id": "qoNiELgb", | ||
"Size": 523265, | ||
"CreationDate": "2021-09-26T14:29:04.0000000+08:00", | ||
"ModificationDate": "2021-02-28T22:11:37.0000000+08:00" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.