-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
536 additions
and
127 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
471 changes: 422 additions & 49 deletions
471
src/main/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/ApiBridge.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
5 changes: 5 additions & 0 deletions
5
...n/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/dto/GetAccClientIdDTO.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,5 @@ | ||
package no.seime.openhab.binding.panasoniccomfortcloud.internal.dto; | ||
|
||
public class GetAccClientIdDTO { | ||
public int language = 0; | ||
} |
42 changes: 0 additions & 42 deletions
42
src/main/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/dto/LoginRequest.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...ain/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/dto/LoginRequestDTO.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,18 @@ | ||
package no.seime.openhab.binding.panasoniccomfortcloud.internal.dto; | ||
|
||
public class LoginRequestDTO { | ||
|
||
public String client_id; | ||
public String redirect_uri; | ||
public String tenant; | ||
public String response_type; | ||
public String scope; | ||
public String audience; | ||
public String _csrf; | ||
public String state; | ||
public String _intstate; | ||
public String username; | ||
public String password; | ||
public String lang; | ||
public String connection; | ||
} |
30 changes: 0 additions & 30 deletions
30
src/main/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/dto/LoginResponse.java
This file was deleted.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
src/test/java/no/seime/openhab/binding/panasoniccomfortcloud/internal/APIClientTest.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,55 @@ | ||
package no.seime.openhab.binding.panasoniccomfortcloud.internal; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.security.NoSuchAlgorithmException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.openhab.core.storage.Storage; | ||
import org.openhab.core.test.storage.VolatileStorage; | ||
|
||
import com.google.gson.reflect.TypeToken; | ||
|
||
import no.seime.openhab.binding.panasoniccomfortcloud.internal.dto.GetGroupsRequest; | ||
import no.seime.openhab.binding.panasoniccomfortcloud.internal.dto.GetGroupsResponse; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class APIClientTest { | ||
|
||
private Storage storage = new VolatileStorage(); | ||
|
||
// Disabled - must have credentials to run | ||
// @Test | ||
public void test() throws PanasonicComfortCloudException { | ||
ApiBridge apiBridge = new ApiBridge(storage); | ||
|
||
String username = "FILL IN USERNAME TO TEST"; | ||
String password = "FILL IN PASSWORD TO TEST"; | ||
|
||
apiBridge.init(username, password, "1.20.0"); | ||
apiBridge.sendRequest(new GetGroupsRequest(), new TypeToken<GetGroupsResponse>() { | ||
}.getType()); | ||
} | ||
|
||
@Test | ||
public void testSha256() throws NoSuchAlgorithmException { | ||
String hash = ApiBridge.generateHash("XZlJsY7dnp32w4KCC39xehdfsENsR265TjzHGQoePVP"); | ||
assertEquals("TeFR13C1atlTUPWD1G9NdFCwvNC0Z0yOb7oVI8yjzvk", hash); | ||
} | ||
|
||
@Test | ||
public void testGenerateRandom() { | ||
String random = ApiBridge.generateRandomString(20); | ||
assertEquals(20, random.length()); | ||
} | ||
|
||
@Test | ||
public void testGenerateRandomHexString() { | ||
int length = "B7d80fb2bc3faE769b89Bf4EC9C4729eCfe690C1CbBa7c42a40A062dc2f4f3671daAaFF1Cf6777cdC23dfcfFfa6DabdDec825c8b0BfB2EFDe04FCE17Bb5e086e" | ||
.length(); | ||
String random = ApiBridge.generateRandomStringHex(length); | ||
assertEquals(length, random.length()); | ||
} | ||
} |
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,18 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<!-- encoders are assigned the type | ||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<logger name="no.seime.openhab.binding" level="TRACE" additivity="false"> | ||
<appender-ref ref="STDOUT"/> | ||
</logger> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
</configuration> |