Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cred scan #179

Merged
merged 1 commit into from
Jan 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Kudu.Tests/Services/Models/EncryptedHostAssignmentContextTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Buffers.Text;
using System.Collections.Generic;
using System.Text;
using Kudu.Services.Models;
Expand All @@ -8,7 +9,6 @@ namespace Kudu.Tests.Services.Models
{
public class EncryptedHostAssignmentContextTests
{
private const string _encryptionKey = "MDEyMzQ1Njc4OUFCQ0RFRjAxMjM0NTY3ODlBQkNERUY=";
private const string _lastModifiedTime = "2019-01-15T15:53:00";
private HostAssignmentContext _context = new HostAssignmentContext() {
SiteId = 10,
Expand All @@ -29,24 +29,30 @@ public class EncryptedHostAssignmentContextTests
[Fact]
public void EncryptedContextShouldExistAfterCreate()
{
var result = EncryptedHostAssignmentContext.Create(_context, _encryptionKey);
var result = EncryptedHostAssignmentContext.Create(_context, GetMockedEncryptionKey());
Assert.NotEmpty(result.EncryptedContext);
}

[Fact]
public void DecryptedContextShouldMatchByEqual()
{
var encrypted = EncryptedHostAssignmentContext.Create(_context, _encryptionKey);
var decrypted = encrypted.Decrypt(_encryptionKey);
var encrypted = EncryptedHostAssignmentContext.Create(_context, GetMockedEncryptionKey());
var decrypted = encrypted.Decrypt(GetMockedEncryptionKey());
Assert.True(_context.Equals(decrypted));
}

[Fact]
public void DecryptedContextShouldMatchEnvironments()
{
var encrypted = EncryptedHostAssignmentContext.Create(_context, _encryptionKey);
var decrypted = encrypted.Decrypt(_encryptionKey);
var encrypted = EncryptedHostAssignmentContext.Create(_context, GetMockedEncryptionKey());
var decrypted = encrypted.Decrypt(GetMockedEncryptionKey());
Assert.Equal(_context.Environment, decrypted.Environment);
}

private string GetMockedEncryptionKey()
{
var bytes = Encoding.ASCII.GetBytes("0123456789ABCDEF0123456789ABCDEF");
return Convert.ToBase64String(bytes);
}
}
}