Skip to content

Commit

Permalink
Merge pull request #252 from mattosaurus/refactor/remove-obsolete-met…
Browse files Browse the repository at this point in the history
…hods

Refactor/remove obsolete methods
  • Loading branch information
mattosaurus authored Nov 24, 2023
2 parents 8535de9 + 55ded3a commit dc66276
Show file tree
Hide file tree
Showing 47 changed files with 4,276 additions and 11,644 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
analyze:
runs-on: windows-latest
steps:
- name: Set up JDK 21
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- uses: actions/checkout@v3
with:
Expand Down
Empty file added IPGPEncryptAsync.cs
Empty file.
36 changes: 18 additions & 18 deletions PgpCore.Tests/TestFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,45 @@ public TestFactory(string uniqueIdentifier)

public string Content => Constants.CONTENT;

public string ContentFilePath => $"{ContentDirectory}{Constants.CONTENTFILENAME}";
private string ContentFilePath => $"{ContentDirectory}{Constants.CONTENTFILENAME}";

public FileInfo ContentFileInfo => new FileInfo(ContentFilePath);

public Stream ContentStream => GetFileStream(ContentFileInfo);

public string EncryptedContentFilePath => $"{ContentDirectory}{Constants.ENCRYPTEDCONTENTFILENAME}";
private string EncryptedContentFilePath => $"{ContentDirectory}{Constants.ENCRYPTEDCONTENTFILENAME}";

public FileInfo EncryptedContentFileInfo => new FileInfo(EncryptedContentFilePath);

public string EncryptedContent => File.ReadAllText(EncryptedContentFilePath);

public Stream EncryptedContentStream => GetFileStream(EncryptedContentFileInfo);

public string SignedContentFilePath => $"{ContentDirectory}{Constants.SIGNEDCONTENTFILENAME}";
private string SignedContentFilePath => $"{ContentDirectory}{Constants.SIGNEDCONTENTFILENAME}";

public FileInfo SignedContentFileInfo => new FileInfo(SignedContentFilePath);

public string SignedContent => File.ReadAllText(SignedContentFilePath);

public Stream SignedContentStream => GetFileStream(SignedContentFileInfo);

public string DecryptedContentFilePath => $"{ContentDirectory}{Constants.DECRYPTEDCONTENTFILENAME}";
private string DecryptedContentFilePath => $"{ContentDirectory}{Constants.DECRYPTEDCONTENTFILENAME}";

public FileInfo DecryptedContentFileInfo => new FileInfo(DecryptedContentFilePath);

public string DecryptedContent => File.ReadAllText(DecryptedContentFilePath);

public Stream DecryptedContentStream => GetFileStream(DecryptedContentFileInfo);

public string PrivateKeyFilePath => $"{KeyDirectory}{Constants.PRIVATEKEYFILENAME}";
private string PrivateKeyFilePath => $"{KeyDirectory}{Constants.PRIVATEKEYFILENAME}";

public FileInfo PrivateKeyFileInfo => new FileInfo(PrivateKeyFilePath);

public string PrivateKey => File.ReadAllText(PrivateKeyFilePath);

public Stream PrivateKeyStream => GetFileStream(PrivateKeyFileInfo);

public string PublicKeyFilePath => $"{KeyDirectory}{Constants.PUBLICKEYFILENAME}";
private string PublicKeyFilePath => $"{KeyDirectory}{Constants.PUBLICKEYFILENAME}";

public FileInfo PublicKeyFileInfo => new FileInfo(PublicKeyFilePath);

Expand All @@ -88,16 +88,16 @@ public void Arrange(KeyType keyType)
// Create keys
if (keyType == KeyType.Generated)
{
pgp.GenerateKey(PublicKeyFilePath, PrivateKeyFilePath, UserName, Password);
pgp.GenerateKey(PublicKeyFileInfo, PrivateKeyFileInfo, UserName, Password);
}
else if (keyType == KeyType.Known)
{
using (StreamWriter streamWriter = File.CreateText(PublicKeyFilePath))
using (StreamWriter streamWriter = PublicKeyFileInfo.CreateText())
{
streamWriter.WriteLine(Constants.PUBLICKEY1);
}

using (StreamWriter streamWriter = File.CreateText(PrivateKeyFilePath))
using (StreamWriter streamWriter = PrivateKeyFileInfo.CreateText())
{
streamWriter.WriteLine(Constants.PRIVATEKEY1);
}
Expand All @@ -107,12 +107,12 @@ public void Arrange(KeyType keyType)
}
else if (keyType == KeyType.KnownGpg)
{
using (StreamWriter streamWriter = File.CreateText(PublicKeyFilePath))
using (StreamWriter streamWriter = PublicKeyFileInfo.CreateText())
{
streamWriter.WriteLine(Constants.PUBLICGPGKEY1);
}

using (StreamWriter streamWriter = File.CreateText(PrivateKeyFilePath))
using (StreamWriter streamWriter = PrivateKeyFileInfo.CreateText())
{
streamWriter.WriteLine(Constants.PRIVATEGPGKEY1);
}
Expand All @@ -130,16 +130,16 @@ public async Task ArrangeAsync(KeyType keyType)
// Create keys
if (keyType == KeyType.Generated)
{
pgp.GenerateKey(PublicKeyFilePath, PrivateKeyFilePath, UserName, Password);
pgp.GenerateKey(PublicKeyFileInfo, PrivateKeyFileInfo, UserName, Password);
}
else if (keyType == KeyType.Known)
{
using (StreamWriter streamWriter = File.CreateText(PublicKeyFilePath))
using (StreamWriter streamWriter = PublicKeyFileInfo.CreateText())
{
await streamWriter.WriteLineAsync(Constants.PUBLICKEY1);
}

using (StreamWriter streamWriter = File.CreateText(PrivateKeyFilePath))
using (StreamWriter streamWriter = PrivateKeyFileInfo.CreateText())
{
await streamWriter.WriteLineAsync(Constants.PRIVATEKEY1);
}
Expand All @@ -149,12 +149,12 @@ public async Task ArrangeAsync(KeyType keyType)
}
else if (keyType == KeyType.KnownGpg)
{
using (StreamWriter streamWriter = File.CreateText(PublicKeyFilePath))
using (StreamWriter streamWriter = PublicKeyFileInfo.CreateText())
{
await streamWriter.WriteLineAsync(Constants.PUBLICGPGKEY1);
}

using (StreamWriter streamWriter = File.CreateText(PrivateKeyFilePath))
using (StreamWriter streamWriter = PrivateKeyFileInfo.CreateText())
{
await streamWriter.WriteLineAsync(Constants.PRIVATEGPGKEY1);
}
Expand All @@ -171,7 +171,7 @@ public void Arrange(FileType fileType)
// Create content file
if (fileType == FileType.Known)
{
using (StreamWriter streamWriter = File.CreateText(ContentFilePath))
using (StreamWriter streamWriter = ContentFileInfo.CreateText())
{
streamWriter.WriteLine(Constants.CONTENT);
}
Expand All @@ -193,7 +193,7 @@ public async Task ArrangeAsync(FileType fileType)
// Create content file
if (fileType == FileType.Known)
{
using (StreamWriter streamWriter = File.CreateText(ContentFilePath))
using (StreamWriter streamWriter = ContentFileInfo.CreateText())
{
await streamWriter.WriteLineAsync(Constants.CONTENT);
}
Expand Down
Loading

0 comments on commit dc66276

Please sign in to comment.