diff --git a/src/BSLManager/Tools/SettingsManager.cs b/src/BSLManager/Tools/SettingsManager.cs index 5ff6314..4763822 100644 --- a/src/BSLManager/Tools/SettingsManager.cs +++ b/src/BSLManager/Tools/SettingsManager.cs @@ -3,7 +3,6 @@ using System.IO; using System.Runtime.CompilerServices; using BirdsiteLive.Common.Settings; using Newtonsoft.Json; -using Org.BouncyCastle.Asn1.IsisMtt.X509; namespace BSLManager.Tools { diff --git a/src/BirdsiteLive.Cryptography/BirdsiteLive.Cryptography.csproj b/src/BirdsiteLive.Cryptography/BirdsiteLive.Cryptography.csproj index a282f1b..43b50a5 100644 --- a/src/BirdsiteLive.Cryptography/BirdsiteLive.Cryptography.csproj +++ b/src/BirdsiteLive.Cryptography/BirdsiteLive.Cryptography.csproj @@ -6,8 +6,6 @@ - - diff --git a/src/BirdsiteLive.Cryptography/MagicKey.cs b/src/BirdsiteLive.Cryptography/MagicKey.cs index 23d478a..a281c24 100644 --- a/src/BirdsiteLive.Cryptography/MagicKey.cs +++ b/src/BirdsiteLive.Cryptography/MagicKey.cs @@ -1,28 +1,12 @@ using System; -using System.Collections.Generic; using System.Security.Cryptography; using System.Text; -using Newtonsoft.Json; +using System.Text.Json; namespace BirdsiteLive.Cryptography { public class MagicKey { - //public class WebfingerLink - //{ - // public string rel { get; set; } - // public string type { get; set; } - // public string href { get; set; } - // public string template { get; set; } - //} - - //public class WebfingerResult - //{ - // public string subject { get; set; } - // public List aliases { get; set; } - // public List links { get; set; } - //} - private string[] _parts; private RSA _rsa; @@ -38,14 +22,14 @@ namespace BirdsiteLive.Cryptography private class RSAKeyParms { - public byte[] D; - public byte[] DP; - public byte[] DQ; - public byte[] Exponent; - public byte[] InverseQ; - public byte[] Modulus; - public byte[] P; - public byte[] Q; + public byte[] D { get; set; } + public byte[] DP {get; set; } + public byte[] DQ {get; set; } + public byte[] Exponent {get; set; } + public byte[] InverseQ {get; set; } + public byte[] Modulus {get; set; } + public byte[] P {get; set; } + public byte[] Q {get; set; } public static RSAKeyParms From(RSAParameters parms) { @@ -81,7 +65,9 @@ namespace BirdsiteLive.Cryptography if (key[0] == '{') { _rsa = RSA.Create(); - _rsa.ImportParameters(JsonConvert.DeserializeObject(key).Make()); + Console.WriteLine(key); + Console.WriteLine(JsonSerializer.Deserialize(key).Make()); + _rsa.ImportParameters(JsonSerializer.Deserialize(key).Make()); } else { @@ -102,7 +88,7 @@ namespace BirdsiteLive.Cryptography var rsa = RSA.Create(); rsa.KeySize = 2048; - return new MagicKey(JsonConvert.SerializeObject(RSAKeyParms.From(rsa.ExportParameters(true)))); + return new MagicKey(JsonSerializer.Serialize(RSAKeyParms.From(rsa.ExportParameters(true)))); } public byte[] BuildSignedData(string data, string dataType, string encoding, string algorithm) @@ -140,7 +126,7 @@ namespace BirdsiteLive.Cryptography public string PrivateKey { - get { return JsonConvert.SerializeObject(RSAKeyParms.From(_rsa.ExportParameters(true))); } + get { return JsonSerializer.Serialize(RSAKeyParms.From(_rsa.ExportParameters(true))); } } public string PublicKey diff --git a/src/BirdsiteLive.Cryptography/RsaGenerator.cs b/src/BirdsiteLive.Cryptography/RsaGenerator.cs deleted file mode 100644 index 5763c54..0000000 --- a/src/BirdsiteLive.Cryptography/RsaGenerator.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.IO; -using System.Security.Cryptography; - -namespace BirdsiteLive.Cryptography -{ - //https://gist.github.com/ststeiger/f4b29a140b1e3fd618679f89b7f3ff4a - //https://gist.github.com/valep27/4a720c25b35fff83fbf872516f847863 - //https://gist.github.com/therightstuff/aa65356e95f8d0aae888e9f61aa29414 - //https://stackoverflow.com/questions/52468125/export-rsa-public-key-in-der-format-and-decrypt-data - public class RsaGenerator - { - public string GetRsa() - { - var rsa = RSA.Create(); - - var outputStream = new StringWriter(); - var parameters = rsa.ExportParameters(true); - using (var stream = new MemoryStream()) - { - var writer = new BinaryWriter(stream); - writer.Write((byte)0x30); // SEQUENCE - using (var innerStream = new MemoryStream()) - { - var innerWriter = new BinaryWriter(innerStream); - innerWriter.Write((byte)0x30); // SEQUENCE - EncodeLength(innerWriter, 13); - innerWriter.Write((byte)0x06); // OBJECT IDENTIFIER - var rsaEncryptionOid = new byte[] { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01 }; - EncodeLength(innerWriter, rsaEncryptionOid.Length); - innerWriter.Write(rsaEncryptionOid); - innerWriter.Write((byte)0x05); // NULL - EncodeLength(innerWriter, 0); - innerWriter.Write((byte)0x03); // BIT STRING - using (var bitStringStream = new MemoryStream()) - { - var bitStringWriter = new BinaryWriter(bitStringStream); - bitStringWriter.Write((byte)0x00); // # of unused bits - bitStringWriter.Write((byte)0x30); // SEQUENCE - using (var paramsStream = new MemoryStream()) - { - var paramsWriter = new BinaryWriter(paramsStream); - //EncodeIntegerBigEndian(paramsWriter, parameters.Modulus); // Modulus - //EncodeIntegerBigEndian(paramsWriter, parameters.Exponent); // Exponent - var paramsLength = (int)paramsStream.Length; - EncodeLength(bitStringWriter, paramsLength); - bitStringWriter.Write(paramsStream.GetBuffer(), 0, paramsLength); - } - var bitStringLength = (int)bitStringStream.Length; - EncodeLength(innerWriter, bitStringLength); - innerWriter.Write(bitStringStream.GetBuffer(), 0, bitStringLength); - } - var length = (int)innerStream.Length; - EncodeLength(writer, length); - writer.Write(innerStream.GetBuffer(), 0, length); - } - - var base64 = Convert.ToBase64String(stream.GetBuffer(), 0, (int)stream.Length).ToCharArray(); - // WriteLine terminates with \r\n, we want only \n - outputStream.Write("-----BEGIN PUBLIC KEY-----\n"); - for (var i = 0; i < base64.Length; i += 64) - { - outputStream.Write(base64, i, Math.Min(64, base64.Length - i)); - outputStream.Write("\n"); - } - outputStream.Write("-----END PUBLIC KEY-----"); - } - - return outputStream.ToString(); - } - - private static void EncodeLength(BinaryWriter stream, int length) - { - if (length < 0) throw new ArgumentOutOfRangeException("length", "Length must be non-negative"); - if (length < 0x80) - { - // Short form - stream.Write((byte)length); - } - else - { - // Long form - var temp = length; - var bytesRequired = 0; - while (temp > 0) - { - temp >>= 8; - bytesRequired++; - } - stream.Write((byte)(bytesRequired | 0x80)); - for (var i = bytesRequired - 1; i >= 0; i--) - { - stream.Write((byte)(length >> (8 * i) & 0xff)); - } - } - } - - } -} diff --git a/src/BirdsiteLive.Cryptography/RsaKeys.cs b/src/BirdsiteLive.Cryptography/RsaKeys.cs deleted file mode 100644 index 0bc4a90..0000000 --- a/src/BirdsiteLive.Cryptography/RsaKeys.cs +++ /dev/null @@ -1,225 +0,0 @@ -using Org.BouncyCastle.Crypto; -using Org.BouncyCastle.Crypto.Parameters; -using Org.BouncyCastle.OpenSsl; -using Org.BouncyCastle.Security; -using System; -using System.IO; -using System.Security.Cryptography; - -namespace MyProject.Data.Encryption -{ - public class RSAKeys - { - /// - /// Import OpenSSH PEM private key string into MS RSACryptoServiceProvider - /// - /// - /// - public static RSACryptoServiceProvider ImportPrivateKey(string pem) - { - PemReader pr = new PemReader(new StringReader(pem)); - AsymmetricCipherKeyPair KeyPair = (AsymmetricCipherKeyPair)pr.ReadObject(); - RSAParameters rsaParams = DotNetUtilities.ToRSAParameters((RsaPrivateCrtKeyParameters)KeyPair.Private); - - RSACryptoServiceProvider csp = new RSACryptoServiceProvider();// cspParams); - csp.ImportParameters(rsaParams); - return csp; - } - - /// - /// Import OpenSSH PEM public key string into MS RSACryptoServiceProvider - /// - /// - /// - public static RSACryptoServiceProvider ImportPublicKey(string pem) - { - PemReader pr = new PemReader(new StringReader(pem)); - AsymmetricKeyParameter publicKey = (AsymmetricKeyParameter)pr.ReadObject(); - RSAParameters rsaParams = DotNetUtilities.ToRSAParameters((RsaKeyParameters)publicKey); - - RSACryptoServiceProvider csp = new RSACryptoServiceProvider();// cspParams); - csp.ImportParameters(rsaParams); - return csp; - } - - /// - /// Export private (including public) key from MS RSACryptoServiceProvider into OpenSSH PEM string - /// slightly modified from https://stackoverflow.com/a/23739932/2860309 - /// - /// - /// - public static string ExportPrivateKey(RSACryptoServiceProvider csp) - { - StringWriter outputStream = new StringWriter(); - if (csp.PublicOnly) throw new ArgumentException("CSP does not contain a private key", "csp"); - var parameters = csp.ExportParameters(true); - using (var stream = new MemoryStream()) - { - var writer = new BinaryWriter(stream); - writer.Write((byte)0x30); // SEQUENCE - using (var innerStream = new MemoryStream()) - { - var innerWriter = new BinaryWriter(innerStream); - EncodeIntegerBigEndian(innerWriter, new byte[] { 0x00 }); // Version - EncodeIntegerBigEndian(innerWriter, parameters.Modulus); - EncodeIntegerBigEndian(innerWriter, parameters.Exponent); - EncodeIntegerBigEndian(innerWriter, parameters.D); - EncodeIntegerBigEndian(innerWriter, parameters.P); - EncodeIntegerBigEndian(innerWriter, parameters.Q); - EncodeIntegerBigEndian(innerWriter, parameters.DP); - EncodeIntegerBigEndian(innerWriter, parameters.DQ); - EncodeIntegerBigEndian(innerWriter, parameters.InverseQ); - var length = (int)innerStream.Length; - EncodeLength(writer, length); - writer.Write(innerStream.GetBuffer(), 0, length); - } - - var base64 = Convert.ToBase64String(stream.GetBuffer(), 0, (int)stream.Length).ToCharArray(); - // WriteLine terminates with \r\n, we want only \n - outputStream.Write("-----BEGIN RSA PRIVATE KEY-----\n"); - // Output as Base64 with lines chopped at 64 characters - for (var i = 0; i < base64.Length; i += 64) - { - outputStream.Write(base64, i, Math.Min(64, base64.Length - i)); - outputStream.Write("\n"); - } - outputStream.Write("-----END RSA PRIVATE KEY-----"); - } - - return outputStream.ToString(); - } - - /// - /// Export public key from MS RSACryptoServiceProvider into OpenSSH PEM string - /// slightly modified from https://stackoverflow.com/a/28407693 - /// - /// - /// - public static string ExportPublicKey(RSACryptoServiceProvider csp) - { - StringWriter outputStream = new StringWriter(); - var parameters = csp.ExportParameters(false); - using (var stream = new MemoryStream()) - { - var writer = new BinaryWriter(stream); - writer.Write((byte)0x30); // SEQUENCE - using (var innerStream = new MemoryStream()) - { - var innerWriter = new BinaryWriter(innerStream); - innerWriter.Write((byte)0x30); // SEQUENCE - EncodeLength(innerWriter, 13); - innerWriter.Write((byte)0x06); // OBJECT IDENTIFIER - var rsaEncryptionOid = new byte[] { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01 }; - EncodeLength(innerWriter, rsaEncryptionOid.Length); - innerWriter.Write(rsaEncryptionOid); - innerWriter.Write((byte)0x05); // NULL - EncodeLength(innerWriter, 0); - innerWriter.Write((byte)0x03); // BIT STRING - using (var bitStringStream = new MemoryStream()) - { - var bitStringWriter = new BinaryWriter(bitStringStream); - bitStringWriter.Write((byte)0x00); // # of unused bits - bitStringWriter.Write((byte)0x30); // SEQUENCE - using (var paramsStream = new MemoryStream()) - { - var paramsWriter = new BinaryWriter(paramsStream); - EncodeIntegerBigEndian(paramsWriter, parameters.Modulus); // Modulus - EncodeIntegerBigEndian(paramsWriter, parameters.Exponent); // Exponent - var paramsLength = (int)paramsStream.Length; - EncodeLength(bitStringWriter, paramsLength); - bitStringWriter.Write(paramsStream.GetBuffer(), 0, paramsLength); - } - var bitStringLength = (int)bitStringStream.Length; - EncodeLength(innerWriter, bitStringLength); - innerWriter.Write(bitStringStream.GetBuffer(), 0, bitStringLength); - } - var length = (int)innerStream.Length; - EncodeLength(writer, length); - writer.Write(innerStream.GetBuffer(), 0, length); - } - - var base64 = Convert.ToBase64String(stream.GetBuffer(), 0, (int)stream.Length).ToCharArray(); - // WriteLine terminates with \r\n, we want only \n - outputStream.Write("-----BEGIN PUBLIC KEY-----\n"); - for (var i = 0; i < base64.Length; i += 64) - { - outputStream.Write(base64, i, Math.Min(64, base64.Length - i)); - outputStream.Write("\n"); - } - outputStream.Write("-----END PUBLIC KEY-----"); - } - - return outputStream.ToString(); - } - - /// - /// https://stackoverflow.com/a/23739932/2860309 - /// - /// - /// - private static void EncodeLength(BinaryWriter stream, int length) - { - if (length < 0) throw new ArgumentOutOfRangeException("length", "Length must be non-negative"); - if (length < 0x80) - { - // Short form - stream.Write((byte)length); - } - else - { - // Long form - var temp = length; - var bytesRequired = 0; - while (temp > 0) - { - temp >>= 8; - bytesRequired++; - } - stream.Write((byte)(bytesRequired | 0x80)); - for (var i = bytesRequired - 1; i >= 0; i--) - { - stream.Write((byte)(length >> (8 * i) & 0xff)); - } - } - } - - /// - /// https://stackoverflow.com/a/23739932/2860309 - /// - /// - /// - /// - private static void EncodeIntegerBigEndian(BinaryWriter stream, byte[] value, bool forceUnsigned = true) - { - stream.Write((byte)0x02); // INTEGER - var prefixZeros = 0; - for (var i = 0; i < value.Length; i++) - { - if (value[i] != 0) break; - prefixZeros++; - } - if (value.Length - prefixZeros == 0) - { - EncodeLength(stream, 1); - stream.Write((byte)0); - } - else - { - if (forceUnsigned && value[prefixZeros] > 0x7f) - { - // Add a prefix zero to force unsigned if the MSB is 1 - EncodeLength(stream, value.Length - prefixZeros + 1); - stream.Write((byte)0); - } - else - { - EncodeLength(stream, value.Length - prefixZeros); - } - for (var i = prefixZeros; i < value.Length; i++) - { - stream.Write(value[i]); - } - } - } - } -} \ No newline at end of file diff --git a/src/BirdsiteLive.Domain/StatusService.cs b/src/BirdsiteLive.Domain/StatusService.cs index 06f1ced..a10d8b5 100644 --- a/src/BirdsiteLive.Domain/StatusService.cs +++ b/src/BirdsiteLive.Domain/StatusService.cs @@ -11,8 +11,6 @@ using BirdsiteLive.Domain.Repository; using BirdsiteLive.Domain.Statistics; using BirdsiteLive.Domain.Tools; using BirdsiteLive.Twitter.Models; -using Tweetinvi.Models; -using Tweetinvi.Models.Entities; namespace BirdsiteLive.Domain { diff --git a/src/BirdsiteLive.Domain/Tools/ModerationRegexParser.cs b/src/BirdsiteLive.Domain/Tools/ModerationRegexParser.cs index 6f4df11..ce6a800 100644 --- a/src/BirdsiteLive.Domain/Tools/ModerationRegexParser.cs +++ b/src/BirdsiteLive.Domain/Tools/ModerationRegexParser.cs @@ -1,7 +1,6 @@ using System; using System.Text.RegularExpressions; using BirdsiteLive.Domain.Repository; -using Org.BouncyCastle.Pkcs; namespace BirdsiteLive.Domain.Tools { diff --git a/src/BirdsiteLive.Domain/UserService.cs b/src/BirdsiteLive.Domain/UserService.cs index 96fdf7f..83d73fd 100644 --- a/src/BirdsiteLive.Domain/UserService.cs +++ b/src/BirdsiteLive.Domain/UserService.cs @@ -17,8 +17,6 @@ using BirdsiteLive.Domain.Statistics; using BirdsiteLive.Domain.Tools; using BirdsiteLive.Twitter; using BirdsiteLive.Twitter.Models; -using Tweetinvi.Core.Exceptions; -using Tweetinvi.Models; namespace BirdsiteLive.Domain { diff --git a/src/BirdsiteLive.Pipeline/Models/UserWithDataToSync.cs b/src/BirdsiteLive.Pipeline/Models/UserWithDataToSync.cs index c5e6639..9773fc2 100644 --- a/src/BirdsiteLive.Pipeline/Models/UserWithDataToSync.cs +++ b/src/BirdsiteLive.Pipeline/Models/UserWithDataToSync.cs @@ -1,6 +1,5 @@ using BirdsiteLive.DAL.Models; using BirdsiteLive.Twitter.Models; -using Tweetinvi.Models; namespace BirdsiteLive.Pipeline.Models { diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs index f4a48ba..6e2764d 100644 --- a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs @@ -12,7 +12,6 @@ using BirdsiteLive.Twitter; using BirdsiteLive.Twitter.Models; using BirdsiteLive.Common.Settings; using Microsoft.Extensions.Logging; -using Tweetinvi.Models; namespace BirdsiteLive.Pipeline.Processors { diff --git a/src/BirdsiteLive.Pipeline/Processors/SendTweetsToFollowersProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/SendTweetsToFollowersProcessor.cs index 745c170..2663287 100644 --- a/src/BirdsiteLive.Pipeline/Processors/SendTweetsToFollowersProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/SendTweetsToFollowersProcessor.cs @@ -16,7 +16,6 @@ using BirdsiteLive.Pipeline.Processors.SubTasks; using BirdsiteLive.Twitter; using BirdsiteLive.Twitter.Models; using Microsoft.Extensions.Logging; -using Tweetinvi.Models; namespace BirdsiteLive.Pipeline.Processors { diff --git a/src/BirdsiteLive/BirdsiteLive.csproj b/src/BirdsiteLive/BirdsiteLive.csproj index b5d2746..43dedc9 100644 --- a/src/BirdsiteLive/BirdsiteLive.csproj +++ b/src/BirdsiteLive/BirdsiteLive.csproj @@ -24,7 +24,4 @@ - - - diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/CachedTweetsPostgresDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/CachedTweetsPostgresDal.cs deleted file mode 100644 index b95d5d1..0000000 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/CachedTweetsPostgresDal.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using BirdsiteLive.DAL.Contracts; -using BirdsiteLive.DAL.Models; -using BirdsiteLive.DAL.Postgres.DataAccessLayers.Base; -using BirdsiteLive.DAL.Postgres.Settings; -using BirdsiteLive.DAL.Postgres.Tools; -using Dapper; -using Newtonsoft.Json; -using Tweetinvi.Models; - -namespace BirdsiteLive.DAL.Postgres.DataAccessLayers -{ - public class CachedTweetsPostgresDal : PostgresBase, ICachedTweetsDal - { - #region Ctor - public CachedTweetsPostgresDal(PostgresSettings settings) : base(settings) - { - - } - #endregion - - public async Task CreateTweetAsync(long tweetId, int userId, CachedTweet tweet) - { - if(tweetId == default) throw new ArgumentException("tweetId"); - if(userId == default) throw new ArgumentException("userId"); - - var serializedData = JsonConvert.SerializeObject(tweet); - - using (var dbConnection = Connection) - { - dbConnection.Open(); - - await dbConnection.ExecuteAsync( - $"INSERT INTO {_settings.CachedTweetsTableName} (id,twitterUserId,data) VALUES(@id,@twitterUserId,CAST(@data as json))", - new { id = tweetId, twitterUserId = userId, data = serializedData }); - } - } - - public async Task GetTweetAsync(long tweetId) - { - if (tweetId == default) throw new ArgumentException("tweetId"); - - var query = $"SELECT * FROM {_settings.CachedTweetsTableName} WHERE id = @id"; - - using (var dbConnection = Connection) - { - dbConnection.Open(); - - var result = (await dbConnection.QueryAsync(query, new { id = tweetId })).FirstOrDefault(); - return Convert(result); - } - } - - public async Task DeleteTweetAsync(long tweetId) - { - if (tweetId == default) throw new ArgumentException("tweetId"); - - var query = $"DELETE FROM {_settings.CachedTweetsTableName} WHERE id = @id"; - - using (var dbConnection = Connection) - { - dbConnection.Open(); - - await dbConnection.QueryAsync(query, new { id = tweetId }); - } - } - - private CachedTweet Convert(SerializedTweet result) - { - if (result == null || string.IsNullOrWhiteSpace(result.Data)) return null; - return JsonConvert.DeserializeObject(result.Data); - } - } - - internal class SerializedTweet - { - public long Id { get; set; } - public int TwitterUserId { get; set; } - public string Data { get; set; } - } -} \ No newline at end of file diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs index 6256d03..eff4c12 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs @@ -7,7 +7,6 @@ using BirdsiteLive.DAL.Models; using BirdsiteLive.DAL.Postgres.DataAccessLayers.Base; using BirdsiteLive.DAL.Postgres.Settings; using Dapper; -using Newtonsoft.Json; using System.Text.Json; using Npgsql; @@ -27,7 +26,7 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers if(followings == null) followings = new int[0]; if(followingSyncStatus == null) followingSyncStatus = new Dictionary(); - var serializedDic = JsonConvert.SerializeObject(followingSyncStatus); + var serializedDic = JsonSerializer.Serialize(followingSyncStatus); acct = acct.ToLowerInvariant(); host = host.ToLowerInvariant(); @@ -205,7 +204,7 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers ActorId = follower.ActorId, SharedInboxRoute = follower.SharedInboxRoute, Followings = follower.Followings.ToList(), - FollowingsSyncStatus = JsonConvert.DeserializeObject>(follower.FollowingsSyncStatus), + FollowingsSyncStatus = JsonSerializer.Deserialize>(follower.FollowingsSyncStatus), PostingErrorCount = follower.PostingErrorCount }; } diff --git a/src/DataAccessLayers/BirdsiteLive.DAL/BirdsiteLive.DAL.csproj b/src/DataAccessLayers/BirdsiteLive.DAL/BirdsiteLive.DAL.csproj index 84e0bf0..03324f0 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL/BirdsiteLive.DAL.csproj +++ b/src/DataAccessLayers/BirdsiteLive.DAL/BirdsiteLive.DAL.csproj @@ -5,7 +5,6 @@ - diff --git a/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/ICachedTweetsDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/ICachedTweetsDal.cs index 64ffe41..504b58f 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/ICachedTweetsDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/ICachedTweetsDal.cs @@ -1,6 +1,5 @@ using System.Threading.Tasks; using BirdsiteLive.DAL.Models; -using Tweetinvi.Models; namespace BirdsiteLive.DAL.Contracts { diff --git a/src/Tests/BirdsiteLive.Cryptography.Tests/RsaGeneratorTests.cs b/src/Tests/BirdsiteLive.Cryptography.Tests/RsaGeneratorTests.cs deleted file mode 100644 index 639c392..0000000 --- a/src/Tests/BirdsiteLive.Cryptography.Tests/RsaGeneratorTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace BirdsiteLive.Cryptography.Tests -{ - [TestClass] - public class RsaGeneratorTests - { - [TestMethod] - public void TestMethod1() - { - var rsaGen = new RsaGenerator(); - var rsa = rsaGen.GetRsa(); - } - } -} diff --git a/src/Tests/BirdsiteLive.Cryptography.Tests/RsaKeysTests.cs b/src/Tests/BirdsiteLive.Cryptography.Tests/RsaKeysTests.cs deleted file mode 100644 index 2e4ae5e..0000000 --- a/src/Tests/BirdsiteLive.Cryptography.Tests/RsaKeysTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -//using System.Security.Cryptography; -//using Microsoft.VisualStudio.TestTools.UnitTesting; -//using MyProject.Data.Encryption; - -//namespace BirdsiteLive.Cryptography.Tests -//{ -// [TestClass] -// public class RsaKeysTests -// { -// [TestMethod] -// public void TestMethod1() -// { -// var rsa = RSA.Create(); - -// var cspParams = new CspParameters(); -// cspParams.ProviderType = 1; // PROV_RSA_FULL -// cspParams.Flags = CspProviderFlags.CreateEphemeralKey; -// var rsaProvider = new RSACryptoServiceProvider(2048, cspParams); - -// var rsaPublicKey = RSAKeys.ExportPublicKey(rsaProvider); -// var rsaPrivateKey = RSAKeys.ExportPrivateKey(rsaProvider); - -// //rsaProvider. - -// var pem = RSAKeys.ImportPublicKey(rsaPrivateKey); -// } - -// [TestMethod] -// public void TestMethod2() -// { - -// } -// } -//} \ No newline at end of file diff --git a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/CachedTweetsPostgresDalTests.cs b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/CachedTweetsPostgresDalTests.cs deleted file mode 100644 index 24672c3..0000000 --- a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/CachedTweetsPostgresDalTests.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Threading.Tasks; -using BirdsiteLive.DAL.Models; -using BirdsiteLive.DAL.Postgres.DataAccessLayers; -using BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers.Base; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers -{ - [TestClass] - public class CachedTweetsPostgresDalTests : PostgresTestingBase - { - [TestInitialize] - public async Task TestInit() - { - var dal = new DbInitializerPostgresDal(_settings, _tools); - var init = new DatabaseInitializer(dal); - await init.InitAndMigrateDbAsync(); - } - - [TestCleanup] - public async Task CleanUp() - { - var dal = new DbInitializerPostgresDal(_settings, _tools); - await dal.DeleteAllAsync(); - } - - [TestMethod] - public async Task CreateAndGet() - { - var id = 152L; - var userId = 15; - - var tweet = new CachedTweet - { - UserId = userId, - Id = id, - Text = "text data", - FullText = "full text data", - CreatedAt = DateTime.UtcNow - }; - - var dal = new CachedTweetsPostgresDal(_settings); - await dal.CreateTweetAsync(id, userId, tweet); - - var result = await dal.GetTweetAsync(id); - - Assert.IsNotNull(result); - Assert.AreEqual(id, result.Id); - Assert.AreEqual(tweet.Text, result.Text); - Assert.AreEqual(tweet.FullText, result.FullText); - Assert.AreEqual(tweet.CreatedAt, result.CreatedAt); - } - - [TestMethod] - public async Task CreateAndDelete() - { - var id = 152L; - var userId = 15; - - var tweet = new CachedTweet - { - UserId = userId, - Id = id, - Text = "text data", - FullText = "full text data", - CreatedAt = DateTime.UtcNow - }; - - var dal = new CachedTweetsPostgresDal(_settings); - await dal.CreateTweetAsync(id, userId, tweet); - - var result = await dal.GetTweetAsync(id); - Assert.IsNotNull(result); - - await dal.DeleteTweetAsync(id); - result = await dal.GetTweetAsync(id); - Assert.IsNull(result); - } - } -} \ No newline at end of file diff --git a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs index 0fb03ae..17c4fec 100644 --- a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs +++ b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs @@ -5,7 +5,6 @@ using BirdsiteLive.DAL.Models; using BirdsiteLive.Domain.BusinessUseCases; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -using Org.BouncyCastle.Crypto.Prng; namespace BirdsiteLive.Domain.Tests.BusinessUseCases {