Skip to content

Commit

Permalink
Have to recreate test accounts + full layout for integration tests a …
Browse files Browse the repository at this point in the history
…second time (6590883) because Mega has decided to close the test accounts one more time.
  • Loading branch information
gpailler committed Mar 5, 2023
1 parent 21902a8 commit 7fa231c
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 83 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,5 @@ tools/*
!tools/packages.config

# Ignore Rider
.idea/*
.idea/*
.DS_Store
2 changes: 1 addition & 1 deletion MegaApiClient.Tests/Context/AuthenticatedTestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class AuthenticatedLoginTestsCollection : ICollectionFixture<Authenticate

public class AuthenticatedTestContext : TestContext, IDisposable
{
internal static readonly string InputsJson = File.ReadAllText("Data\\inputs.json");
internal static readonly string InputsJson = File.ReadAllText("Data/inputs.json");

static AuthenticatedTestContext()
{
Expand Down
104 changes: 54 additions & 50 deletions MegaApiClient.Tests/Data/inputs.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"UsernameAccount": "megaapiclient3@yopmail.com",
"UsernameAccount": "megaapiclient4@yopmail.com",
"TotalQuota": 21474836480,

"_comment_MasterKeyHash": "Hash of the master key (check GetRecoveryKeyAfterLogin_Succeeds to generate the hash from the masterkey)",
"MasterKeyHash": "AqZH2MufH0VgX-qcv9rQ2zoPQxxhxsMGEyRfeVrYWHk",
"MasterKeyHash": "p4KqEao9gqcagOS87203DiDLosoak7Y41QztZ_3QewQ",

"_comment_StorageLayout": [
"+-Root",
"| +-SharedFolder (Outgoing Share)",
"| |-SharedFile.jpg",
"| +-SharedSubFolder (Outgoing Share)",
"| |-SharedFileUpSideDown.jpg",
"+-SampleFile.zip",
"+-SampleZipFile.zip",
"+-Trash",
"+-Inbox",
"+-Contacts",
Expand All @@ -22,96 +22,100 @@
" +-SharedRemoteSubSubFolder"
],

"FileLink": "https://mega.nz/file/W0UAgJaK#XOYyTETrIy8daz3_dw3fdh6Hh8EFEdrnbyoop1r9R6g",
"ZipFileLink": "https://mega.nz/file/WkNUzRzK#4aKRNvHSlkPPW3zHMYuRQANh1CNueAd6dmw5rOlwurY",
"FolderLink": "https://mega.nz/folder/e4diDZ7T#iJnegBO_m6OXBQp27lHCrg",
"FileLink": "https://mega.nz/file/3MolSBjA#Jdd26GHPF2sfj40IakU46UMNJAvInEPX4QlWT2oWYNQ",
"ZipFileLink": "https://mega.nz/file/eIRnyIiQ#iFqZubk4ETI8H2rPhwMRjQaQ3puHlsSvc-bWby9E87o",
"FolderLink": "https://mega.nz/folder/PIZlnRaY#KIOsd4bKgGQmB3gOH2VeGA",

"Root": {
"Id": "39FwkLpK",
"CreationDate": "2021-09-24T17:18:01.0000000+08:00"
"Id": "CVwBQBzB",
"CreationDate": "2023-03-05T21:29:51.0000000+08:00"
},

"Trash": {
"Id": "npM2zZiJ",
"CreationDate": "2021-09-24T17:18:01.0000000+08:00"
"Id": "GUpXWJiQ",
"CreationDate": "2023-03-05T21:29:51.0000000+08:00"
},

"Inbox": {
"Id": "iwEglZbZ",
"CreationDate": "2021-09-24T17:18:01.0000000+08:00"
"Id": "KQhTTBgD",
"CreationDate": "2023-03-05T21:29:51.0000000+08:00"
},

"SharedFolder": {
"Id": "G5NikTgR",
"CreationDate": "2021-09-24T17:23:48.0000000+08:00"
"Id": "eBoFxIwa",
"CreationDate": "2023-03-05T21:37:34.0000000+08:00"
},

"SharedFile": {
"Id": "KlVgwR4B",
"Id": "2QgnCCpB",
"Size": 523265,
"CreationDate": "2021-09-24T17:24:21.0000000+08:00",
"ModificationDate": "2021-02-28T22:11:37.0000000+08:00",
"Fingerprint": "GRSM8-c1HUmlmyDuTJVrDwSZpDtg",
"Thumbnail": {
"Id": "Br9xX2hAYqw",
"AttributeId": 882
},
"Preview": {
"Id": "IoZ69cbG8pk",
"AttributeId": 704
}
"CreationDate": "2023-03-05T21:37:48.0000000+08:00",
"ModificationDate": "2020-05-03T15:47:44.0000000+08:00",
"Fingerprint": "GRSM8-c1HUmlmyDuTJVrDwQgd65e",
"Metadata": [
{
"_comment": "Preview",
"Id": "FI4k-VG4Dx4",
"AttributeId": 701
},
{
"_comment": "Thumbnail",
"Id": "9uSiHwYMH_M",
"AttributeId": 825
}
]
},

"SharedSubFolder": {
"Id": "zwNiSB7J",
"CreationDate": "2021-09-24T17:25:24.0000000+08:00"
"Id": "jB5HTS5b",
"CreationDate": "2023-03-05T21:38:29.0000000+08:00"
},

"SharedFileUpSideDown": {
"Id": "y5cSkZrZ",
"Id": "DJpjyICA",
"Size": 112916,
"CreationDate": "2021-09-24T17:25:57.0000000+08:00",
"ModificationDate": "2021-09-24T17:22:20.0000000+08:00",
"Fingerprint": "hDL3WKxHmI6lMM92r43BWQTMmE1h"
"CreationDate": "2023-03-05T21:38:46.0000000+08:00",
"ModificationDate": "2023-03-05T15:02:15.0000000+08:00",
"Fingerprint": "hDL3WKxHmI6lMM92r43BWQR3PgRk"
},

"SampleZipFile": {
"Id": "e5U0XbgQ",
"Id": "GQpXUSZS",
"Size": 513604,
"CreationDate": "2021-11-22T08:12:43.0000000+08:00",
"ModificationDate": "2021-11-22T08:09:59.0000000+08:00",
"Fingerprint": "sKBj43s_QyradRQ1YlmxhATX35ph"
"ModificationDate": "2023-03-05T15:02:15.0000000+08:00",
"Fingerprint": "sKBj43s_QyradRQ1YlmxhAR3PgRk"
},

"SharedRemoteFolder": {
"ParentId": "zoUwhLYR",
"Id": "20d2XLIS",
"CreationDate": "2021-09-26T14:27:29.0000000+08:00"
"ParentId": "HB4RgZwb",
"Id": "aUp32IjL",
"CreationDate": "2023-03-05T21:34:06.0000000+08:00"
},

"SharedRemoteSubFolder": {
"Id": "HgU2GRDB",
"CreationDate": "2021-09-26T14:28:36.0000000+08:00"
"Id": "HY5nFabZ",
"CreationDate": "2023-03-05T21:35:24.0000000+08:00"
},

"SharedRemoteSubSubFolder": {
"Id": "bxMQkZhI",
"CreationDate": "2021-09-26T14:29:11.0000000+08:00"
"Id": "CFpFnYhZ",
"CreationDate": "2023-03-05T21:35:48.0000000+08:00"
},

"SharedRemoteFile": {
"Id": "qgFmnRDI",
"Id": "fQohECZJ",
"Size": 523265,
"CreationDate": "2021-09-26T14:28:31.0000000+08:00",
"ModificationDate": "2021-02-28T22:11:37.0000000+08:00",
"Fingerprint": "GRSM8-c1HUmlmyDuTJVrDwSZpDtg"
"CreationDate": "2023-03-05T21:35:20.0000000+08:00",
"ModificationDate": "2020-05-03T15:47:44.0000000+08:00",
"Fingerprint": "GRSM8-c1HUmlmyDuTJVrDwQgd65e"
},

"SharedRemoteSubFile": {
"Id": "qoNiELgb",
"Id": "XUxxRQaA",
"Size": 523265,
"CreationDate": "2021-09-26T14:29:04.0000000+08:00",
"ModificationDate": "2021-02-28T22:11:37.0000000+08:00",
"Fingerprint": "GRSM8-c1HUmlmyDuTJVrDwSZpDtg"
"CreationDate": "2023-03-05T21:35:39.0000000+08:00",
"ModificationDate": "2020-05-03T15:47:44.0000000+08:00",
"Fingerprint": "GRSM8-c1HUmlmyDuTJVrDwQgd65e"
}
}
4 changes: 2 additions & 2 deletions MegaApiClient.Tests/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ public void GenerateAuthInfos_InvalidCredentials_Throws(string email, string pas
}

[Theory]
[InlineData("[email protected]", "password", null, "{'Email':'[email protected]','Hash':'ObELy57HULI','PasswordAesKey':'ZAM5cl5uvROiXwBSEp98sQ==','MFAKey':null}")]
[InlineData("[email protected]", "password", "mfa", "{'Email':'[email protected]','Hash':'ObELy57HULI','PasswordAesKey':'ZAM5cl5uvROiXwBSEp98sQ==','MFAKey':'mfa'}")]
[InlineData("[email protected]", "password", null, "{'Email':'[email protected]','Hash':'gafGcRqHrzI9lwIJyLoNLA','PasswordAesKey':'o7HMO8ZSIiMEMBIDgzpj6Q==','MFAKey':null}")]
[InlineData("[email protected]", "password", "mfa", "{'Email':'[email protected]','Hash':'gafGcRqHrzI9lwIJyLoNLA','PasswordAesKey':'o7HMO8ZSIiMEMBIDgzpj6Q==','MFAKey':'mfa'}")]
public void GenerateAuthInfos_ValidCredentials_Succeeds(string email, string password, string mfa, string expectedResult)
{
var authInfos = Context.Client.GenerateAuthInfos(email, password, mfa);
Expand Down
2 changes: 1 addition & 1 deletion MegaApiClient.Tests/NodeOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public void GetNodeFromLink_WithoutFileAttributes_Succeeds(string fileLink)
var node = Context.Client.GetNodeFromLink(new Uri(fileLink));

Assert.NotNull(node);
Assert.Equal("SampleFile.zip", node.Name);
Assert.Equal("SampleZipFile.zip", node.Name);
Assert.Equal(AuthenticatedTestContext.Inputs.SampleZipFile.Size, node.Size);
Assert.Equal(AuthenticatedTestContext.Inputs.SampleZipFile.ModificationDate, node.ModificationDate);
Assert.Null(node.CreationDate);
Expand Down
8 changes: 4 additions & 4 deletions MegaApiClient.Tests/NodeOperationsAuthenticated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public void GetFileAttributes_FromNode_Succeeds()
Assert.Equal(2, node.FileAttributes.Length);

var fileAttribute = node.FileAttributes[0];
Assert.Equal(AuthenticatedTestContext.Inputs.SharedFile.Thumbnail.Id, fileAttribute.Handle);
Assert.Equal(AuthenticatedTestContext.Inputs.SharedFile.Thumbnail.AttributeId, fileAttribute.Id);
Assert.Equal(AuthenticatedTestContext.Inputs.SharedFile.Metadata[0].Id, fileAttribute.Handle);
Assert.Equal(AuthenticatedTestContext.Inputs.SharedFile.Metadata[0].AttributeId, fileAttribute.Id);
Assert.Equal(FileAttributeType.Thumbnail, fileAttribute.Type);

fileAttribute = node.FileAttributes[1];
Assert.Equal(AuthenticatedTestContext.Inputs.SharedFile.Preview.Id, fileAttribute.Handle);
Assert.Equal(AuthenticatedTestContext.Inputs.SharedFile.Preview.AttributeId, fileAttribute.Id);
Assert.Equal(AuthenticatedTestContext.Inputs.SharedFile.Metadata[1].Id, fileAttribute.Handle);
Assert.Equal(AuthenticatedTestContext.Inputs.SharedFile.Metadata[1].AttributeId, fileAttribute.Id);
Assert.Equal(FileAttributeType.Preview, fileAttribute.Type);
}

Expand Down
42 changes: 18 additions & 24 deletions MegaApiClient.Tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

Integration tests require a specific layout. It can be generated by following the following steps and updating the `inputs.json` file.

### Accounts creation
Two account are required to generate this layout. You should create the accounts on https://mega.nz website
```
Account1 = [email protected]
Account2 = [email protected]
```

### Install megacmd and launch the server
```
scoop install megacmd
$env:USERPROFILE\scoop\apps\megacmd\current\MEGAcmdServer.exe
."$env:USERPROFILE\scoop\apps\megacmd\current\MEGAcmdServer.exe"
```

### Launch megacmd
```
$env:USERPROFILE\scoop\apps\megacmd\current\MEGAcmdShell.exe
."$env:USERPROFILE\scoop\apps\megacmd\current\MEGAcmdShell.exe"
```

### Layout
Expand All @@ -30,25 +37,10 @@ $env:USERPROFILE\scoop\apps\megacmd\current\MEGAcmdShell.exe
+-SharedRemoteSubSubFolder
```

### Accounts creation
Two account are required to generate this layout
```
$account="[email protected]"
$accountshare="[email protected]"
```

```
signup $account $account --name="megaapiclient"
confirm [LINK] $account $account
```
```
signup $accountshare $accountshare --name="megaapiclient share"
confirm [LINK] $accountshare $accountshare
```

### Layout configuration
```
login $accountshare $accountshare
login [ACCOUNT2] [PASSWORD2]
mkdir SharedRemoteFolder
cd SharedRemoteFolder
Expand All @@ -58,15 +50,16 @@ cd SharedRemoteSubFolder
put Data\SampleFile.jpg SharedRemoteSubFile.jpg
mkdir SharedRemoteSubSubFolder
cd
share -a --with=$account SharedRemoteFolder
share -a --with=[ACCOUNT1] SharedRemoteFolder
logout
```

```
login $account $account
login [ACCOUNT1] [PASSWORD1]
rm "Welcome to MEGA.pdf"
put SampleZipFile.zip SampleZipFile.zip
mkdir SharedFolder
cd SharedFolder
put Data\SampleFile.jpg SharedFile.jpg
Expand All @@ -78,19 +71,20 @@ put Data\SampleFileUpSideDown.jpg SharedFileUpSideDown.jpg
cd
export -a -f SharedFolder
export -a -f SharedFolder/SharedFile.jpge
export -a -f SharedFolder/SharedFile.jpg
export -a -f SampleZipFile.zip
showpcr
ipc $accountshare -a
ipc [ACCOUNT2] -a
# Commands used to retrieve the required informations
ls --tree --show-handles -aaa
ls --tree --show-handles -aaa $accountshare:SharedRemoteFolder
ls --tree --show-handles -aaa [ACCOUNT2]:SharedRemoteFolder
# Command used to retrieve the masterkey
masterkey
logout
```

Once the layout is created, the file `inputs.json` can be updated accordingly
Once the layout is created, the file `inputs.json` should be updated accordingly

0 comments on commit 7fa231c

Please sign in to comment.