public string BuildRelativeUrl() { var url = (Path[0] == '/' ? "" : "/") + Path; if (QueryString?.Length > 0) { url += "?" + FormUrlEncoder.Encode(QueryString); } return(url); }
public void Encodes_password_grant_attempt() { var dataStore = TestDataStore.Create(); var createGrantAttempt = dataStore.Instantiate <IPasswordGrantAuthenticationAttempt>(); createGrantAttempt.SetLogin("*****@*****.**"); createGrantAttempt.SetPassword("Secret1"); createGrantAttempt.SetAccountStore("https://api.stormpath.com/v1/directories/1bcd23ec1d0a8wa6"); var properties = (createGrantAttempt as AbstractResource).GetResourceData().GetUpdatedProperties().ToDictionary(); var result = new FormUrlEncoder(properties) .ToString() .Split('&'); result.ShouldContain("grant_type=password"); result.ShouldContain("username=tom%40stormpath.com"); result.ShouldContain("password=Secret1"); result.ShouldContain("accountStore=https%3A%2F%2Fapi.stormpath.com%2Fv1%2Fdirectories%2F1bcd23ec1d0a8wa6"); }