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

Update fake credentials #498

Merged
merged 1 commit into from
Feb 23, 2023
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
Update fake credentials
  • Loading branch information
Tratcher committed Feb 23, 2023
commit 2153dc77aaa5f27b8d51e4a08bd62933d0ca12d0
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void Security_AuthorizeEndpointTests(HostType hostType)
Assert.Equal("invalid_client", jToken.SelectToken("error").Value<string>());

//grant_type=authorization_code - invalid code being sent
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "secret123"), new kvp("grant_type", "authorization_code"), new kvp("code", "InvalidCode"), new kvp("redirect_uri", Client_Redirect_Uri) });
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "Placeholder"), new kvp("grant_type", "authorization_code"), new kvp("code", "InvalidCode"), new kvp("redirect_uri", Client_Redirect_Uri) });
responseMessage = httpClient.PostAsync(tokenEndpointUri, formContent).Result.Content.ReadAsStringAsync().Result;
jToken = JToken.Parse(responseMessage);
Assert.Equal("invalid_grant", jToken.SelectToken("error").Value<string>());
Expand All @@ -146,7 +146,7 @@ public void Security_AuthorizeEndpointTests(HostType hostType)
Assert.Equal(Client_Redirect_Uri, landingUri.GetLeftPart(UriPartial.Path));
Assert.NotNull(landingUri.ParseQueryString()["code"]);
Assert.Equal("validstate", landingUri.ParseQueryString()["state"]);
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "secret123"), new kvp("grant_type", "authorization_code"), new kvp("code", landingUri.ParseQueryString()["code"]), new kvp("redirect_uri", Client_Redirect_Uri) });
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "Placeholder"), new kvp("grant_type", "authorization_code"), new kvp("code", landingUri.ParseQueryString()["code"]), new kvp("redirect_uri", Client_Redirect_Uri) });
responseMessage = httpClient.PostAsync(tokenEndpointUri, formContent).Result.Content.ReadAsStringAsync().Result;
jToken = JToken.Parse(responseMessage);
Assert.NotNull(jToken.SelectToken("access_token").Value<string>());
Expand All @@ -157,13 +157,13 @@ public void Security_AuthorizeEndpointTests(HostType hostType)
Assert.NotNull(jToken.SelectToken("refresh_token").Value<string>());

//grant_type=password -- Resource owner credentials -- Invalid credentials
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "secret123"), new kvp("grant_type", "password"), new kvp("username", "user1"), new kvp("password", "invalid"), new kvp("scope", "scope1 scope2 scope3") });
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "Placeholder"), new kvp("grant_type", "password"), new kvp("username", "user1"), new kvp("password", "invalid"), new kvp("scope", "scope1 scope2 scope3") });
responseMessage = httpClient.PostAsync(tokenEndpointUri, formContent).Result.Content.ReadAsStringAsync().Result;
jToken = JToken.Parse(responseMessage);
Assert.Equal("invalid_grant", jToken.SelectToken("error").Value<string>());

//grant_type=password -- Resource owner credentials
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "secret123"), new kvp("grant_type", "password"), new kvp("username", "user1"), new kvp("password", "password1"), new kvp("scope", "scope1 scope2 scope3") });
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "Placeholder"), new kvp("grant_type", "password"), new kvp("username", "user1"), new kvp("password", "password1"), new kvp("scope", "scope1 scope2 scope3") });
responseMessage = httpClient.PostAsync(tokenEndpointUri, formContent).Result.Content.ReadAsStringAsync().Result;
jToken = JToken.Parse(responseMessage);
Assert.NotNull(jToken.SelectToken("access_token").Value<string>());
Expand All @@ -174,7 +174,7 @@ public void Security_AuthorizeEndpointTests(HostType hostType)
Assert.NotNull(jToken.SelectToken("refresh_token").Value<string>());

//grant_type=refresh_token -- Use the refresh token issued on the previous call
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "secret123"), new kvp("grant_type", "refresh_token"), new kvp("refresh_token", jToken.SelectToken("refresh_token").Value<string>()), new kvp("scope", "scope1 scope2") });
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "Placeholder"), new kvp("grant_type", "refresh_token"), new kvp("refresh_token", jToken.SelectToken("refresh_token").Value<string>()), new kvp("scope", "scope1 scope2") });
responseMessage = httpClient.PostAsync(tokenEndpointUri, formContent).Result.Content.ReadAsStringAsync().Result;
jToken = JToken.Parse(responseMessage);
Assert.NotNull(jToken.SelectToken("access_token").Value<string>());
Expand All @@ -185,7 +185,7 @@ public void Security_AuthorizeEndpointTests(HostType hostType)
Assert.NotNull(jToken.SelectToken("refresh_token").Value<string>());

//grant_type=client_credentials - Bug# https://github.com/Katana/katana/issues/562
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "secret123"), new kvp("grant_type", "client_credentials"), new kvp("scope", "scope1 scope2 scope3") });
formContent = AuthZ.CreateTokenEndpointContent(new[] { new kvp("client_id", "123"), new kvp("client_secret", "Placeholder"), new kvp("grant_type", "client_credentials"), new kvp("scope", "scope1 scope2 scope3") });
responseMessage = httpClient.PostAsync(tokenEndpointUri, formContent).Result.Content.ReadAsStringAsync().Result;
jToken = JToken.Parse(responseMessage);
Assert.NotNull(jToken.SelectToken("access_token").Value<string>());
Expand Down