https://stackoverflow.com/questions/758066/how-to-mock-controller-user-using-moq
Simply mock the ControllerContext and assign it to the controller before running the method that needs testing.
Bruce Ng's software development blog
An archive of solutions of programming problems I have faced in my career
https://stackoverflow.com/questions/758066/how-to-mock-controller-user-using-moq
Simply mock the ControllerContext and assign it to the controller before running the method that needs testing.
https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/
I tried to use Moq to mock the DbContext and IQueryable<>, but it seems to be really complicated. It’s also not recommended by Microsoft.
For unit testing, it’s recommended to use a real database, perhaps using an in-memory database or a temporary sqlite database. Whatever the type of database you use, install the required NuGet package.
If this happens, make sure clipboard sharing is enabled in the guest settings.
If it still doesn’t work, re-insert the VBox Additions ISO to the guest OS and reinstall VBox Additions, reboot guest OS and try again.
It may work for a while until eventually breaking again if Virtualbox is updated. After upgrading Virtualbox, usually there will be a new version of VBox Additions.
When the response header is too large, nginx will reject it and return 502 Bad Gateway, this is because the default proxy buffer size is not large enough.
If you inspect the error.log file under /var/nginx, you will find this error
upstream sent too big header while reading response header from upstream
Change the following settings under location to fix this issue by making the buffers larger
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
After fixing this, if you encounter error: Request header or cookie too long. You can fix it by setting the buffer size for client header under server configuration context.
large_client_header_buffers 4 24k
This was really a lot of work as I’m not familiar with SSL and openssl. Took me a few days digging the net and trying many things to eventually make this work.
I was trying to make a Ubuntu client to trust a Windows webserver.
A few things I learned
Steps to do it
Instructions are from the below link
https://www.ibm.com/support/knowledgecenter/SSZQDR/com.ibm.rba.doc/LD_rootkeyandcert.html
Generate the private key of the root CA:
openssl genrsa -out rootCAKey.pem 2048
Generate the self-signed root CA certificate, with SAN, you need openssl 1.1.1
openssl req -x509 -sha256 -new -nodes -key rootCAKey.pem -days 3650 -out rootCACert.crt -addext “subjectAltName = DNS:<Your domain name>”
Refer to this stackoverflow question on how to add SAN: https://security.stackexchange.com/questions/74345/provide-subjectaltname-to-openssl-directly-on-the-command-line
Create a pfx file to install in Windows web server.
openssl pkcs12 -export -out rootCACert.pfx -inkey rootCAKey.pem -in rootCACert.crt -name “<Your domain name>”
Afterwards, import the pfx file to the certificate store of the Windows Server using Microsoft Management Console and configure your webserver to use this certificate.
For Ubuntu Client, install to ca-certificates
sudo cp rootCACert.crt /usr/local/share/ca-certificates
sudo update-ca-certificates
Test using cURL, you may need to configure DNS or hosts file
curl https://<Your domain name>
Chrome and Firefox use their own certificate stores, so you need to add the certificates through their settings GUI. cURL will still work if cert doesn’t have SAN, but Chrome will complain as mentioned above.