Browsed by
Category: computer

Modifying cn=config in OpenLDAP without rootDN password

Modifying cn=config in OpenLDAP without rootDN password

Using a configures “admin” user and the corresponding password, I successfully created a bind user uid=bind_user,ou=users,dc=work,dc=com on an OpenLDAP server. The bind user needed escalated privileges, but as the cn=admin,dc=work,dc=com user didn’t have write access to the cn=config database, all my efforts running commands such as ldapmodify on the bind user, resulted in this error message: I didn’t have access to the rootDN password, so I was kind of stuck for a while. Then I was advised to try ldapvi,…

Read More Read More

React: Auto scroll when overflow

React: Auto scroll when overflow

I recently had an issue with an React app, in which contents was added to the bottom of an area – a <div> element with the CSS property overflow: scroll; set – on the screen. I wanted the app to automatically scroll to the latest element. I found this post on StackOverflow which seemed to be what I needed, and while the auto scroll feature did work it was kind of our of sync with the content. I figured the…

Read More Read More

Python: Writing test to verify command line arguments

Python: Writing test to verify command line arguments

I wrote a small Python script that will be executed from the command line. After finishing the tests to verify the business logic, I decided to test the command line arguments as well, just to make sure they’re parsed correctly and passed to their appropriate places in the business logic code. Initially I was thinking I needed to write a test that executes the actual command line such as python3 myscript.py –argument=value, but as this is neither appropriate nor really…

Read More Read More

Running Oracle in Docker for development and testing

Running Oracle in Docker for development and testing

I’m working on a Python based microservice that needs to communicate with an Oracle database. My development environment consist only of my laptop, so to do some real testing I decided to spin up Oracle in a Docker container on my laptop. For me, the process of getting things up and running wasn’t very straight forward for an Oracle newbie as myself, so I though I’d share my setup in case others may benefit from it. Let’s start with my…

Read More Read More

Extending business logic functions in unit tests

Extending business logic functions in unit tests

We have a database view, from now on referred to as View, that lists users we need to send an email to, and when we’ve sent the user an email we acknowledge this by updating the corresponding user in a database table (which is one of the tables the above mentioned database view is build from), from now on referred to as Table. For my unit tests I needed to emulate this behavior. I found that by extending the database…

Read More Read More

Developing .NET applications without installing .NET SDK

Developing .NET applications without installing .NET SDK

I recently developed a small .NET application. I considered installing the .NET SDK on my laptop (on which I were to develop the .NET application), but was unsure of which version I would need, and how I would potentially downgrade the SDK version if needed.  Instead of installing the SDK on my laptop, I decided to run the SDK inside a Docker container. This way I could easily switch between SDK versions if needed, as all I’d have to do…

Read More Read More

Docker build fails with “no matching manifest for unknown in the manifest list entries”

Docker build fails with “no matching manifest for unknown in the manifest list entries”

I recently got this error when trying to build a Windows container (specifically microsoft/dotnet-framework:4.7.2-sdk) on my Windows 10 laptop: no matching manifest for unknown in the manifest list entries I was surprised that I couldn’t build Windows containers on my Windows laptop, but then I recalled that Docker for Windows let you choose between running Linux containers or Windows containers. As I until now had exclusively ran Linux containers, my Docker was set up to run Linux containers, but configuring Docker to…

Read More Read More

Patching Python instance methods

Patching Python instance methods

I’m working on a project in which one of our services need to publish messages to a RabbitMQ exchange. Consider this code excerpt from the message queue client:

In my unit tests I wanted to verify that an unsuccessful attempt to publish the message, would cause trigger an exception to be thrown. To test this, I needed basic_publish  to return False. At first I found it tricky to patch instance methods such as basic_publish , but after coming across this excellent…

Read More Read More

Testing a Flask REST API using Factory Boy and an in-memory sqlite database

Testing a Flask REST API using Factory Boy and an in-memory sqlite database

I’m developing a REST API using Python’s Flask microframework. As I wanted to do test driven development to ensure good test coverage, I needed a working testing framework. After checking out a few different options, I found one that works well for my use case. I thought I’d share my setup in case it may be of help to others. First, this is how I create the server: