public void Missing_default_parameters_can_be_set_by_extra_parameters() { var options = new OidcClientOptions(); var frontChannel = new FrontChannelParameters { Resource = { "urn:resource1", "urn:resource2" }, Extra = new Parameters { { "client_id", "client_id2" }, { "scope", "openid extra" }, { "redirect_uri", "http://redirect2" } } }; var client = new AuthorizeClient(options); var parameters = client.CreateAuthorizeParameters("state", "nonce", "code_challenge", frontChannel); parameters.Should().HaveCount(10); parameters.GetValues("client_id").Single().Should().Be("client_id2"); parameters.GetValues("scope").Single().Should().Be("openid extra"); parameters.GetValues("redirect_uri").Single().Should().Be("http://redirect2"); parameters.GetValues("response_type").Single().Should().Be("code"); parameters.GetValues("state").Single().Should().Be("state"); parameters.GetValues("nonce").Single().Should().Be("nonce"); parameters.GetValues("code_challenge").Single().Should().Be("code_challenge"); parameters.GetValues("code_challenge_method").Single().Should().Be("S256"); var resources = parameters.GetValues("resource").ToList(); resources.Should().HaveCount(2); resources[0].Should().Be("urn:resource1"); resources[1].Should().Be("urn:resource2"); }
public void Extra_parameters_should_override_default_parameters() { var options = new OidcClientOptions { ClientId = "client_id", Scope = "openid", RedirectUri = "http://redirect" }; var frontChannel = new FrontChannelParameters { Extra = new Parameters { { "client_id", "client_id2" }, { "scope", "openid extra" }, { "redirect_uri", "http://redirect2" } } }; var client = new AuthorizeClient(options); var parameters = client.CreateAuthorizeParameters("state", "nonce", "code_challenge", frontChannel); parameters.Should().Contain("client_id", "client_id2"); parameters.Should().Contain("scope", "openid extra"); parameters.Should().Contain("redirect_uri", "http://redirect2"); parameters.Should().Contain("response_type", "code"); parameters.Should().Contain("state", "state"); parameters.Should().Contain("nonce", "nonce"); parameters.Should().Contain("code_challenge", "code_challenge"); }