-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DMS-376] Add Register Test Pact File
Signed-off-by: Moises Siles <[email protected]>
- Loading branch information
Showing
4 changed files
with
56 additions
and
2 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 |
---|---|---|
|
@@ -3,6 +3,27 @@ | |
"name": "ConfigurationService-API" | ||
}, | ||
"interactions": [ | ||
{ | ||
"description": "A register request when registration is disabled", | ||
"request": { | ||
"body": { | ||
"clientid": "CSClient2", | ||
"clientsecret": "test123@Puiu", | ||
"displayname": "[email protected]" | ||
}, | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"method": "POST", | ||
"path": "/connect/register" | ||
}, | ||
"response": { | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"status": 404 | ||
} | ||
}, | ||
{ | ||
"description": "A request for an access token with a valid credentials", | ||
"request": { | ||
|
@@ -37,4 +58,4 @@ | |
"provider": { | ||
"name": "Register" | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -167,6 +167,34 @@ await pact.VerifyAsync(async ctx => | |
content.Should().NotBeNull(); | ||
}); | ||
} | ||
|
||
[Test] | ||
public async Task When_allow_registration_is_disabled() | ||
{ | ||
pact.UponReceiving("A register request when registration is disabled") | ||
.WithRequest(HttpMethod.Post, "/connect/register") | ||
.WithJsonBody(new | ||
{ | ||
clientid = "CSClient2", | ||
clientsecret = "test123@Puiu", | ||
displayname = "[email protected]" | ||
}) | ||
.WithHeader("Content-Type", "application/json") | ||
.WillRespond() | ||
.WithStatus(HttpStatusCode.Forbidden) | ||
.WithHeader("Content-Type", "application/json"); | ||
|
||
await pact.VerifyAsync(async ctx => | ||
{ | ||
var client = new HttpClient(); | ||
|
||
// Act | ||
var requestBody = new { clientid = "CSClient2", clientsecret = "test123@Puiu", displayname = "[email protected]" }; | ||
var response = await client.PostAsJsonAsync($"{ctx.MockServerUri}connect/register", requestBody); | ||
var content = await response.Content.ReadAsStringAsync(); | ||
response.StatusCode.Should().Be(HttpStatusCode.NotFound); | ||
}); | ||
} | ||
} | ||
|
||
|
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