O'Reilly logo

Test-Driven iOS Development with Swift by Dr. Dominik Hauser

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a login request to a web service

Let's assume that a colleague is developing a web service, but it is not finished yet. However, we already know what the API will look like. There will be an endpoint for the login. The URL will be https://awesometodos.com/login; it will take two parameters, a username and password, and it will return a token that has to be used with each call to the API.

We need a test that asserts that the token, returned from the login call, is stored somewhere for later use. Tokens should be stored in the iOS keychain. Keychain access is managed by a very low-level API. This means that it is a bit complicated to build a class accessing keychain items (but it's easier than you might think). Because of this, there ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required