Skip to content

Commit

Permalink
Pull request #209: Release 7.9
Browse files Browse the repository at this point in the history
Merge in RIHA/riha-browser from release to master

* commit 'c7093e1918c35b1e8fd3479a3bb9d33129a3cb06': (65 commits)
  version up
  version up
  Fixing sonarqube errors
  Fixing sonarqube errors
  Fixing sonarqube errors
  Fixing sonarqube errors
  Check for Null Statement
  Check for Null Statement
  Check for Null Statement
  Tests
  Test auditlog
  Test auditlog
  Test remove fix
  Test remove
  Test fix
  Test
  Fixing sonarqube errors
  Fixing sonarqube errors
  Selenium test fix
  Pull request #201: RIHAKB-1095
  ...
  • Loading branch information
KristjanKruusRIA committed Jul 8, 2022
2 parents 0a8db0f + c7093e1 commit 6f4f0af
Show file tree
Hide file tree
Showing 76 changed files with 4,453 additions and 5,719 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Additional parameters: <br>
<i>currently supported:</i> 'chrome', 'firefox' <br>
<i>default:</i> 'chrome' <br>
<b>url</b> - defines RIHA application URL<br>
<i>default:</i> 'https://riha-browser-ik.ci.kit' <br><br>
<i>default:</i> 'https://www.riha.ee' <br><br>
Running tests with additional parameters:<br>
`mvn test -DskipTests=false -Dbrowser=chrome -Durl=https://riha-browser-ik.ci.kit`
`mvn test -DskipTests=false -Dbrowser=chrome -Durl=https://www.riha.ee`




2 changes: 2 additions & 0 deletions autotest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`Run test`
mvn test -DskipTests=false -Dbrowser=chrome -Durl=https://www.riha.ee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ScenarioContext {
public static final String CREATED_SYSTEM_NAME = "CREATED_SYSTEM_NAME";
public static final String CREATED_SYSTEM_SHORT_NAME = "CREATED_SYSTEM_SHORT_NAME";

public static final String DEFAULT_APP_URL = "https://riha-browser-ik.ci.kit";
public static final String DEFAULT_APP_URL = "https://www.riha.ee/Avaleht";

private final Map<String, String> context = new HashMap<>();

Expand Down
10 changes: 10 additions & 0 deletions autotest/src/main/java/ee/ria/riha/pages/BasePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,14 @@ public void rememberSystemNameAndShortName(String systemName, String shortName)
scenarioContext.saveToContext(ScenarioContext.CREATED_SYSTEM_NAME, systemName);
scenarioContext.saveToContext(ScenarioContext.CREATED_SYSTEM_SHORT_NAME, shortName);
}

public void scrollDown(){
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
}

public void scrollToElement(WebElement element){
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].scrollIntoView();", element);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public String getLastInfosystemDateClass() {
}

public boolean isPreviouslySavedSystemVisibleInTheFeedbackTable() {
wait.sleep(1000);
scrollToElement(lastInfosystem);
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, lastInfosystem, "lastInfosystem");
String savedShortName = scenarioContext.getFromContext(ScenarioContext.CREATED_SYSTEM_SHORT_NAME);
return savedShortName.trim().equalsIgnoreCase(lastInfosystem.getText().trim());
Expand Down
5 changes: 4 additions & 1 deletion autotest/src/main/java/ee/ria/riha/pages/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public String getLoggedInUsersName() {

public void selectSecondOrganization() {
wait.forPresenceOfElements(25, By.xpath("/html/body/ngb-modal-window"), "modal");
modalContainer.findElement(By.cssSelector("tr:nth-child(2) > td")).click();
modalContainer.findElement(By.cssSelector("tr:nth-child(3) > td")).click();
wait.sleep(3000);
}

Expand Down Expand Up @@ -99,6 +99,9 @@ public void clickEvaluate() {
}

public void openSelectOrganizationDialog() {
wait.sleep(1000);
scrollToElement(selectOrganizationButton);
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, selectOrganizationButton, "selectOrganizationButton");
selectOrganizationButton.click();
}
Expand Down
35 changes: 31 additions & 4 deletions autotest/src/main/java/ee/ria/riha/pages/InfosystemPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,21 @@ public void clickOnTopic(String topic) {
public void clickEditButton() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, editButton, "editButton");
editButton.click();
wait.sleep(2000);
}

public void clickEditLegalActsButton() {
wait.sleep(1000);
scrollToElement(editLegalActsButton);
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, editLegalActsButton, "editButton");
editLegalActsButton.click();
}

public void clickEditContactsButton() {
wait.sleep(1000);
scrollToElement(editContactsButton);
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, editContactsButton, "editContactsButton");
editContactsButton.click();
}
Expand All @@ -207,6 +214,9 @@ public void clickSelectDevelopmentStatus(boolean isActiveDevelopment) {
}

