taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
270 stars 163 forks source link

fix diacritic encoding for downloading wiki details #359

Closed AdrianDiemerDev closed 3 years ago

AdrianDiemerDev commented 3 years ago

Wiki pages with diacritics in their titles (lika ä,ö,ü) are not working with the current version of the client.

I suggest removing the seemingly unnessecary URL-encoding.

alexeyOnGitHub commented 3 years ago

how did you test this? have you ran the existing integration tests against your own Redmine instance? e.g. WikiManagerIT and others

AdrianDiemerDev commented 3 years ago

I tried running the Integrationtests against my own redmine container but that failed spectacularly. I assume the testsystem has to contain the correct content in order for the tests to run correctly?

If you could start up your test machine, I could let the tests run.

alexeyOnGitHub commented 3 years ago

I recall there were a few tests that fail because there is no REST API in redmine to set up a few things, so I configured those myself. but other tests should work. there are a few config params in api_test.properties file, which you may need to adjust for your local setup.

the best solution is to integrate docker redmine container into the test process for this project, so that everyone can run these tests on their local box. the test container would be launched locally and then shut down after all tests.

AdrianDiemerDev commented 3 years ago

I used the docker environment provided here for my tests.

However, I have no experience with gradle so I don't really feel qualified to make that change. Also, I'm not sure if that's even that great an idea since it would require everyone to have a docker environment in order to run the tests.

Another problem is that the bind mounts which would be necessary to persist a state of the application (i.e. rest api activated) don't work very well on Windows.

alexeyOnGitHub commented 3 years ago

please include tests demonstrating the problem. all current integration tests for WikiManager pass. I added a test for a wiki page with the symbols you referenced:


    @Test
    public void wikiPageWithWeirdSymbolsCanBeLoaded() throws Exception {
        var wikiPageDetail = new WikiPageDetail(transport)
                .setTitle("title " + System.currentTimeMillis() + "ä ö ü")
                .setText("some text here")
                .setProjectKey(projectKey);
        wikiPageDetail.create();

        var loaded = manager.getWikiPageDetailByProjectAndTitle(projectKey, wikiPageDetail.getTitle());
        String title = wikiPageDetail.getTitle();
        String urlSafeTitleIsExpected = URLEncoder.encode(title, StandardCharsets.UTF_8.name());
        assertThat(loaded.getTitle()).isEqualToIgnoringCase(urlSafeTitleIsExpected);
    }