-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
writer/src/test/java/com/opendatahub/timeseries/bdp/writer/AuthorizationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-FileCopyrightText: NOI Techpark <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
package com.opendatahub.timeseries.bdp.writer; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.opendatahub.timeseries.bdp.writer.writer.authz.AuthorizeSyncStation; | ||
|
||
public class AuthorizationTest { | ||
@Test | ||
public void testStationSyncUrlMatch() { | ||
// actually matches what's in the URL | ||
var uri = "bdp://station?origin=testorigin&stationType=testtype&syncState=false&onlyActivation=true"; | ||
assertTrue(AuthorizeSyncStation.uriMatches(uri, "testtype", "testorigin", false, true)); | ||
assertFalse(AuthorizeSyncStation.uriMatches(uri, "EchargingStation", "testorigin", false, true)); | ||
assertFalse(AuthorizeSyncStation.uriMatches(uri, "testtype", "A22", false, true)); | ||
assertFalse(AuthorizeSyncStation.uriMatches(uri, "testtype", "testorigin", true, true)); | ||
assertFalse(AuthorizeSyncStation.uriMatches(uri, "testtype", "testorigin", false, false)); | ||
|
||
uri = "bdp://station?origin=testorigin&syncState=false&onlyActivation=true"; | ||
// Missing stationType in URL | ||
assertFalse(AuthorizeSyncStation.uriMatches(uri, "EchargingStation", "testorigin", false, true)); | ||
|
||
uri = "bdp://station?origin=testorigin&stationType=test1&stationType=test2&syncState=false&onlyActivation=true"; | ||
// duplicate parameter | ||
assertTrue(AuthorizeSyncStation.uriMatches(uri, "test1", "testorigin", false, true)); | ||
assertTrue(AuthorizeSyncStation.uriMatches(uri, "test2", "testorigin", false, true)); | ||
} | ||
} |