/// <inheritdoc /> public async Task <ICreatedOrganisation> CreateOrganisation( CreateOrganisationOptions options, CancellationToken cancellationToken = default(CancellationToken)) { var requestUrl = _client.Configuration.BuildUrl("/api/v1/orgs"); return(await _client.PostAsync <CreatedOrganisation>(requestUrl.AbsoluteUri, options, cancellationToken)); }
public async Task CanCreateAnOrgTest() { //GIVEN A valid specifcation for an Okta organisation var mockClient = new Mock <IOktaClient>(); var client = mockClient.Object; mockClient.Setup(x => x.Configuration) .Returns(new OktaClientConfiguration() { OktaDomain = ExampleOktaDomain }); var createOrgOptions = new CreateOrganisationOptions( subDomain: "testSubDomain", name: "Test New Organisation", website: "https://test.org.new.okta.com", edition: "EXAMPLE EDITION", licensing: new OrganisationLicensing() { Apps = new[] { "example_app" } }, admin: new User { Profile = new UserProfile() { Email = "*****@*****.**", FirstName = "TestFirstName", LastName = "TestLastName", Login = "******", MobilePhone = "012345678", SecondEmail = "*****@*****.**" }, Credentials = new UserCredentials() { RecoveryQuestion = new RecoveryQuestionCredential() { Question = "Recovery question", Answer = "Recovery answer" }, Password = new PasswordCredential() { Value = "Secret password value" } } }); mockClient.Setup(x => x.PostAsync <CreatedOrganisation>($"{ExampleOktaDomain}/api/v1/orgs", It.IsAny <object>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(new CreatedOrganisation() { Token = "Returned token" })); //WHEN A request is made to create an org ICreatedOrganisation result = await client.Organisations().CreateOrganisation(createOrgOptions, CancellationToken.None); //THEN The okta client is invoked with the correct parameters Assert.That(result.Token, Is.EqualTo("Returned token"), "The returned object should be the mock expectation"); mockClient.VerifyAll(); }