public async Task <string> GetAccessTokenForAuthClient() { string accessToken = await this.GetAccessToken(new HttpRequestMessage { Content = new FormUrlEncodedContent( FunctionalTestHelpers.GetAccessTokenKeyValuePair( FunctionalTestConstants.IdentityTestUser, _funcTestClientSecret, "client_credentials", "fabric/authorization.read fabric/authorization.write")) }).ConfigureAwait(false); return(accessToken); }
public async Task <string> GetAccessTokenForInstaller() { string accessToken = await this.GetAccessToken(new HttpRequestMessage { Content = new FormUrlEncodedContent( FunctionalTestHelpers.GetAccessTokenKeyValuePair( "fabric-installer", this.args.InstallerClientSecret, "client_credentials", "fabric/identity.manageresources fabric/authorization.read fabric/authorization.write fabric/authorization.manageclients")) }).ConfigureAwait(false); return(accessToken); }
public async Task <string> GetUserAccessToken(string username, string password) { string stringToEncode = $"{FunctionalTestConstants.IdentityTestUser}:{this._funcTestClientSecret}"; string encodedData = stringToEncode.ToBase64Encoded(); string accessToken = await this.GetAccessToken(new HttpRequestMessage { Headers = { Authorization = new AuthenticationHeaderValue(FunctionalTestConstants.Basic, encodedData) }, Content = FunctionalTestHelpers.GetResourceOwnerPasswordPostBody(username, password) }).ConfigureAwait(false); return(accessToken); }
public async Task <string> CreateClient(string username) { string requestContent = FunctionalTestHelpers.CreateFunctionalTestClient(username); var response = await this._identityClient.SendAsync(new HttpRequestMessage() { RequestUri = new Uri(new Uri(this.args.IdentityBaseUrl), "/api/client"), Method = HttpMethod.Post, Headers = { Authorization = new AuthenticationHeaderValue(FunctionalTestConstants.Bearer, this._installerAccessToken), Accept = { new MediaTypeWithQualityHeaderValue(FunctionalTestConstants.Applicationjson) } }, Content = new StringContent(requestContent, Encoding.UTF8, FunctionalTestConstants.Applicationjson) }).ConfigureAwait(false); string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); return(content.FromJson <ClientModel>().clientSecret); }