-
Notifications
You must be signed in to change notification settings - Fork 4
Kurki simulation
Kurki simulation or Fake Kurki is an app for simulating KurkiAPI. It is very useful for development purposes and let's one log in using fake accounts. It also has fake information about courses that it can give to backend, when backend makes requests to KurkiAPI.
Using Kurki simulation and existing test data (seeders) together is recommended: start the backend by running script restart-test.sh
which is found in the backend repository.
In your /backend, edit your .env file and add one of the following lines:
KURKI_URL=http://localhost:3002
KURKI_URL=https://opetushallinto.cs.helsinki.fi
The first one is the fake kurki and the latter the real one
Tip: You can add both and comment the one you don't use with #
If you're running fake kurki for the first time, remember to run npm install in the Kurki_Simulation directory. Otherwise it's not required.
cd /labtool/Kurki_Simulation
npm install (if using for the first time)
npm start
After this, you should get a notification in the terminal, saying:
Fake Kurki listening on port 3002.
You can now start your front- and backend normally and your project will use the fake kurki instead of the real one. Specifically this feature is useful for running npm run import_courses
while the backend and Kurki simulation are running to import test data.
Remember to log in with one of the test users from users.js. The password for all of them is password
.
With Shibboleth, a fake login can also be used. Set the environment variable USE_FAKE_LOGIN=ThisIsNotProduction
for the backend and REACT_APP_USE_FAKE_LOGIN=ThisIsNotProduction
for the frontend by using .env
or environment variables. DO NOT, UNDER ANY CIRCUMSTANCES, USE THESE VALUES IN A PRODUCTION ENVIRONMENT.
when both are enabled, the frontend will allow you to choose an user to log in as, and the backend will let you. The users should be the same as for the Kurki simulation, and only users with an email address can be logged in as. The user data is available under labtool2.0/src/utils/fakeLoginUsers.js
for the frontend and Kurki_simulation/responses/users.js
for the backend.
Please note that backend admin page shows a duplicate for each course when using fake-Kurki.
This is a feature, not a bug, caused by the backend making two requests: first for the current term and then for the next. The date functionality of the real thing is not implemented in this version, so we get all the courses twice.
If you experience unusual behaviour of the app while using fake-Kurki, try clearing the local storage.