public void clickRequestFeedbackButton() {
wait.sleep(2000);
scrollToElement(feedbackRequestButton);
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, feedbackRequestButton, "feedback request button");
feedbackRequestButton.click();
wait.sleep(2000);
Expand Down Expand Up @@ -237,7 +247,7 @@ public String getOpenIssues() {

public void userClicksOnUploadNewFileButton() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, modalContainer, "modalContainer");
modalContainer.findElement(By.cssSelector(".ml-2:nth-child(2)")).click();
modalContainer.findElement(By.cssSelector(".ms-2:nth-child(2)")).click();
}

public boolean isUploadedDateDisplayedOnTheLastUploadedDocument() {
Expand Down Expand Up @@ -302,11 +312,11 @@ public void userAddsFeedbackWithTypeAndComment(String type, String comment) {
modalContainer.findElement(By.name("commentText")).sendKeys(comment);

modalContainer.findElement(By.name("decisionType")).click();
wait.sleep(2000);
wait.sleep(3000);
new Select(modalContainer.findElement(By.name("decisionType"))).selectByVisibleText(type);

wait.sleep(2000);
modalContainer.findElement(By.cssSelector(".mx-2 > .btn")).click();
modalContainer.findElement(By.xpath("/html/body/ngb-modal-window/div/div/app-approver-feedback-details/section/div/form/div/div[2]/div[2]/div[2]/button")).click();

wait.sleep(2000);
modalContainer.findElement(By.cssSelector(".btn-secondary")).click();
Expand All @@ -328,6 +338,8 @@ public void createIssue(String title, String comment) {
public boolean isIssueSaved() {
String issueTitle = scenarioContext.getFromContext(ISSUE_TITLE);
wait.forPresenceOfElements(DISPLAY_ELEMENT_TIMEOUT, By.linkText(issueTitle), "linkTitle");
scrollToElement(driver.findElement(By.linkText(issueTitle)));
wait.sleep(2000);
driver.findElement(By.linkText(issueTitle)).click();

wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, modalContainer, "modalContainer");
Expand Down Expand Up @@ -365,6 +377,8 @@ public void clickSubmitFeedbackRequestButton() {
}

public void clickSaveButton() {
scrollDown();
wait.sleep(2000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, saveButton, "saveButton");
saveButton.click();
}
Expand Down Expand Up @@ -423,16 +437,22 @@ public void enterNewTopic(String topic) {
}

public void removeTopic(String topic) {
scrollDown();
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, topicTagsContainer, "topicTagsContainer");
WebElement topicTag = topicTagsContainer.findElements(By.tagName("tag"))
.stream()
.filter(tag -> tag.findElement(By.tagName("div")).getAttribute("aria-label").equalsIgnoreCase(topic))
.findFirst()
.get();
topicTag.findElement(By.tagName("delete-icon")).click();
wait.sleep(1000);
}

public void clickEditDocumentationButton() {
wait.sleep(1000);
scrollToElement(editDocumentationButton);
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, editDocumentationButton, "editDocumentationButton");
editDocumentationButton.click();
}
Expand All @@ -444,6 +464,9 @@ public void clickOnAddNewDocumentationUrlButton() {
}

public void clickEditDataButton() {
wait.sleep(2000);
scrollToElement(editDataButton);
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, editDataButton, "editDataButton");
editDataButton.click();
}
Expand Down Expand Up @@ -480,7 +503,7 @@ public void uploadNewFileDocumentFile(String fileName) {
}

