You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Authors:

Name

Student number

679586

Teachers:

Name

Function

Skills begeleider

Procesbegeleider

Klas

ITA-OOSE-A

GroepsnaamSmalltalk
CourseOOSE
Datum

 

Versie

1.9

In this document we will take a look at the safety of the application. This is mainly focused on unit tests and what they do.

One of the requirements from Regterschot Racing was that the application needs to be safe, so that no-one is allowed on the appplication, except for those with the permission to be in the application.
The code also needs to work and be well documented. This document will show which code works and what all the tests are. If there is a failed test, it will be explained on why this happens.

GraphDAOTest class


Name

Expected result

Parameters

Actual result

Success

Comments

1getGraphs()All graphs with tabID are shown.tabID = 1All graphs with the given tabID, are returned to the user.Yes
2getUserTabsSqlException()A databaseException will be thrown after a SQLException. tabID = 1A SQLException is thrown.YesWrong exception is thrown.

Table 1: Tests in GraphDAOTest

TabDAOTest class


Name

Expected result

Parameters

Actual result

SuccessComments
1getUserTabsCorrectly()All tabs from the user.username = 'Erik'All graphs are returned to the user.Yes
2getUserTabsSqlException()A databaseException will be thrown after a SQLException. username = 'Erik'A SQLException is thrown.YesWrong exception is thrown.

Table 2: Tests in TabDAOTest

Login tests

LoginServiceTest


Name

Expected result

Parameters

Actual result

SuccessComments
1checkCorrectUsernameResponse()Gives the same username back as the user has given to the system.

LoginRequestDTO{

username = 'Erik'
password = 'Welkom123'

}

The class returns 'Erik', and thus gives the same username back.YesThe response from the database is set manually, because a connection to the real database is not safe in tests.
2checkCorrectTokenResponse()Gives a new token dedicated to a specific name.

LoginRequestDTO{

username = 'Erik'
password = 'Welkom123'

}

The class returns the same token as expected for the user given.YesThe response from the database is set manually, because a connection to the real database is not safe in tests.
3checkThrownExceptionWrongPassword()Throws a LoginCredentialsIncorrectException after wrong input of the password.

LoginRequestDTO{

username = 'Erik'
password = 'WrongPassword'

}

A LoginCredentialsIncorrectException is thrown.YesThe response from the database is set manually, because a connection to the real database is not safe in tests. In this case it's set to 0, to simulate the database returning nothing.
4checkThrownExceptionWrongUser()Throws a LoginCredentialsIncorrectException after wrong input of the name.

LoginRequestDTO{

username = 'WrongUser'
password = 'Welkom123'

}

A LoginCredentialsIncorrectException is thrown.YesThe response from the database is set manually, because a connection to the real database is not safe in tests. In this case it's set to 0, to simulate the database returning nothing.
5checkThrownExceptionNoUserAndPassword()Throws a LoginCredentialsIncorrectException after no input.

LoginRequestDTO{

username = ''
password = ''

}

A LoginCredentialsIncorrectException is thrown.YesThe response from the database is set manually, because a connection to the real database is not safe in tests. In this case it's set to 0, to simulate the database returning nothing.
6testCreationToken()Creates a token based on the name that it has receivedusername = 'Erik'Creates the token from username 'Erik'Yes

LoginResourceTest


Name

Expected result

Parameters

Actual result

SuccessComments
1getUserHTMLcodeWithCorrectInformation()Returns a 200 status code back to the user.

LoginRequestDTO{

username = 'Erik'
password = 'Welkom123'

}

Returns a 200 response code, which means that the response is OKYes
2
getUserHTMLcodeWithIncorrectInformation()
Returns a 403 status code back to the user.
A 403 status is returnedYes
(see comments)
This method does work, but doesn't test if it works with a wrong input given. This is because the thrown exception gets mapped by the mapper with the Provider annotation. This test strictly tests if the mapper does return the 403 code given by the user.
3checkExceptionThrown()Throws a LoginCredentialsIncorrectException after wrong input of the password in resource.

LoginRequestDTO{

username = 'Erik'
password = 'Welkm123'

}

A LoginCredentialsIncorrectException is thrown.Yes

UserDAOTest


Name

Expected result

Parameters

Actual result

SuccessComments
1getUserCorrectly()Expect a result that is not null.

username = 'Erik'

Returns something that is not null.YesWe manually added some return values of this function, to test if it would work. This test cannot connect to the database, since a unit test may not do this.
2
getUserSqlException()
Throws a SQLException that in return throws a DatabaseExceptionusername = 'Erik'A DatabaseException is thrownYes

  • No labels