-
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-443] Update content type to url encoded (#372)
* Update content type to url encoded * update the default realm * Setup .net version * Add setup dotnet to config pull request file * Update the response to match admin api * set the .net version on dms pull request file * Format C# --------- Co-authored-by: Adam Hopkins <[email protected]>
- Loading branch information
1 parent
edad6e3
commit d09533e
Showing
6 changed files
with
118 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
using System.Net; | ||
using System.Net.Http.Json; | ||
using System.Text.Json.Nodes; | ||
using EdFi.DmsConfigurationService.Backend; | ||
using EdFi.DmsConfigurationService.Backend.Repositories; | ||
|
@@ -62,13 +61,14 @@ public async Task Given_valid_client_details() | |
using var client = factory.CreateClient(); | ||
|
||
// Act | ||
var requestContent = new | ||
{ | ||
clientid = "CSClient1", | ||
clientsecret = "test123@Puiu", | ||
displayname = "CSClient1", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", "CSClient1"), | ||
new KeyValuePair<string, string>("clientsecret", "test123@Puiu"), | ||
new KeyValuePair<string, string>("displayname", "CSClient1"), | ||
] | ||
); | ||
var response = await client.PostAsync("/connect/register", requestContent); | ||
string content = await response.Content.ReadAsStringAsync(); | ||
|
||
// Assert | ||
|
@@ -94,13 +94,14 @@ public async Task Given_empty_client_details() | |
using var client = factory.CreateClient(); | ||
|
||
// Act | ||
var requestContent = new | ||
{ | ||
clientid = "", | ||
clientsecret = "", | ||
displayname = "", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", ""), | ||
new KeyValuePair<string, string>("clientsecret", ""), | ||
new KeyValuePair<string, string>("displayname", ""), | ||
] | ||
); | ||
var response = await client.PostAsync("/connect/register", requestContent); | ||
string content = await response.Content.ReadAsStringAsync(); | ||
content = System.Text.RegularExpressions.Regex.Unescape(content); | ||
|
||
|
@@ -135,13 +136,14 @@ public async Task Given_invalid_client_secret(string secret) | |
using var client = factory.CreateClient(); | ||
|
||
// Act | ||
var requestContent = new | ||
{ | ||
clientid = "CSClient2", | ||
clientsecret = secret, | ||
displayname = "[email protected]", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", "CSClient2"), | ||
new KeyValuePair<string, string>("clientsecret", secret), | ||
new KeyValuePair<string, string>("displayname", "[email protected]"), | ||
] | ||
); | ||
var response = await client.PostAsync("/connect/register", requestContent); | ||
string content = await response.Content.ReadAsStringAsync(); | ||
|
||
// Assert | ||
|
@@ -178,13 +180,14 @@ public async Task When_provider_has_bad_credentials() | |
using var client = factory.CreateClient(); | ||
|
||
// Act | ||
var requestContent = new | ||
{ | ||
clientid = "CSClient3", | ||
clientsecret = "test123@Puiu", | ||
displayname = "CSClient3", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", "CSClient3"), | ||
new KeyValuePair<string, string>("clientsecret", "test123@Puiu"), | ||
new KeyValuePair<string, string>("displayname", "CSClient3"), | ||
] | ||
); | ||
var response = await client.PostAsync("/connect/register", requestContent); | ||
string content = await response.Content.ReadAsStringAsync(); | ||
|
||
// Assert | ||
|
@@ -217,13 +220,14 @@ public async Task When_provider_has_not_real_admin_role() | |
using var client = factory.CreateClient(); | ||
|
||
// Act | ||
var requestContent = new | ||
{ | ||
clientid = "CSClient3", | ||
clientsecret = "test123@Puiu", | ||
displayname = "CSClient3", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", "CSClient3"), | ||
new KeyValuePair<string, string>("clientsecret", "test123@Puiu"), | ||
new KeyValuePair<string, string>("displayname", "CSClient3"), | ||
] | ||
); | ||
var response = await client.PostAsync("/connect/register", requestContent); | ||
string content = await response.Content.ReadAsStringAsync(); | ||
|
||
// Assert | ||
|
@@ -256,13 +260,14 @@ public async Task When_provider_has_invalid_real() | |
using var client = factory.CreateClient(); | ||
|
||
// Act | ||
var requestContent = new | ||
{ | ||
clientid = "CSClient3", | ||
clientsecret = "test123@Puiu", | ||
displayname = "CSClient3", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", "CSClient3"), | ||
new KeyValuePair<string, string>("clientsecret", "test123@Puiu"), | ||
new KeyValuePair<string, string>("displayname", "CSClient3"), | ||
] | ||
); | ||
var response = await client.PostAsync("/connect/register", requestContent); | ||
string content = await response.Content.ReadAsStringAsync(); | ||
|
||
// Assert | ||
|
@@ -294,13 +299,15 @@ public async Task Given_client_with_existing_client_id() | |
using var client = factory.CreateClient(); | ||
|
||
// Act | ||
var requestContent = new | ||
{ | ||
clientid = "CSClient2", | ||
clientsecret = "test123@Puiu", | ||
displayname = "[email protected]", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", "CSClient2"), | ||
new KeyValuePair<string, string>("clientsecret", "test123@Puiu"), | ||
new KeyValuePair<string, string>("displayname", "[email protected]"), | ||
] | ||
); | ||
|
||
var response = await client.PostAsync("/connect/register", requestContent); | ||
string content = await response.Content.ReadAsStringAsync(); | ||
|
||
// Assert | ||
|
@@ -332,13 +339,14 @@ public async Task When_allow_registration_is_disabled() | |
using var client = factory.CreateClient(); | ||
|
||
// Act | ||
var requestContent = new | ||
{ | ||
clientid = "CSClient2", | ||
clientsecret = "test123@Puiu", | ||
displayname = "[email protected]", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", "CSClient2"), | ||
new KeyValuePair<string, string>("clientsecret", "test123@Puiu"), | ||
new KeyValuePair<string, string>("displayname", "[email protected]"), | ||
] | ||
); | ||
var response = await client.PostAsync("/connect/register", requestContent); | ||
|
||
// Assert | ||
response.StatusCode.Should().Be(HttpStatusCode.Forbidden); | ||
|
@@ -371,13 +379,14 @@ public async Task When_provider_is_unreachable() | |
using var client = factory.CreateClient(); | ||
|
||
//Act | ||
var requestContent = new | ||
{ | ||
clientid = "CSClient3", | ||
clientsecret = "test123@Puiu", | ||
displayname = "CSClient3", | ||
}; | ||
var response = await client.PostAsJsonAsync("/connect/register", requestContent); | ||
var requestContent = new FormUrlEncodedContent( | ||
[ | ||
new KeyValuePair<string, string>("clientid", "CSClient3"), | ||
new KeyValuePair<string, string>("clientsecret", "test123@Puiu"), | ||
new KeyValuePair<string, string>("displayname", "CSClient3"), | ||
] | ||
); | ||
var response = await client.PostAsync("/connect/register", requestContent); | ||
string content = await response.Content.ReadAsStringAsync(); | ||
|
||
// Assert | ||
|
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