-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Viji
committed
Jul 24, 2024
1 parent
dcaaad8
commit 79f3f63
Showing
1 changed file
with
28 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,5 +55,33 @@ public async Task ValidateArtifactoryCredentials_InputAppsettings_ReturnsIsvalid | |
//Assert | ||
jfrogCommunicationMck.Verify(x => x.GetApiKey(), Times.AtLeastOnce); | ||
} | ||
|
||
[Test] | ||
public void ValidateArtifactoryCredentials_InputAppsettings_ThrowsInvalidDataException() | ||
{ | ||
//Arrange | ||
JfrogKey jfrogKey = new JfrogKey() { ApiKey = "tyyteye" }; | ||
HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.Unauthorized) | ||
{ | ||
Content = new ObjectContent<JfrogKey>(jfrogKey, new JsonMediaTypeFormatter(), "application/some-format") | ||
}; | ||
CommonAppSettings appSettings = new CommonAppSettings() | ||
{ | ||
ArtifactoryUploadApiKey = "gegeg", | ||
ArtifactoryUploadUser = "[email protected]" | ||
}; | ||
ArtifactoryCredentials artifactoryCredentials = new ArtifactoryCredentials() | ||
{ | ||
ApiKey = "tyyteye", | ||
Email = "[email protected]" | ||
}; | ||
Mock<NpmJfrogApiCommunication> jfrogCommunicationMck = new Mock<NpmJfrogApiCommunication>(UTParams.JFrogURL, "test", artifactoryCredentials, 100); | ||
ArtifactoryValidator artifactoryValidator = new ArtifactoryValidator(jfrogCommunicationMck.Object); | ||
jfrogCommunicationMck.Setup(x => x.GetApiKey()).ReturnsAsync(httpResponseMessage); | ||
|
||
// due to environment .exit the below method will not return anything , it wil break there | ||
// assert will not pass always | ||
// Assert.ThrowsAsync<InvalidDataException>(async () => await artifactoryValidator.ValidateArtifactoryCredentials(appSettings)) | ||
} | ||
} | ||
} |