-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding user Key Verification to MAJORBBS Lock & Key Ordinals * Implement hasmkey * Handle Account Keys for RLOGIN & New Accounts - Return Default Keys for RLOGIN Users - Assign new users default keys on signup * Fix Test Build Issue * Refactor MBBSEmu Database to be Testable - Impement haskey test - Add `Reset()` methods to Accounts and AccounKeys Repositories - Add Database Resets to ExportedModuleTestBase * Fixing Failing Tests & Added Test for HASMKEY
- Loading branch information
Showing
15 changed files
with
272 additions
and
50 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using MBBSEmu.Memory; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using MBBSEmu.Database.Repositories.Account; | ||
using MBBSEmu.Database.Repositories.AccountKey; | ||
using MBBSEmu.Module; | ||
using Xunit; | ||
|
||
namespace MBBSEmu.Tests.ExportedModules.Majorbbs | ||
{ | ||
public class key_Tests :ExportedModuleTestBase | ||
{ | ||
|
||
private const ushort HASKEY_ORDINAL = 334; | ||
private const ushort HASMKEY_ORDINAL = 335; | ||
|
||
[Fact] | ||
public void haskey_Test() | ||
{ | ||
//Reset State | ||
Reset(); | ||
|
||
//Set the test Username | ||
testSessions[0].Username = "sysop"; | ||
var key = "SYSOP"; | ||
|
||
//Set Argument Values to be Passed In | ||
var stringPointer = mbbsEmuMemoryCore.AllocateVariable("INPUT_STRING", (ushort)(key.Length + 1)); | ||
mbbsEmuMemoryCore.SetArray("INPUT_STRING", Encoding.ASCII.GetBytes("SYSOP")); | ||
|
||
//Execute Test | ||
ExecuteApiTest(HostProcess.ExportedModules.Majorbbs.Segment, HASKEY_ORDINAL, new List<IntPtr16> { stringPointer }); | ||
|
||
Assert.Equal(1, mbbsEmuCpuRegisters.AX); | ||
|
||
} | ||
|
||
[Fact] | ||
public void hasmkey_Test() | ||
{ | ||
//Reset State | ||
Reset(); | ||
|
||
//Set the test Username | ||
testSessions[0].Username = "sysop"; | ||
var key = "NORMAL"; | ||
|
||
var mcvPointer = (ushort)majorbbs.McvPointerDictionary.Allocate(new McvFile("TEST.MCV", | ||
new Dictionary<int, byte[]> { { 0, Encoding.ASCII.GetBytes(key) } })); | ||
|
||
mbbsEmuMemoryCore.SetPointer("CURRENT-MCV", new IntPtr16(0xFFFF, mcvPointer)); | ||
|
||
//Execute Test | ||
ExecuteApiTest(HostProcess.ExportedModules.Majorbbs.Segment, HASMKEY_ORDINAL, new List<ushort> { 0 }); | ||
|
||
Assert.Equal(1, mbbsEmuCpuRegisters.AX); | ||
|
||
} | ||
|
||
protected override void Reset() | ||
{ | ||
base.Reset(); | ||
|
||
_serviceResolver.GetService<IAccountRepository>().Reset("sysop"); | ||
_serviceResolver.GetService<IAccountKeyRepository>().Reset(); | ||
} | ||
} | ||
} |
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
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
9 changes: 9 additions & 0 deletions
9
MBBSEmu/Database/Repositories/AccountKey/Queries/GetAccountKeysByUsername.sql
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,9 @@ | ||
SELECT | ||
AK.* | ||
FROM | ||
AccountKeys AK | ||
INNER JOIN | ||
Accounts A ON | ||
A.accountId = AK.accountId | ||
WHERE | ||
A.userName = @userName |
16 changes: 16 additions & 0 deletions
16
MBBSEmu/Database/Repositories/AccountKey/Queries/InsertAccountKeyByUsername.sql
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,16 @@ | ||
INSERT INTO AccountKeys ( | ||
accountId, | ||
accountKey, | ||
createDate, | ||
updateDate) | ||
SELECT | ||
A.accountID, | ||
@accountKey, | ||
datetime('now'), | ||
datetime('now') | ||
FROM | ||
Accounts A | ||
WHERE | ||
userName = @userName; | ||
|
||
SELECT last_insert_rowid(); |
Oops, something went wrong.