stuff
This commit is contained in:
parent
14fd359ea8
commit
a4ef2b4a20
26 changed files with 331 additions and 78 deletions
|
@ -1,26 +1,46 @@
|
|||
using System.Text;
|
||||
using Geralt;
|
||||
using Npgsql;
|
||||
|
||||
namespace Femto.Database.Seed;
|
||||
|
||||
public static class TestDataSeeder
|
||||
{
|
||||
private const int Iterations = 3;
|
||||
private const int MemorySize = 67108864;
|
||||
|
||||
public static async Task Seed(NpgsqlDataSource dataSource)
|
||||
{
|
||||
var id = Guid.Parse("0196960c-6296-7532-ba66-8fabb38c6ae0");
|
||||
var username = "johnbotris";
|
||||
var salt = new byte[32];
|
||||
var password = "hunter2"u8;
|
||||
var hashInput = new byte[password.Length + salt.Length];
|
||||
password.CopyTo(hashInput);
|
||||
salt.CopyTo(hashInput, password.Length);
|
||||
var passwordHash = new byte[128];
|
||||
Argon2id.ComputeHash(
|
||||
passwordHash,
|
||||
hashInput,
|
||||
Iterations,
|
||||
MemorySize
|
||||
);
|
||||
|
||||
await using var addToHistoryCommand = dataSource.CreateCommand(
|
||||
"""
|
||||
$"""
|
||||
INSERT INTO blog.author
|
||||
(id, username)
|
||||
VALUES
|
||||
('0196960c-6296-7532-ba66-8fabb38c6ae0', 'johnbotris')
|
||||
(@id, @username)
|
||||
;
|
||||
|
||||
INSERT INTO blog.post
|
||||
(id, author_id, content)
|
||||
VALUES
|
||||
('019691a0-48ed-7eba-b8d3-608e25e07d4b', '0196960c-6296-7532-ba66-8fabb38c6ae0', 'However, authors often misinterpret the zoology as a smothered advantage, when in actuality it feels more like a blindfold accordion. They were lost without the chastest puppy that composed their Santa.'),
|
||||
('019691a0-4ace-7bb5-a8f3-e3362920eba0', '0196960c-6296-7532-ba66-8fabb38c6ae0', 'Extending this logic, a swim can hardly be considered a seasick duckling without also being a tornado. Some posit the whity voyage to be less than dippy.'),
|
||||
('019691a0-4c3e-726f-b8f6-bcbaabe789ae', '0196960c-6296-7532-ba66-8fabb38c6ae0','Few can name a springless sun that isn''t a thudding Vietnam. The burn of a competitor becomes a frosted target.'),
|
||||
('019691a0-4dd3-7e89-909e-94a6fd19a05e', '0196960c-6296-7532-ba66-8fabb38c6ae0','Some unwitched marbles are thought of simply as currencies. A boundary sees a nepal as a chordal railway.')
|
||||
('019691a0-48ed-7eba-b8d3-608e25e07d4b', @id, 'However, authors often misinterpret the zoology as a smothered advantage, when in actuality it feels more like a blindfold accordion. They were lost without the chastest puppy that composed their Santa.'),
|
||||
('019691a0-4ace-7bb5-a8f3-e3362920eba0', @id, 'Extending this logic, a swim can hardly be considered a seasick duckling without also being a tornado. Some posit the whity voyage to be less than dippy.'),
|
||||
('019691a0-4c3e-726f-b8f6-bcbaabe789ae', @id,'Few can name a springless sun that isn''t a thudding Vietnam. The burn of a competitor becomes a frosted target.'),
|
||||
('019691a0-4dd3-7e89-909e-94a6fd19a05e', @id,'Some unwitched marbles are thought of simply as currencies. A boundary sees a nepal as a chordal railway.')
|
||||
;
|
||||
|
||||
INSERT INTO blog.post_media
|
||||
|
@ -33,9 +53,19 @@ public static class TestDataSeeder
|
|||
('019691b6-07cb-7353-8c33-68456188f462', '019691a0-4c3e-726f-b8f6-bcbaabe789ae', 'https://wallpapers.com/images/hd/big-chungus-2bxloyitgw7q1hfg.jpg', 1),
|
||||
('019691b6-2608-7088-8110-f0f6e35fa633', '019691a0-4dd3-7e89-909e-94a6fd19a05e', 'https://www.pinclipart.com/picdir/big/535-5356059_big-transparent-chungus-png-background-big-chungus-clipart.png', 0)
|
||||
;
|
||||
|
||||
INSERT INTO authn.user_identity
|
||||
(id, username, password_hash, password_salt)
|
||||
VALUES
|
||||
(@id, @username, @passwordHash, @salt);
|
||||
"""
|
||||
);
|
||||
|
||||
addToHistoryCommand.Parameters.AddWithValue("@id", id);
|
||||
addToHistoryCommand.Parameters.AddWithValue("@username", username);
|
||||
addToHistoryCommand.Parameters.AddWithValue("@passwordHash", passwordHash);
|
||||
addToHistoryCommand.Parameters.AddWithValue("@salt", salt);
|
||||
|
||||
await addToHistoryCommand.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue