# Test login against openHAB instance using Docker

**URL:** <https://community.openhab.org/t/test-login-against-openhab-instance-using-docker/147831>\
**Category:** Installation\
**Created:** [July 16, 2023, 10:32am UTC](https://community.openhab.org/t/test-login-against-openhab-instance-using-docker/147831 "2023-07-16T10:32:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mu88](https://community.openhab.org/user_avatar/community.openhab.org/mu88/32/102048_2.png) [@mu88](https://community.openhab.org/u/mu88)\
**Post date:** [July 16, 2023, 10:32am UTC](https://community.openhab.org/t/test-login-against-openhab-instance-using-docker/147831/1 "2023-07-16T10:32:21Z")

</div>

- Platform information:
  - Hardware: Raspberry Pi 4
  - OS: Raspberry Pi OS / x64 / 11 (bullseye)
  - Java Runtime Environment: 11.0.15 (Temurin-11.0.15+10) (running in Docker)
  - openHAB version: 3.4.4 (running in Docker)
  - ConBee 2 USB stick

Dear community,

I’ve built [this little service](https://github.com/mu88/ScreenshotCreator/) to create screenshots from an openHAB dashboard. Since the service also handles authenticating against openHAB (logging in), I want to test this particular feature in a system integration test (SIT, e. g. to easily verify that my code is still working with a new release of either openHAB or the used technology stack .NET as part of the automated build process) and for this I need an easily runnable openHAB instance.

The public demo [openHAB](https://demo.openhab.org/page/temperatures) has all I need - except the login. That’s why I was thinking that if the public demo is based on a Docker image, I could use it, make the temperature dashboard only accessible to a user and persist this as a new Docker image that I can use for my SIT.

Of course, I could also use the pure openHAB Docker image and create the dashboard, user, etc. on my own, but since I’d have to do this for each and every openHAB release, I’m looking for a way to either automate this process or use already existing resources.

Thank you for your input!

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [July 17, 2023, 2:18pm UTC](https://community.openhab.org/t/test-login-against-openhab-instance-using-docker/147831/2 "2023-07-17T14:18:22Z")

</div>

> [@mu88](#):
>
> The public demo [openHAB](https://demo.openhab.org/page/temperatures) has all I need - except the login

There is a login…

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/c/6/c653e26a96295f08cb2655fc8b31299279a67fe0.jpeg)

> [@mu88](#):
>
> Of course, I could also use the pure openHAB Docker image and create the dashboard, user, etc. on my own, but since I’d have to do this for each and every openHAB release

Not really. You’d just need to update the config on those rare cases where the config cannot be updated automatically which is almost always only going to be when there’s a major version number change (e.g. 3.4 to 4.0). Within a given version number, any required changes to the config are handled automatically. Even then there are almost never any of these changes because that usually means a breaking change which are not allowed except at a major version change.

The demo config is maintained at [openhab-distro/launch/app/runtime/conf at ff8160b2d1c08a48507f2df5f0273319701a3d90 · openhab/openhab-distro · GitHub](https://github.com/openhab/openhab-distro/tree/ff8160b2d1c08a48507f2df5f0273319701a3d90/launch/app/runtime/conf) I think but I do not know how the demo instance is deployed. But you probably don’t need to maintain anything. Just use the existing Docker image with these config files.

But ultimately, if that’s not sufficient, _someone_ is going to have to create and keep up these Docker images. Since you are the one who needs this feature, it’s most likely to be implemented if you do so and submit the PR than otherwise. I can’t imagine someone else volunteering to do this as it’s a pretty niche use case.

---

<div class="post-metadata">

**Author:** ![mu88](https://community.openhab.org/user_avatar/community.openhab.org/mu88/32/102048_2.png) [@mu88](https://community.openhab.org/u/mu88)\
**Post date:** [July 17, 2023, 4:43pm UTC](https://community.openhab.org/t/test-login-against-openhab-instance-using-docker/147831/3 "2023-07-17T16:43:16Z")

</div>

Thx for taking the time answering my question!

> There is a login…

Sorry, I was not precise enough: you are right, there’s a login, but the temperature dashboard is accessible without login - what I need is a dashboard requiring authorization.

> The demo config is maintained at [openhab-distro/launch/app/runtime/conf at ff8160b2d1c08a48507f2df5f0273319701a3d90 · openhab/openhab-distro · GitHub](https://github.com/openhab/openhab-distro/tree/ff8160b2d1c08a48507f2df5f0273319701a3d90/launch/app/runtime/conf) I think but I do not know how the demo instance is deployed. But you probably don’t need to maintain anything. Just use the existing Docker image with these config files.

That’s very interesting, I didn’t know that. So basically I could spawn a Docker container from the official base image, copy the config into it (maybe restart?) and that’s it? That would be perfect for my needs 💪🏻  
But what I don’t see in the config you mentioned is the temperature dashboard 🤔

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [July 17, 2023, 4:50pm UTC](https://community.openhab.org/t/test-login-against-openhab-instance-using-docker/147831/4 "2023-07-17T16:50:37Z")

</div>

> [@mu88](#):
>
> So basically I could spawn a Docker container from the official base image, copy the config into it (maybe restart?) and that’s it?

I’d swap the order. Clone the config and spawn a container with that config mounted.

You could get even more clever. The first thing that the container does is execute scripts mounted into it under init.d (see the openHAB image docs for details). You could in that init script clone the demo configs into the container before OH comes up.

But even if you do it all outside the container, if you clone the config first there’s no need to restart the container.

> [@mu88](#):
>
> But what I don’t see in the config you mentioned is the temperature dashboard 🤔

I’m not 100% now that that is the config in question. The MainUI config will be under `userdata` but there isn’t a josndb folder there checked in so maybe that isn’t the source of the demo config.

But it’s bound to be somewhere in that repo.

---

<div class="post-metadata">

**Author:** ![mu88](https://community.openhab.org/user_avatar/community.openhab.org/mu88/32/102048_2.png) [@mu88](https://community.openhab.org/u/mu88)\
**Post date:** [July 19, 2023, 3:47pm UTC](https://community.openhab.org/t/test-login-against-openhab-instance-using-docker/147831/5 "2023-07-19T15:47:49Z")

</div>

Thank you for your help, it works like a charm 💪🏻 [here’s the C# code](https://github.com/mu88/ScreenshotCreator/blob/main/tests/Tests/Integration/Api/ProgramTests.cs#L130-L152) with [this openHAB config](https://github.com/mu88/ScreenshotCreator/tree/main/tests/Tests/testData/openhab) if somebody needs it as well
