While writing the last article, I noticed that I had made a bunch of little changes to the files without explicitly meaning to. I didn’t include them in the diffs. However, on my screen, I have a bunch of changes that appear to be…not changes:
Continue readingCategory Archives: Python
Long Refactoring: Extract Read
The typical approach to Data handling is
- read
- munge
- write
We want out code to reflect that structure. In doing so, we make it much easier to adapt the code to read from different sources and write to different destinations.
Continue readingLong Refactoring: First New Unit Test
The heart of the code is the call to solve a single puzzle; the function tree_to_solution_string. We want to write a test that runs just this function. Getting there is not so easy.
This method is buried deep within the class SudokuSolver. But creating one of these essentially runs the entire code. In fact, we can redo our original test to run the code as a python call as opposed to a subprocess call. Lets’ start with that.
Continue readingLong Refactoring: Call a Unit Test
Our test takes 5 seconds to run. That is not horrible, but it does not bode well for when we write more tests. We don’t want to explode that number, and we want to be able to write more focused test. I’m going to do some project setup that will enable us to do more development, including fine grained unit tests.
I’m going to start by using tox.
Continue readingLong Refactoring: Symbolic Constants
180 lines of code is not horrible, but it is a lot to wrap your mind around all at once. In order to get oriented to the code, we’re going to take on one of the simpler refactorings. We are going to replace a bunch of the magic numbers with symbolic constants.
Continue readingLong Refactoring: Testing
The code runs. How do me make sure that continues to be the case? Write a test.
Continue readingA Long Refactoring: Introduction
Congratulations, you got your code to run! You are done! Ship it!. Just don’t expect to be able to read it next month. You need to maintain it. You need to add new features. It is a mess.
Give yourself a well deserved break. Then come back to it.
Continue readingTalking to FreeIPA with python-requests
The code that Rich M gave me a while back has bit rotted. At some point, I need to get an updated version, but until then, I can continue to talk to the FreeIPA server using Python and the Requests library. In the future, I can get a session cookie, but for now, python3-request-gssapi will work to authenticate me, provided I have a valid TGT.
I pulled the requests-gssapi library from Koji, as it does not currently ship in any of the RHEL8 repos. Here is the one I installed.
https://koji.fedoraproject.org/koji/buildinfo?buildID=1371255
Note that this quick-and-dirty code runs on the IPA server itself. A better approach would be to read the Server name out of /etc/ipa/default.conf.
#!/bin/python3 import requests from requests_gssapi import HTTPSPNEGOAuth import socket hostname = socket.gethostname() url = "https://%s/ipa/json" % hostname referer = "https://%s/ipa" % hostname body = {"method":"user_find","params":[[""],{}],"id":0} r = requests.post(url, json = body, auth=HTTPSPNEGOAuth(), headers = { 'Content-Type': 'application/json', 'Accept': 'applicaton/json', 'referer': referer}) print(r.status_code) if r.status_code == 200: print(r.text) |
Decisions when playing Chromatic Triadic patterns
George Garzone is the Sax players sax player. He is a teacher that has taught the best of the crop that is out there right now. I had the privilege of studying with George back in high school. I can honestly say that no subject I studied before or since taught me how to think better than Jazz improvisation.
Continue readingUsing mod_auth_gssapi via Podman
Kerberos is a cryptographically secure authentication mechanism in use in many large organizations. Developers may want to make their applications work with Kerberos while developing inside containers. Here is a quick proof-of-concept that shows how to set up a container to work with mod_auth_gssapi., the Apache module that makes use of Kerberos.
Continue reading