tl;dr: Back up your stuff, and you have to create mountebank config files in something other than VisualStudio.
Okay, the first lesson to dole out for the day is to back up your blog entry drafts as you write them. I am currently going back through some projects we have been working on cleaning up and reworking tests to get better coverage (and finding some issues along the way, which has made this a very worthwhile excercise). In trying to get some tests working locally, I discovered they rely on mountebank, an incredibly handy code package that acts as a test double for downstream services. Tests were failing because I hadn't reinstalled mountebank locally since I had a crash about six weeks ago.
So, I got mountebank re-installed. Some of the tests needed to be re-worked so. In doing so I ran into an extremely frustrating issue where MB just won't accept a configuration file. I was working from home, so my wife was suddenly an audience for the flood of expletives I can unleash at times while doing this job. After her admonishment and composing myself I realized I had run into this exact smae issue before. More on this later. I remembered I had even written down the exact nature of the issue before. I set about tryiing to find just exactly what had happened to what I wrote.
I remember thinking that it would make for a good blog post. Looking at my published blog posts, however, turned up nothing. Had I just saved it locally and then never published it? The crash I mentioned before was actually an issue with our corporate encryption software. Basically every file that I had created locally had been encrypted by the software, which then suddenly stopped recognizing that I was who I said I was and wouldn't decrypt anything. This included config files for software I used every day, which all then stopped working. Anyway, long story short, I lost basically everything I had written and only saved locally.
At one point I had sent out some notes to my fellow teammates on using mountebank. Maybe I had included my write-up for them. One sent me back that email, which included a couple links on getting started with MB, along with a note saying "I was looking forward to reading your blog post on it." Argh!
So here I am re-creating that post along with the lesson for all to save those blog posts as drafts online, or somewhere where they will eventually be lost to corporate encryption perdition.
I'm going to make this a series of posts, building incrementally, since there is a lot of depth to mountebank that can be explored. With that in mind, I want to wrap this initial post up with a rundown of the problem I ran into once again yesterday,
You can begin running the mountbank API simply with the command 'mb' on the command line and then making a series of posts to it to set up the services you intend to impersonate. I've found for automated testing purposes it is simpler to pass a configuration file as an .ejs file.
mb --configfile "C:/path/to/my/config.ejs"
The .ejs extension allows you to use javaScript and javaScript variables directly in the file, something to explore later. The issue is when you create this .ejb file in VisualStudio, VS does something to add additional info to the file which causes MB to choke on the file. MB will throw an error that the JSON in the file is incorrect. You will then spend the next half hour looking for stray brackets or misplaced commas and then copying in the content of previously-created files that work just fine and pulling out your hair.
Then you will try opening the file in a text editor like Notepad++ and re-copying the contents in, to discover that doesn't work either. Then you'll check to confirm that the .ejs file is being copied to the correct location upon build. You have to delete the file and re-create it in something other than VS. Notepad++ works just fine. I'm not sure if VS Code works. I've discovered now that this is an issue with both VS 2015 and VS 2017 (since my rebuild of the computer now has the latest VS).
Hope this helps out some of you to save both time and hair. My next post will hopefully get one at least started using mountebank for testing purposes.
Okay, the first lesson to dole out for the day is to back up your blog entry drafts as you write them. I am currently going back through some projects we have been working on cleaning up and reworking tests to get better coverage (and finding some issues along the way, which has made this a very worthwhile excercise). In trying to get some tests working locally, I discovered they rely on mountebank, an incredibly handy code package that acts as a test double for downstream services. Tests were failing because I hadn't reinstalled mountebank locally since I had a crash about six weeks ago.
So, I got mountebank re-installed. Some of the tests needed to be re-worked so. In doing so I ran into an extremely frustrating issue where MB just won't accept a configuration file. I was working from home, so my wife was suddenly an audience for the flood of expletives I can unleash at times while doing this job. After her admonishment and composing myself I realized I had run into this exact smae issue before. More on this later. I remembered I had even written down the exact nature of the issue before. I set about tryiing to find just exactly what had happened to what I wrote.
I remember thinking that it would make for a good blog post. Looking at my published blog posts, however, turned up nothing. Had I just saved it locally and then never published it? The crash I mentioned before was actually an issue with our corporate encryption software. Basically every file that I had created locally had been encrypted by the software, which then suddenly stopped recognizing that I was who I said I was and wouldn't decrypt anything. This included config files for software I used every day, which all then stopped working. Anyway, long story short, I lost basically everything I had written and only saved locally.
At one point I had sent out some notes to my fellow teammates on using mountebank. Maybe I had included my write-up for them. One sent me back that email, which included a couple links on getting started with MB, along with a note saying "I was looking forward to reading your blog post on it." Argh!
So here I am re-creating that post along with the lesson for all to save those blog posts as drafts online, or somewhere where they will eventually be lost to corporate encryption perdition.
I'm going to make this a series of posts, building incrementally, since there is a lot of depth to mountebank that can be explored. With that in mind, I want to wrap this initial post up with a rundown of the problem I ran into once again yesterday,
You can begin running the mountbank API simply with the command 'mb' on the command line and then making a series of posts to it to set up the services you intend to impersonate. I've found for automated testing purposes it is simpler to pass a configuration file as an .ejs file.
mb --configfile "C:/path/to/my/config.ejs"
The .ejs extension allows you to use javaScript and javaScript variables directly in the file, something to explore later. The issue is when you create this .ejb file in VisualStudio, VS does something to add additional info to the file which causes MB to choke on the file. MB will throw an error that the JSON in the file is incorrect. You will then spend the next half hour looking for stray brackets or misplaced commas and then copying in the content of previously-created files that work just fine and pulling out your hair.
Then you will try opening the file in a text editor like Notepad++ and re-copying the contents in, to discover that doesn't work either. Then you'll check to confirm that the .ejs file is being copied to the correct location upon build. You have to delete the file and re-create it in something other than VS. Notepad++ works just fine. I'm not sure if VS Code works. I've discovered now that this is an issue with both VS 2015 and VS 2017 (since my rebuild of the computer now has the latest VS).
Hope this helps out some of you to save both time and hair. My next post will hopefully get one at least started using mountebank for testing purposes.
No comments:
Post a Comment