-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - trying to get integration tests to work
- Loading branch information
1 parent
96d40aa
commit 5b7ef78
Showing
13 changed files
with
162 additions
and
31 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
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
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
102 changes: 102 additions & 0 deletions
102
tests/Agent/UnitTests/NewRelic.Agent.Extensions.Tests/Helpers/AwsAccountIdDecoderTests.cs
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,102 @@ | ||
// Copyright 2020 New Relic, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System; | ||
using NewRelic.Agent.Extensions.AwsSdk; | ||
using NUnit.Framework; | ||
using Telerik.JustMock; | ||
|
||
namespace Agent.Extensions.Tests.Helpers | ||
{ | ||
[TestFixture] | ||
internal class AwsAccountIdDecoderTests | ||
{ | ||
[Test] | ||
public void GetAccountId_ValidAwsAccessKeyId_ReturnsExpectedAccountId() | ||
{ | ||
// Arrange | ||
string awsAccessKeyId = "AKIAIOSFODNN7EXAMPLE"; // not a real AWS access key! | ||
string expectedAccountId = "581039954779"; | ||
|
||
// Act | ||
string actualAccountId = AwsAccountIdDecoder.GetAccountId(awsAccessKeyId); | ||
|
||
// Assert | ||
Assert.That(expectedAccountId, Is.EqualTo(actualAccountId)); | ||
} | ||
|
||
[Test] | ||
public void GetAccountId_NullOrEmptyAwsAccessKeyId_ThrowsArgumentNullException() | ||
{ | ||
// Arrange | ||
string awsAccessKeyId = null; | ||
|
||
// Act & Assert | ||
var ex = Assert.Throws<ArgumentNullException>(() => AwsAccountIdDecoder.GetAccountId(awsAccessKeyId)); | ||
Assert.That(ex.ParamName, Is.EqualTo("awsAccessKeyId")); | ||
} | ||
|
||
[Test] | ||
public void GetAccountId_ShortAwsAccessKeyId_ThrowsArgumentOutOfRangeException() | ||
{ | ||
// Arrange | ||
string awsAccessKeyId = "AKIAIOSFODN"; | ||
|
||
// Act & Assert | ||
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => AwsAccountIdDecoder.GetAccountId(awsAccessKeyId)); | ||
Assert.That(ex.ParamName, Is.EqualTo("awsAccessKeyId")); | ||
} | ||
|
||
[Test] | ||
public void Base32Decode_ShortString_ThrowsArgumentException() | ||
{ | ||
// Arrange | ||
string shortString = "shortstr"; | ||
|
||
// Act & Assert | ||
var ex = Assert.Throws<ArgumentException>(() => AwsAccountIdDecoder.Base32Decode(shortString)); | ||
Assert.That(ex.ParamName, Is.EqualTo("src")); | ||
} | ||
|
||
[Test] | ||
public void Base32Decode_InvalidCharacters_ThrowsArgumentOutOfRangeException() | ||
{ | ||
// Arrange | ||
string invalidBase32String = "someBogusbase32string"; | ||
|
||
// Act & Assert | ||
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => AwsAccountIdDecoder.Base32Decode(invalidBase32String)); | ||
Assert.That(ex.ParamName, Is.EqualTo("src")); | ||
} | ||
|
||
[Test] | ||
public void Base32Decode_NullOrEmptyString_ThrowsArgumentNullException() | ||
{ | ||
// Arrange | ||
string nullString = null; | ||
string emptyString = string.Empty; | ||
|
||
// Act & Assert | ||
var exNull = Assert.Throws<ArgumentNullException>(() => AwsAccountIdDecoder.Base32Decode(nullString)); | ||
Assert.That(exNull.ParamName, Is.EqualTo("src")); | ||
|
||
var exEmpty = Assert.Throws<ArgumentNullException>(() => AwsAccountIdDecoder.Base32Decode(emptyString)); | ||
Assert.That(exEmpty.ParamName, Is.EqualTo("src")); | ||
} | ||
|
||
[Test] | ||
public void Base32Decode_ValidBase32String_ReturnsDecodedLong() | ||
{ | ||
// Arrange | ||
string validBase32String = "iosfodnn7example"; // Example valid Base32 string (10 characters) | ||
long expectedDecodedValue = 74373114211833L; | ||
|
||
// Act | ||
long decodedValue = AwsAccountIdDecoder.Base32Decode(validBase32String); | ||
|
||
// Assert | ||
Assert.That(decodedValue, Is.EqualTo(expectedDecodedValue)); // Adjust expected value based on actual decoding logic | ||
} | ||
|
||
} | ||
} |