Beispiel #1
0
 public void Setup()
 {
     context = RealmContext.Create()
               .WithCredentials(InputData.Username, InputData.Password)
               .Endpoint(InputData.Endpoint)
               .ToRealm(InputData.Realm)
               .ToClientName(InputData.ClientId);
 }
Beispiel #2
0
        public void Setup()
        {
            context = RealmContext.Create()
                      .WithCredentials(InputData.Username, InputData.Password)
                      .Endpoint(InputData.Endpoint)
                      .ToRealm(InputData.Realm)
                      .ToClientName(InputData.ClientId, InputData.ClientSecret);

            //context.Client.CreateClientAsync(InputData.Realm, new global::Keycloak.Net.Models.Clients.Client()
            //{
            //    ClientId = ClientName,
            //    Protocol = "openId-connect"
            //});
        }
Beispiel #3
0
        public void I_d_Like_have_content_correctly_created()
        {
            //given

            //when
            var content = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId);

            //than
            Assert.NotNull(content);
        }
Beispiel #4
0
        public async Task I_d_like_to_push_revocation()
        {
            //given
            var context = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId, InputData.ClientSecret);

            //when
            var result = await context.Manager.Sessions.Revocation.SetToNowAndPushAsync();

            //than
            Assert.NotNull(result);
        }
Beispiel #5
0
        public async Task I_d_like_to_logout_all_sessions()
        {
            //given
            var context = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId, InputData.ClientSecret);

            //when
            var result = await context.Manager.Sessions.RealmSessions.LogoutAllAsync();

            //than
            Assert.IsTrue(result);
        }
        public async Task I_d_like_to_export_realm_as_byte_array()
        {
            //given
            var context = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId, InputData.ClientSecret);

            //when
            var result = await context.Manager.Export.ExportToByteArrayAsync(true, true);

            //than
            Assert.NotNull(result);
        }
        public async Task I_d_like_to_have_role_names_of_used_client()
        {
            //given
            var context = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId, InputData.ClientSecret);

            //when
            var result = await context.Configurator.Clients.GetDefaultClientRolesNamesAsync();

            //than
            Assert.NotNull(result);
            Assert.Greater(result.ToList().Count, 0);
        }
        public async Task I_d_like_to_import_realm()
        {
            //given
            var context = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId, InputData.ClientSecret);

            var realm = await context.Manager.Export.ExportAsync(true, true);

            //when
            var result = await context.Manager.Import.ImportAsync(realm);

            //than
            Assert.IsTrue(result);
        }
Beispiel #9
0
        public async Task I_d_like_to_remove_role_from_specific_client()
        {
            //given
            var context = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId);

            var newName = Guid.NewGuid().ToString();
            await context.Configurator.Roles.AddRoleAsync(newName);

            //when
            var result = await context.Configurator.Roles.DeleteRoleAsync(newName);

            //than
            Assert.IsTrue(result);
        }
Beispiel #10
0
        public async Task I_d_like_to_import_realm_from_file()
        {
            //given
            var context = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId, InputData.ClientSecret);

            var inputFilePath = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "realm-export.json");
            var inputFile     = File.ReadAllBytes(inputFilePath);

            //when
            var result = await context.Manager.Import.ImportAsync(inputFile);

            //than
            Assert.IsTrue(result);
        }
Beispiel #11
0
        public void I_d_like_to_create_context_with_token()
        {
            //given

            //when
            var context = RealmContext.Create()
                          .WithToken(Guid.NewGuid().ToString())
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId);

            //than
            Assert.NotNull(context);
            Assert.NotNull(context.ConnectionSettings.ClientName);
            Assert.Null(context.ConnectionSettings.Password);
            Assert.Null(context.ConnectionSettings.Username);
            Assert.NotNull(context.ConnectionSettings.Token);
        }
Beispiel #12
0
        public async Task I_d_like_to_get_role_by_Id()
        {
            //given
            var context = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId, InputData.ClientSecret);

            var allOfThem = await context.Configurator.Roles.AllAsync();

            var newOne = allOfThem.First();

            //when
            var result = context.Configurator.Roles.GetRoleById(newOne.Id);

            //than
            Assert.IsNotNull(result);
        }
Beispiel #13
0
        public void I_d_like_to_have_access_to_submodules()
        {
            //given
            var content = RealmContext.Create()
                          .WithCredentials(InputData.Username, InputData.Password)
                          .Endpoint(InputData.Endpoint)
                          .ToRealm(InputData.Realm)
                          .ToClientName(InputData.ClientId);

            //when
            var configuration = content.Configurator;
            var manager       = content.Manager;
            var groups        = content.Manager.Groups;
            var clients       = content.Configurator.Clients;
            var clientScopes  = content.Configurator.ClientScopes;

            //than
            Assert.NotNull(configuration);
            Assert.NotNull(manager);
            Assert.NotNull(groups);
            Assert.NotNull(clients);
            Assert.NotNull(clientScopes);
        }