public boolean isUserCanEditLastUploadedDocument() {
modalContainer.findElement(By.cssSelector(".expandable-block:last-child .mr-1")).click();
modalContainer.findElement(By.cssSelector(".expandable-block:last-child .me-1")).click();
wait.sleep(1000);
boolean filenameInputVisible = modalContainer.findElement(By.cssSelector(".expandable-block:last-child .form-group:nth-child(1)")).isDisplayed();
modalContainer.findElement(By.cssSelector(".btn-success")).click();
Expand All @@ -497,6 +520,7 @@ public void enterNewLegalActInfo(String url, String title) {
modifiedSelectByValue(new Select(legalTypeSelect), "LEGAL_TYPE_STATUTE");
modalContainer.findElement(By.cssSelector(".col-12 > .btn")).click();
modalContainer.findElement(By.cssSelector(".btn-success")).click();
wait.sleep(1000);
}

public String getTechDocUrls() {
Expand Down Expand Up @@ -685,6 +709,9 @@ public void clickLogOut() {
}

public void clickFeedbackTopic(String topic) {
wait.sleep(1000);
scrollToElement(driver.findElement(By.linkText(topic)));
wait.sleep(2000);
wait.forPresenceOfElements(DISPLAY_ELEMENT_TIMEOUT, By.linkText(topic), "feedbackTopic");
driver.findElement(By.linkText(topic)).click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public void goToInfosystemPage(String infosystem) {
}

public void goToCreateNewInfosystemPage() {
wait.sleep(1000);
scrollToElement(createNewLink);
wait.sleep(1000);
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, createNewLink, "createNewLink");
createNewLink.click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feature: Infosystems feedback requesting
Given User is logged in to "/" as "60001019906" using tel. number "00000766"
And HomePage: user opens 'my organization infosystems' page

Scenario: User can add contact to infosystem (RIHAKB-423)
Scenario: User can add relation to infosystem (RIHAKB-423)
Given MyInfosystemsPage: user select "riha-test" infosystem
When InfosytemPage: user clicks on 'Seosed süsteemidega' in the navigation bar
Then InfosystemPage: url will contain '/Infosüsteemid/Vaata/riha-test#seosed'
Expand Down
2 changes: 1 addition & 1 deletion autotest/src/test/resources/ee/ria/riha/HomePage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Feature: Home page functionality

Scenario: End user can perform a search in RIHA navigation (RIHAKB-540)
Given HomePage: user clicks on the search bar and enters 'kontakt'
Then InfosytemsPage: the search bar still contains entered words 'kontakt' and url ends with '/Infosüsteemid?searchText=kontakt&sort=meta.update_timestamp&dir=DESC'
Then InfosytemsPage: the search bar still contains entered words 'kontakt' and url ends with '/Infosüsteemid?searchText=kontakt&sort=meta.update_timestamp&dir=DESC'
29 changes: 9 additions & 20 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,12 @@
</dependency>

<!-- TARA integration related -->
<!-- ENDOF TARA integration related -->

<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.5.7</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<!-- ENDOF TARA integration related -->

<dependency>
<groupId>ee.ria.riha</groupId>
Expand All @@ -87,7 +75,7 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.12</version>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand Down Expand Up @@ -177,10 +165,11 @@
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<skip>true</skip>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
</plugin>
</plugins>
Expand Down
8 changes: 6 additions & 2 deletions backend/src/main/java/ee/ria/riha/client/StorageClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ public Long update(String path, Long id, Object entity) {
new ParameterizedTypeReference<>() {
});

return response.get("ok").asLong();
long responseOk = response.get("ok").asLong();

return responseOk;
}

/**
Expand All @@ -298,7 +300,9 @@ public Long remove(String path, Long id) {
new ParameterizedTypeReference<>() {
});

return response.get("ok").asLong();
long responseOk = response.get("ok").asLong();

return responseOk;
}

public static class ParameterizedListTypeReference implements ParameterizedType {
Expand Down
34 changes: 34 additions & 0 deletions backend/src/main/java/ee/ria/riha/conf/OAuthConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ee.ria.riha.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository;
import org.springframework.security.oauth2.core.AuthorizationGrantType;

@Configuration
public class OAuthConfiguration {

@Bean
@Profile("!dev")
public ClientRegistrationRepository clientRegistrationRepository(ApplicationProperties applicationProperties) {
ApplicationProperties.TaraProperties taraConfig = applicationProperties.getTara();
return new InMemoryClientRegistrationRepository(
ClientRegistration
.withRegistrationId(taraConfig.getRegistrationId())
.authorizationUri(taraConfig.getUserAuthorizationUri())
.clientId(taraConfig.getClientId())
.clientName(taraConfig.getClientId())
.clientSecret(taraConfig.getClientSecret())
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
.redirectUri(taraConfig.getRegisteredRedirectUri())
.tokenUri(taraConfig.getAccessTokenUri())
.jwkSetUri(taraConfig.getJwkKeySetUri())
.scope(taraConfig.getScope())
.build()
);
}

}
32 changes: 29 additions & 3 deletions backend/src/main/java/ee/ria/riha/conf/WebMvcConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@
import ee.ria.riha.service.util.FilterableArgumentResolver;
import ee.ria.riha.service.util.PageableArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.CorsEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementPortType;
import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
import org.springframework.boot.actuate.endpoint.web.*;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.env.Environment;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpStatus;
import org.springframework.lang.NonNull;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.*;

import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.TimeUnit;

@Configuration
Expand Down Expand Up @@ -84,4 +92,22 @@ public UUID convert(@NonNull String source) {
return UUID.fromString(source);
}
}

@Bean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
List<ExposableEndpoint<?>> allEndpoints = new ArrayList();
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
allEndpoints.addAll(webEndpoints);
allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
String basePath = webEndpointProperties.getBasePath();
EndpointMapping endpointMapping = new EndpointMapping(basePath);
boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
}


private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
}
}
Loading

0 comments on commit 6f4f0af

Please sign in to comment.