jld3103
2 years ago
9 changed files with 1851 additions and 2 deletions
@ -0,0 +1 @@
|
||||
Subproject commit ea2264cc05443f295a662030ad13c4a40c744eb9 |
@ -0,0 +1,66 @@
|
||||
import 'package:test/test.dart'; |
||||
|
||||
import 'helper.dart'; |
||||
|
||||
Future main() async { |
||||
await run(await getDockerImage()); |
||||
} |
||||
|
||||
Future run(final DockerImage image) async { |
||||
group('uppush', () { |
||||
late DockerContainer container; |
||||
late TestNextcloudClient client; |
||||
setUp(() async { |
||||
container = await getDockerContainer(image); |
||||
client = await getTestClient( |
||||
container, |
||||
username: 'admin', |
||||
password: 'admin', |
||||
); |
||||
}); |
||||
tearDown(() => container.destroy()); |
||||
|
||||
test('Is installed', () async { |
||||
final response = await client.unifiedPushProvider.check(); |
||||
expect(response.success, isTrue); |
||||
}); |
||||
|
||||
test('Set keepalive', () async { |
||||
final response = await client.unifiedPushProvider.setKeepalive(keepalive: '10'); |
||||
expect(response.success, isTrue); |
||||
}); |
||||
|
||||
test('Create device', () async { |
||||
final response = await client.unifiedPushProvider.createDevice(deviceName: 'Test'); |
||||
expect(response.success, isTrue); |
||||
expect(response.deviceId, isNotEmpty); |
||||
}); |
||||
|
||||
test('Delete device', () async { |
||||
final deviceId = (await client.unifiedPushProvider.createDevice(deviceName: 'Test')).deviceId; |
||||
|
||||
final response = await client.unifiedPushProvider.deleteDevice(deviceId: deviceId); |
||||
expect(response.success, isTrue); |
||||
}); |
||||
|
||||
test('Create app', () async { |
||||
final deviceId = (await client.unifiedPushProvider.createDevice(deviceName: 'Test')).deviceId; |
||||
|
||||
final response = await client.unifiedPushProvider.createApp(deviceId: deviceId, appName: 'Test'); |
||||
expect(response.success, isTrue); |
||||
expect(response.token, isNotEmpty); |
||||
}); |
||||
|
||||
test('UnifiedPush discovery', () async { |
||||
final response = await client.unifiedPushProvider.unifiedpushDiscovery(token: 'example'); |
||||
expect(response.unifiedpush.version, 1); |
||||
}); |
||||
|
||||
test('Matrix gateway discovery', () async { |
||||
final response = await client.unifiedPushProvider.gatewayMatrixDiscovery(); |
||||
expect(response.unifiedpush.gateway, 'matrix'); |
||||
}); |
||||
|
||||
// Deleting an app, sending a notification (also via matrix gateway) or listening for notifications is not possible because redis is not set up |
||||
}); |
||||
} |
@ -0,0 +1,444 @@
|
||||
{ |
||||
"openapi": "3.0.3", |
||||
"info": { |
||||
"title": "UnifiedPush Provider", |
||||
"description": "Use Nextcloud as a push provider for mobile phones' notifications", |
||||
"license": { |
||||
"name": "agpl" |
||||
}, |
||||
"version": "1.2.0" |
||||
}, |
||||
"paths": { |
||||
"/index.php/apps/uppush": { |
||||
"get": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Check if the UnifiedPush provider is present", |
||||
"operationId": "unified_push_provider-check", |
||||
"responses": { |
||||
"200": { |
||||
"description": "", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"success" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"success": { |
||||
"type": "boolean" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/index.php/apps/uppush/keepalive": { |
||||
"put": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Set keepalive interval.", |
||||
"operationId": "unified_push_provider-set-keepalive", |
||||
"parameters": [ |
||||
{ |
||||
"name": "keepalive", |
||||
"in": "query", |
||||
"description": "Keep alive value in seconds", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"success" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"success": { |
||||
"type": "boolean" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/index.php/apps/uppush/device": { |
||||
"put": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Request to create a new deviceId.", |
||||
"operationId": "unified_push_provider-create-device", |
||||
"parameters": [ |
||||
{ |
||||
"name": "deviceName", |
||||
"in": "query", |
||||
"description": "Name of the device", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"success", |
||||
"deviceId" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"success": { |
||||
"type": "boolean" |
||||
}, |
||||
"deviceId": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/index.php/apps/uppush/device/{deviceId}": { |
||||
"parameters": [ |
||||
{ |
||||
"name": "deviceId", |
||||
"in": "path", |
||||
"description": "ID of the device", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
], |
||||
"get": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Request to get push messages.", |
||||
"description": "This is a public page since it has to be handle by the non-connected app (NextPush app and not Nextcloud-app)", |
||||
"operationId": "unified_push_provider-sync-device", |
||||
"responses": { |
||||
"401": { |
||||
"description": "Missing permissions to sync device", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"success" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"success": { |
||||
"type": "boolean" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"delete": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Delete a device.", |
||||
"operationId": "unified_push_provider-delete-device", |
||||
"responses": { |
||||
"200": { |
||||
"description": "Device deleted successfully", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"success" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"success": { |
||||
"type": "boolean" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/index.php/apps/uppush/app": { |
||||
"put": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Create an authorization token for a new 3rd party service.", |
||||
"operationId": "unified_push_provider-create-app", |
||||
"parameters": [ |
||||
{ |
||||
"name": "deviceId", |
||||
"in": "query", |
||||
"description": "ID of the device", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "string" |
||||
} |
||||
}, |
||||
{ |
||||
"name": "appName", |
||||
"in": "query", |
||||
"description": "Name of the app", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
], |
||||
"responses": { |
||||
"200": { |
||||
"description": "App created successfully", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"success", |
||||
"token" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"success": { |
||||
"type": "boolean" |
||||
}, |
||||
"token": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/index.php/apps/uppush/app/{token}": { |
||||
"parameters": [ |
||||
{ |
||||
"name": "token", |
||||
"in": "path", |
||||
"description": "Token of the app", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
], |
||||
"delete": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Delete an authorization token.", |
||||
"operationId": "unified_push_provider-delete-app", |
||||
"responses": { |
||||
"200": { |
||||
"description": "App deleted successfully", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"success" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"success": { |
||||
"type": "boolean" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/index.php/apps/uppush/push/{token}": { |
||||
"parameters": [ |
||||
{ |
||||
"name": "token", |
||||
"in": "path", |
||||
"description": "Token of the app to push to", |
||||
"required": true, |
||||
"schema": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
], |
||||
"post": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Receive notifications from 3rd parties.", |
||||
"operationId": "unified_push_provider-push", |
||||
"responses": { |
||||
"201": { |
||||
"description": "Notification pushed successfully", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"success" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"success": { |
||||
"type": "boolean" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"get": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Unifiedpush discovery Following specifications", |
||||
"operationId": "unified_push_provider-unifiedpush-discovery", |
||||
"responses": { |
||||
"200": { |
||||
"description": "", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"unifiedpush" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"unifiedpush": { |
||||
"required": [ |
||||
"version" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"version": { |
||||
"type": "integer" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"/index.php/apps/uppush/gateway/matrix": { |
||||
"get": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Matrix Gateway discovery", |
||||
"operationId": "unified_push_provider-gateway-matrix-discovery", |
||||
"responses": { |
||||
"200": { |
||||
"description": "", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"unifiedpush" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"unifiedpush": { |
||||
"required": [ |
||||
"gateway" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"gateway": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"post": { |
||||
"tags": [ |
||||
"unified_push_provider" |
||||
], |
||||
"summary": "Matrix Gateway", |
||||
"operationId": "unified_push_provider-gateway-matrix", |
||||
"responses": { |
||||
"200": { |
||||
"description": "", |
||||
"content": { |
||||
"application/json": { |
||||
"schema": { |
||||
"required": [ |
||||
"rejected" |
||||
], |
||||
"type": "object", |
||||
"properties": { |
||||
"rejected": { |
||||
"type": "array", |
||||
"items": { |
||||
"type": "string" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"components": { |
||||
"schemas": {}, |
||||
"securitySchemes": { |
||||
"basic_auth": { |
||||
"type": "http", |
||||
"scheme": "basic" |
||||
} |
||||
} |
||||
}, |
||||
"security": [ |
||||
{ |
||||
"basic_auth": [] |
||||
} |
||||
], |
||||
"tags": [] |
||||
} |
Loading…
Reference in new issue