Skip to content

Commit

Permalink
Merge pull request #1696 from dedis/work-simone-clean-up-karate
Browse files Browse the repository at this point in the history
Clean up Karate
  • Loading branch information
simone-kalbermatter authored Oct 9, 2023
2 parents 79a6462 + 6eef5a7 commit 271bac1
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Feature: Create a pop LAO
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def validLao = organizer.createValidLao()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Feature: Update a LAO
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def lao = organizer.createValidLao()

# This call executes all the steps to create a valid lao on the server before every scenario
# (lao creation, subscribe, catchup)
* call read('classpath:be/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(organizer)', lao: '#(lao)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(organizer)', lao: '#(lao)' }

Scenario: Update Lao should succeed with a valid update request with new lao name
Given def updateLaoRequest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Feature: Request messages by id from other servers
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def mockServer = call createMockClient
* def lao = mockServer.createValidLao()

Expand All @@ -24,7 +24,7 @@ Feature: Request messages by id from other servers

# This call executes all the steps to create a valid lao on the server before every scenario
# (lao creation, subscribe, catchup)
* call read('classpath:be/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(mockServer)', lao: '#(lao)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(mockServer)', lao: '#(lao)' }

# Check that after sending a heartbeat message with unknown message id, the server responds with a
# getMessagesByID requesting this message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Feature: Send heartbeats to other servers
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def mockServer = call createMockClient
* def lao = mockServer.createValidLao()
* def validRollCall = mockServer.createValidRollCall(lao)

# This call executes all the steps to create a valid lao on the server before every scenario
# (lao creation, subscribe, catchup)
* call read('classpath:be/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(mockServer)', lao: '#(lao)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(mockServer)', lao: '#(lao)' }

# After lao creation, wait and do nothing (30 seconds for now) and check that a heartbeat message was received
Scenario: Server should send heartbeat messages automatically after a time interval
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ Feature: Simple Transactions for digital cash
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def recipient = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)

# This call executes all the steps to set up a lao, complete a roll call and subscribe to the coin channel
* call read('classpath:be/utils/simpleScenarios.feature@name=setup_coin_channel') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=setup_coin_channel') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }

Scenario: Valid transaction: issue 32 mini-Laos to an attendee
Given def transaction = organizer.issueCoins(recipient, 32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Feature: Cast a vote
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)
* def election = organizer.createValidElection(lao)
* def question = election.createQuestion()

# This call executes all the steps to set up a lao, complete a roll call and open an election with one question
* call read('classpath:be/utils/simpleScenarios.feature@name=election_open') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=election_open') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* def vote = question.createVote(0)
* def castVote = election.castVote(vote)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Feature: Terminate an election
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)
* def election = organizer.createValidElection(lao)
* def question = election.createQuestion()

# This call executes all the steps to set up a lao, complete a roll call, open an election and cast a vote
* call read('classpath:be/utils/simpleScenarios.feature@name=cast_vote') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=cast_vote') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* def electionEnd = election.close()

# After a successful election setup and cast vote sending a valid election end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Feature: Open an Election
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)
* def election = organizer.createValidElection(lao)
* def question = election.createQuestion()

# This call executes all the steps to set up a lao, complete a roll call and create an election with one question
* call read('classpath:be/utils/simpleScenarios.feature@name=election_setup') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=election_setup') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)', election: '#(election)', question: '#(question)' }
* def electionOpen = election.open()

# Testing after creating an election, the backend returns an result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Feature: Setup an Election
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)
Expand All @@ -16,7 +16,7 @@ Feature: Setup an Election

# This call executes all the steps to set up a lao and complete a roll call, to get a valid pop token
# (lao creation, subscribe, catchup, roll call creation, roll call open, roll call close)
* call read('classpath:be/utils/simpleScenarios.feature@name=close_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=close_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }

# Testing if after a successful roll call, sending a valid election
# setup results in a valid response from the backend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Feature: Close a Roll Call
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)

# This call executes all the steps to open a valid roll call on the server before every scenario
# (lao creation, subscribe, catchup, roll call creation, roll call open)
* call read('classpath:be/utils/simpleScenarios.feature@name=open_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=open_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* def closeRollCall = rollCall.close()

# Testing if after setting up a valid lao, subscribing to it, sending a catchup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Feature: Create a Roll Call
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def validRollCall = organizer.createValidRollCall(lao)

# This call executes all the steps to create a valid lao on the server before every scenario
# (lao creation, subscribe, catchup)
* call read('classpath:be/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(organizer)', lao: '#(lao)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_lao') { organizer: '#(organizer)', lao: '#(lao)' }

# Testing if after setting up a valid lao, subscribing to it and sending a catchup
# we send a valid roll call create request and expect to receive a valid response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Feature: Roll Call Open
# Call read(...) makes this feature and the called feature share the same scope
# Meaning they share def variables, configurations ...
# Especially JS functions defined in the called features can be directly used here thanks to Karate shared scopes
* call read('classpath:be/utils/server.feature')
* call read('classpath:be/mockClient.feature')
* call read('classpath:be/constants.feature')
* call read('classpath:be/features/utils/server.feature')
* call read('classpath:be/features/utils/mockClient.feature')
* call read('classpath:be/features/utils/constants.feature')
* def organizer = call createMockClient
* def lao = organizer.createValidLao()
* def rollCall = organizer.createValidRollCall(lao)

# This call executes all the steps to create a valid roll call on the server before every scenario
# (lao creation, subscribe, catchup, roll call creation)
* call read('classpath:be/utils/simpleScenarios.feature@name=valid_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* call read('classpath:be/features/utils/simpleScenarios.feature@name=valid_roll_call') { organizer: '#(organizer)', lao: '#(lao)', rollCall: '#(rollCall)' }
* def openRollCall = rollCall.open()

# This scenario tests a valid roll call open message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@ Feature: This feature starts a server and stops it after every scenario.
* call waitForPort
* karate.log('Executing tests')

* def convertData =
"""
function(){
var JsonConverter = Java.type('be.utils.JsonConverter')
return new JsonConverter()
}
"""
* def converter = call convertData

# Shutdown server automatically after the end of a feature
* configure afterFeature =
"""
Expand Down
Loading

0 comments on commit 271bac1

Please sign in to comment.