media-sound/supysonic: addition
Package-Manager: Portage-2.3.11, Repoman-2.3.3
This commit is contained in:
parent
1596e0825c
commit
a26bcad070
5 changed files with 792 additions and 0 deletions
|
@ -0,0 +1,27 @@
|
|||
From 8ddd89ee8b315d943688021c843c514dc15bd5f9 Mon Sep 17 00:00:00 2001
|
||||
From: Tobias Klaus <tk@meskalero.de>
|
||||
Date: Fri, 6 Jan 2017 18:33:35 +0100
|
||||
Subject: [PATCH] fixes execution from initd script
|
||||
|
||||
---
|
||||
bin/supysonic-watcher | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/bin/supysonic-watcher b/bin/supysonic-watcher
|
||||
index 33d5b7e..fd937b3 100755
|
||||
--- a/bin/supysonic-watcher
|
||||
+++ b/bin/supysonic-watcher
|
||||
@@ -24,8 +24,8 @@ from supysonic.watcher import SupysonicWatcher
|
||||
|
||||
watcher = SupysonicWatcher()
|
||||
watcher.stdin_path = '/dev/null'
|
||||
-watcher.stdout_path = '/dev/tty'
|
||||
-watcher.stderr_path = '/dev/tty'
|
||||
+watcher.stdout_path = '/dev/null'
|
||||
+watcher.stderr_path = '/dev/null'
|
||||
watcher.pidfile_path = '/tmp/supysonic-watcher.pid'
|
||||
watcher.pidfile_timeout = 5
|
||||
|
||||
--
|
||||
2.11.0
|
||||
|
|
@ -0,0 +1,695 @@
|
|||
From a7b17aed5c85fad7073f8c839dab217676d27808 Mon Sep 17 00:00:00 2001
|
||||
From: Tobias Klaus <tk@meskalero.de>
|
||||
Date: Tue, 12 Sep 2017 10:13:33 +0200
|
||||
Subject: [PATCH] fixes setup and test
|
||||
|
||||
---
|
||||
setup.py | 10 +-
|
||||
tests/__init__.py | 25 ----
|
||||
tests/test_api.py | 297 -------------------------------------------
|
||||
tests/test_frontend.py | 105 ---------------
|
||||
tests/test_manager_folder.py | 91 -------------
|
||||
tests/test_manager_user.py | 96 --------------
|
||||
6 files changed, 5 insertions(+), 619 deletions(-)
|
||||
delete mode 100644 tests/__init__.py
|
||||
delete mode 100644 tests/test_api.py
|
||||
delete mode 100644 tests/test_frontend.py
|
||||
delete mode 100644 tests/test_manager_folder.py
|
||||
delete mode 100644 tests/test_manager_user.py
|
||||
|
||||
diff --git a/setup.py b/setup.py
|
||||
index a154188..f1225b8 100755
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -14,8 +14,8 @@ import supysonic as project
|
||||
|
||||
from setuptools import setup
|
||||
from setuptools import find_packages
|
||||
-from pip.req import parse_requirements
|
||||
-from pip.download import PipSession
|
||||
+#from pip.req import parse_requirements
|
||||
+#from pip.download import PipSession
|
||||
|
||||
|
||||
setup(
|
||||
@@ -29,10 +29,10 @@ setup(
|
||||
url=project.URL,
|
||||
license=project.LICENSE,
|
||||
packages=find_packages(),
|
||||
- install_requires=[str(x.req) for x in
|
||||
- parse_requirements('requirements.txt', session=PipSession())],
|
||||
+ # install_requires=[str(x.req) for x in
|
||||
+ # parse_requirements('requirements.txt', session=PipSession())],
|
||||
scripts=['bin/supysonic-cli', 'bin/supysonic-watcher'],
|
||||
zip_safe=False,
|
||||
include_package_data=True,
|
||||
- test_suite="tests.suite"
|
||||
+# test_suite="tests.suite"
|
||||
)
|
||||
diff --git a/tests/__init__.py b/tests/__init__.py
|
||||
deleted file mode 100644
|
||||
index bd00f37..0000000
|
||||
--- a/tests/__init__.py
|
||||
+++ /dev/null
|
||||
@@ -1,25 +0,0 @@
|
||||
-# -*- coding: utf-8 -*-
|
||||
-# vim:fenc=utf-8
|
||||
-#
|
||||
-# This file is part of Supysonic.
|
||||
-# Supysonic is a Python implementation of the Subsonic server API.
|
||||
-#
|
||||
-# Copyright (C) 2013-2017 Alban 'spl0k' Féron
|
||||
-# 2017 Óscar García Amor
|
||||
-#
|
||||
-# Distributed under terms of the GNU AGPLv3 license.
|
||||
-
|
||||
-import unittest
|
||||
-
|
||||
-from .test_manager_folder import FolderManagerTestCase
|
||||
-from .test_manager_user import UserManagerTestCase
|
||||
-from .test_api import ApiTestCase
|
||||
-from .test_frontend import FrontendTestCase
|
||||
-
|
||||
-def suite():
|
||||
- suite = unittest.TestSuite()
|
||||
- suite.addTest(unittest.makeSuite(FolderManagerTestCase))
|
||||
- suite.addTest(unittest.makeSuite(UserManagerTestCase))
|
||||
- suite.addTest(unittest.makeSuite(ApiTestCase))
|
||||
- suite.addTest(unittest.makeSuite(FrontendTestCase))
|
||||
- return suite
|
||||
diff --git a/tests/test_api.py b/tests/test_api.py
|
||||
deleted file mode 100644
|
||||
index cffe97e..0000000
|
||||
--- a/tests/test_api.py
|
||||
+++ /dev/null
|
||||
@@ -1,297 +0,0 @@
|
||||
-#!/usr/bin/env python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-# vim:fenc=utf-8
|
||||
-#
|
||||
-# This file is part of Supysonic.
|
||||
-# Supysonic is a Python implementation of the Subsonic server API.
|
||||
-#
|
||||
-# Copyright (C) 2013-2017 Alban 'spl0k' Féron
|
||||
-# 2017 Óscar García Amor
|
||||
-#
|
||||
-# Distributed under terms of the GNU AGPLv3 license.
|
||||
-
|
||||
-from supysonic import db
|
||||
-from supysonic.managers.user import UserManager
|
||||
-
|
||||
-import sys
|
||||
-import unittest
|
||||
-import uuid
|
||||
-
|
||||
-# Create an empty sqlite database in memory
|
||||
-store = db.get_store("sqlite:")
|
||||
-# Read schema from file
|
||||
-with open('schema/sqlite.sql') as sql:
|
||||
- schema = sql.read()
|
||||
-# Create tables on memory database
|
||||
-for command in schema.split(';'):
|
||||
- store.execute(command)
|
||||
-# Create some users
|
||||
-UserManager.add(store, 'alice', 'alice', 'test@example.com', True)
|
||||
-UserManager.add(store, 'bob', 'bob', 'bob@example.com', False)
|
||||
-UserManager.add(store, 'charlie', 'charlie', 'charlie@example.com', False)
|
||||
-
|
||||
-# Create a mockup of web
|
||||
-from flask import Flask
|
||||
-app = Flask(__name__)
|
||||
-class web():
|
||||
- app = app
|
||||
- store = store
|
||||
-sys.modules['supysonic.web'] = web()
|
||||
-
|
||||
-# Import module and set app in test mode
|
||||
-import supysonic.api
|
||||
-
|
||||
-class ApiTestCase(unittest.TestCase):
|
||||
- def setUp(self):
|
||||
- self.app = app.test_client()
|
||||
-
|
||||
- def test_ping(self):
|
||||
- # GET non-existent user
|
||||
- rv = self.app.get('/rest/ping.view?u=null&p=null&c=test')
|
||||
- self.assertIn('status="failed"', rv.data)
|
||||
- self.assertIn('message="Unauthorized"', rv.data)
|
||||
- # POST non-existent user
|
||||
- rv = self.app.post('/rest/ping.view', data=dict(u='null', p='null', c='test'))
|
||||
- self.assertIn('status="failed"', rv.data)
|
||||
- self.assertIn('message="Unauthorized"', rv.data)
|
||||
- # GET user request
|
||||
- rv = self.app.get('/rest/ping.view?u=alice&p=alice&c=test')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # POST user request
|
||||
- rv = self.app.post('/rest/ping.view', data=dict(u='alice', p='alice', c='test'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # GET user request with old enc:
|
||||
- rv = self.app.get('/rest/ping.view?u=alice&p=enc:616c696365&c=test')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # POST user request with old enc:
|
||||
- rv = self.app.post('/rest/ping.view', data=dict(u='alice', p='enc:616c696365', c='test'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # GET user request with bad password
|
||||
- rv = self.app.get('/rest/ping.view?u=alice&p=bad&c=test')
|
||||
- self.assertIn('status="failed"', rv.data)
|
||||
- self.assertIn('message="Unauthorized"', rv.data)
|
||||
- # POST user request with bad password
|
||||
- rv = self.app.post('/rest/ping.view', data=dict(u='alice', p='bad', c='test'))
|
||||
- self.assertIn('status="failed"', rv.data)
|
||||
- self.assertIn('message="Unauthorized"', rv.data)
|
||||
-
|
||||
- def test_ping_in_jsonp(self):
|
||||
- # If ping in jsonp works all other endpoints must work OK
|
||||
- # GET non-existent user
|
||||
- rv = self.app.get('/rest/ping.view?u=null&p=null&c=test&f=jsonp&callback=test')
|
||||
- self.assertIn('"status": "failed"', rv.data)
|
||||
- self.assertIn('"message": "Unauthorized"', rv.data)
|
||||
- # POST non-existent user
|
||||
- rv = self.app.post('/rest/ping.view', data=dict(u='null', p='null', c='test', f='jsonp', callback='test'))
|
||||
- self.assertIn('"status": "failed"', rv.data)
|
||||
- self.assertIn('"message": "Unauthorized"', rv.data)
|
||||
- # GET user request
|
||||
- rv = self.app.get('/rest/ping.view?u=alice&p=alice&c=test&f=jsonp&callback=test')
|
||||
- self.assertIn('"status": "ok"', rv.data)
|
||||
- # POST user request
|
||||
- rv = self.app.post('/rest/ping.view', data=dict(u='alice', p='alice', c='test', f='jsonp', callback='test'))
|
||||
- self.assertIn('"status": "ok"', rv.data)
|
||||
- # GET user request with bad password
|
||||
- rv = self.app.get('/rest/ping.view?u=alice&p=bad&c=test&f=jsonp&callback=test')
|
||||
- self.assertIn('"status": "failed"', rv.data)
|
||||
- self.assertIn('"message": "Unauthorized"', rv.data)
|
||||
- # POST user request with bad password
|
||||
- rv = self.app.post('/rest/ping.view', data=dict(u='alice', p='bad', c='test', f='jsonp', callback='test'))
|
||||
- self.assertIn('"status": "failed"', rv.data)
|
||||
- self.assertIn('"message": "Unauthorized"', rv.data)
|
||||
-
|
||||
- def test_not_implemented(self):
|
||||
- # Access to not implemented endpoint
|
||||
- rv = self.app.get('/rest/not-implemented?u=alice&p=alice&c=test')
|
||||
- self.assertIn('message="Not implemented"', rv.data)
|
||||
- rv = self.app.post('/rest/not-implemented', data=dict(u='alice', p='alice', c='test'))
|
||||
- self.assertIn('message="Not implemented"', rv.data)
|
||||
-
|
||||
- def test_get_license(self):
|
||||
- # GET user request
|
||||
- rv = self.app.get('/rest/getLicense.view?u=alice&p=alice&c=test')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- self.assertIn('license valid="true"', rv.data)
|
||||
- # POST user request
|
||||
- rv = self.app.post('/rest/getLicense.view', data=dict(u='alice', p='alice', c='test'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- self.assertIn('license valid="true"', rv.data)
|
||||
-
|
||||
- def test_get_user(self):
|
||||
- # GET missing username
|
||||
- rv = self.app.get('/rest/getUser.view?u=alice&p=alice&c=test')
|
||||
- self.assertIn('message="Missing username"', rv.data)
|
||||
- # POST missing username
|
||||
- rv = self.app.post('/rest/getUser.view', data=dict(u='alice', p='alice', c='test'))
|
||||
- self.assertIn('message="Missing username"', rv.data)
|
||||
- # GET non-admin request for other user
|
||||
- rv = self.app.get('/rest/getUser.view?u=bob&p=bob&c=test&username=alice')
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # POST non-admin request for other user
|
||||
- rv = self.app.post('/rest/getUser.view', data=dict(u='bob', p='bob', c='test', username='alice'))
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # GET non-existent user
|
||||
- rv = self.app.get('/rest/getUser.view?u=alice&p=alice&c=test&username=null')
|
||||
- self.assertIn('message="Unknown user"', rv.data)
|
||||
- # POST non-existent user
|
||||
- rv = self.app.post('/rest/getUser.view', data=dict(u='alice', p='alice', c='test', username='null'))
|
||||
- self.assertIn('message="Unknown user"', rv.data)
|
||||
- # GET admin request
|
||||
- rv = self.app.get('/rest/getUser.view?u=alice&p=alice&c=test&username=alice')
|
||||
- self.assertIn('adminRole="true"', rv.data)
|
||||
- self.assertIn('username="alice"', rv.data)
|
||||
- # POST admin request
|
||||
- rv = self.app.post('/rest/getUser.view', data=dict(u='alice', p='alice', c='test', username='alice'))
|
||||
- self.assertIn('adminRole="true"', rv.data)
|
||||
- self.assertIn('username="alice"', rv.data)
|
||||
- # GET admin request for other user
|
||||
- rv = self.app.get('/rest/getUser.view?u=alice&p=alice&c=test&username=bob')
|
||||
- self.assertIn('username="bob"', rv.data)
|
||||
- self.assertIn('adminRole="false"', rv.data)
|
||||
- # POST admin request for other user
|
||||
- rv = self.app.post('/rest/getUser.view', data=dict(u='alice', p='alice', c='test', username='bob'))
|
||||
- self.assertIn('username="bob"', rv.data)
|
||||
- self.assertIn('adminRole="false"', rv.data)
|
||||
- # GET non-admin request
|
||||
- rv = self.app.get('/rest/getUser.view?u=charlie&p=charlie&c=test&username=charlie')
|
||||
- self.assertIn('username="charlie"', rv.data)
|
||||
- self.assertIn('adminRole="false"', rv.data)
|
||||
- # POST non-admin request
|
||||
- rv = self.app.post('/rest/getUser.view', data=dict(u='charlie', p='charlie', c='test', username='charlie'))
|
||||
- self.assertIn('username="charlie"', rv.data)
|
||||
- self.assertIn('adminRole="false"', rv.data)
|
||||
-
|
||||
- def test_get_users(self):
|
||||
- # GET admin request
|
||||
- rv = self.app.get('/rest/getUsers.view?u=alice&p=alice&c=test')
|
||||
- self.assertIn('alice', rv.data)
|
||||
- self.assertIn('bob', rv.data)
|
||||
- self.assertIn('charlie', rv.data)
|
||||
- # POST admin request
|
||||
- rv = self.app.post('/rest/getUsers.view', data=dict(u='alice', p='alice', c='test'))
|
||||
- self.assertIn('alice', rv.data)
|
||||
- self.assertIn('bob', rv.data)
|
||||
- self.assertIn('charlie', rv.data)
|
||||
- # GET non-admin request
|
||||
- rv = self.app.get('/rest/getUsers.view?u=bob&p=bob&c=test')
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # POST non-admin request
|
||||
- rv = self.app.post('/rest/getUsers.view', data=dict(u='bob', p='bob', c='test'))
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
-
|
||||
- def test_create_user(self):
|
||||
- # GET non-admin request
|
||||
- rv = self.app.get('/rest/createUser.view?u=bob&p=bob&c=test')
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # POST non-admin request
|
||||
- rv = self.app.post('/rest/createUser.view', data=dict(u='bob', p='bob', c='test'))
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # GET incomplete request
|
||||
- rv = self.app.get('/rest/createUser.view?u=alice&p=alice&c=test')
|
||||
- self.assertIn('message="Missing parameter"', rv.data)
|
||||
- # POST incomplete request
|
||||
- rv = self.app.post('/rest/createUser.view', data=dict(u='alice', p='alice', c='test'))
|
||||
- self.assertIn('message="Missing parameter"', rv.data)
|
||||
- # GET create user and test that user is created
|
||||
- rv = self.app.get('/rest/createUser.view?u=alice&p=alice&c=test&username=david&password=david&email=david%40example.com&adminRole=True')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- rv = self.app.get('/rest/getUser.view?u=david&p=david&c=test&username=david')
|
||||
- self.assertIn('username="david"', rv.data)
|
||||
- self.assertIn('email="david@example.com"', rv.data)
|
||||
- self.assertIn('adminRole="true"', rv.data)
|
||||
- # POST create user and test that user is created
|
||||
- rv = self.app.post('/rest/createUser.view', data=dict(u='alice', p='alice', c='test', username='elanor', password='elanor', email='elanor@example.com', adminRole=True))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- rv = self.app.post('/rest/getUser.view', data=dict(u='elanor', p='elanor', c='test', username='elanor'))
|
||||
- self.assertIn('username="elanor"', rv.data)
|
||||
- self.assertIn('email="elanor@example.com"', rv.data)
|
||||
- self.assertIn('adminRole="true"', rv.data)
|
||||
- # GET create duplicate
|
||||
- rv = self.app.get('/rest/createUser.view?u=alice&p=alice&c=test&username=david&password=david&email=david%40example.com&adminRole=True')
|
||||
- self.assertIn('message="There is already a user with that username"', rv.data)
|
||||
- # POST create duplicate
|
||||
- rv = self.app.post('/rest/createUser.view', data=dict(u='alice', p='alice', c='test', username='elanor', password='elanor', email='elanor@example.com', adminRole=True))
|
||||
- self.assertIn('message="There is already a user with that username"', rv.data)
|
||||
-
|
||||
- def test_delete_user(self):
|
||||
- # GET non-admin request
|
||||
- rv = self.app.get('/rest/deleteUser.view?u=bob&p=bob&c=test')
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # POST non-admin request
|
||||
- rv = self.app.post('/rest/deleteUser.view', data=dict(u='bob', p='bob', c='test'))
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # GET incomplete request
|
||||
- rv = self.app.get('/rest/deleteUser.view?u=alice&p=alice&c=test')
|
||||
- self.assertIn('message="Unknown user"', rv.data)
|
||||
- # POST incomplete request
|
||||
- rv = self.app.post('/rest/deleteUser.view', data=dict(u='alice', p='alice', c='test'))
|
||||
- self.assertIn('message="Unknown user"', rv.data)
|
||||
- # GET delete non-existent user
|
||||
- rv = self.app.get('/rest/deleteUser.view?u=alice&p=alice&c=test&username=nonexistent')
|
||||
- self.assertIn('message="Unknown user"', rv.data)
|
||||
- # POST delete non-existent user
|
||||
- rv = self.app.post('/rest/deleteUser.view', data=dict(u='alice', p='alice', c='test', username='nonexistent'))
|
||||
- self.assertIn('message="Unknown user"', rv.data)
|
||||
- # GET delete existent user
|
||||
- rv = self.app.get('/rest/deleteUser.view?u=alice&p=alice&c=test&username=elanor')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- rv = self.app.get('/rest/getUser.view?u=alice&p=alice&c=test&username=elanor')
|
||||
- self.assertIn('message="Unknown user"', rv.data)
|
||||
- # POST delete existent user
|
||||
- rv = self.app.post('/rest/deleteUser.view', data=dict(u='alice', p='alice', c='test', username='david'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- rv = self.app.post('/rest/getUser.view', data=dict(u='alice', p='alice', c='test', username='david'))
|
||||
- self.assertIn('message="Unknown user"', rv.data)
|
||||
-
|
||||
- def test_change_password(self):
|
||||
- # GET incomplete request
|
||||
- rv = self.app.get('/rest/changePassword.view?u=alice&p=alice&c=test')
|
||||
- self.assertIn('message="Missing parameter"', rv.data)
|
||||
- # POST incomplete request
|
||||
- rv = self.app.post('/rest/changePassword.view', data=dict(u='alice', p='alice', c='test'))
|
||||
- self.assertIn('message="Missing parameter"', rv.data)
|
||||
- # GET non-admin change own password
|
||||
- rv = self.app.get('/rest/changePassword.view?u=bob&p=bob&c=test&username=bob&password=newpassword')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # POST non-admin change own password
|
||||
- rv = self.app.post('/rest/changePassword.view', data=dict(u='bob', p='newpassword', c='test', username='bob', password='bob'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # GET non-admin change other user password
|
||||
- rv = self.app.get('/rest/changePassword.view?u=bob&p=bob&c=test&username=alice&password=newpassword')
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # POST non-admin change other user password
|
||||
- rv = self.app.post('/rest/changePassword.view', data=dict(u='bob', p='bob', c='test', username='alice', password='newpassword'))
|
||||
- self.assertIn('message="Admin restricted"', rv.data)
|
||||
- # GET admin change other user password
|
||||
- rv = self.app.get('/rest/changePassword.view?u=bob&p=bob&c=test&username=bob&password=newpassword')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # POST admin change other user password
|
||||
- rv = self.app.post('/rest/changePassword.view', data=dict(u='bob', p='newpassword', c='test', username='bob', password='bob'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # GET change non-existent user password
|
||||
- rv = self.app.get('/rest/changePassword.view?u=alice&p=alice&c=test&username=nonexistent&password=nonexistent')
|
||||
- self.assertIn('message="No such user"', rv.data)
|
||||
- # POST change non-existent user password
|
||||
- rv = self.app.post('/rest/changePassword.view', data=dict(u='alice', p='alice', c='test', username='nonexistent', password='nonexistent'))
|
||||
- self.assertIn('message="No such user"', rv.data)
|
||||
- # GET non-admin change own password using extended utf-8 characters
|
||||
- rv = self.app.get('/rest/changePassword.view?u=bob&p=bob&c=test&username=bob&password=новыйпароль')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # POST non-admin change own password using extended utf-8 characters
|
||||
- rv = self.app.post('/rest/changePassword.view', data=dict(u='bob', p='новыйпароль', c='test', username='bob', password='bob'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # GET non-admin change own password using extended utf-8 characters with old enc:
|
||||
- rv = self.app.get('/rest/changePassword.view?u=bob&p=enc:626f62&c=test&username=bob&password=новыйпароль')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # POST non-admin change own password using extended utf-8 characters with old enc:
|
||||
- rv = self.app.post('/rest/changePassword.view', data=dict(u='bob', p='enc:d0bdd0bed0b2d18bd0b9d0bfd0b0d180d0bed0bbd18c', c='test', username='bob', password='bob'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # GET non-admin change own password using enc: in password
|
||||
- rv = self.app.get('/rest/changePassword.view?u=bob&p=bob&c=test&username=bob&password=enc:test')
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
- # POST non-admin change own password using enc: in password
|
||||
- rv = self.app.post('/rest/changePassword.view', data=dict(u='bob', p='enc:test', c='test', username='bob', password='bob'))
|
||||
- self.assertIn('status="ok"', rv.data)
|
||||
-
|
||||
-if __name__ == '__main__':
|
||||
- unittest.main()
|
||||
diff --git a/tests/test_frontend.py b/tests/test_frontend.py
|
||||
deleted file mode 100644
|
||||
index f7d8d26..0000000
|
||||
--- a/tests/test_frontend.py
|
||||
+++ /dev/null
|
||||
@@ -1,105 +0,0 @@
|
||||
-#!/usr/bin/env python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-# vim:fenc=utf-8
|
||||
-#
|
||||
-# This file is part of Supysonic.
|
||||
-# Supysonic is a Python implementation of the Subsonic server API.
|
||||
-#
|
||||
-# Copyright (C) 2013-2017 Alban 'spl0k' Féron
|
||||
-# 2017 Óscar García Amor
|
||||
-#
|
||||
-# Distributed under terms of the GNU AGPLv3 license.
|
||||
-
|
||||
-from supysonic import db
|
||||
-from supysonic.managers.user import UserManager
|
||||
-
|
||||
-import sys
|
||||
-import unittest
|
||||
-import uuid
|
||||
-
|
||||
-# Create an empty sqlite database in memory
|
||||
-store = db.get_store("sqlite:")
|
||||
-# Read schema from file
|
||||
-with open('schema/sqlite.sql') as sql:
|
||||
- schema = sql.read()
|
||||
-# Create tables on memory database
|
||||
-for command in schema.split(';'):
|
||||
- store.execute(command)
|
||||
-# Create some users
|
||||
-UserManager.add(store, 'alice', 'alice', 'test@example.com', True)
|
||||
-UserManager.add(store, 'bob', 'bob', 'bob@example.com', False)
|
||||
-UserManager.add(store, 'charlie', 'charlie', 'charlie@example.com', False)
|
||||
-
|
||||
-# Create a mockup of web
|
||||
-from flask import Flask
|
||||
-app = Flask(__name__, template_folder='../supysonic/templates')
|
||||
-class web():
|
||||
- app = app
|
||||
- store = store
|
||||
-sys.modules['supysonic.web'] = web()
|
||||
-
|
||||
-# Import module and set app in test mode
|
||||
-import supysonic.frontend
|
||||
-app.secret_key = 'test-suite'
|
||||
-
|
||||
-class FrontendTestCase(unittest.TestCase):
|
||||
- def setUp(self):
|
||||
- self.app = app.test_client()
|
||||
-
|
||||
- def test_unauthorized_request(self):
|
||||
- # Unauthorized request
|
||||
- rv = self.app.get('/', follow_redirects=True)
|
||||
- self.assertIn('Please login', rv.data)
|
||||
-
|
||||
- def test_login_with_bad_data(self):
|
||||
- # Login with not blank user or password
|
||||
- rv = self.app.post('/user/login', data=dict(name='', password=''), follow_redirects=True)
|
||||
- self.assertIn('Missing user name', rv.data)
|
||||
- self.assertIn('Missing password', rv.data)
|
||||
- # Login with not valid user or password
|
||||
- rv = self.app.post('/user/login', data=dict(user='nonexistent', password='nonexistent'), follow_redirects=True)
|
||||
- self.assertIn('No such user', rv.data)
|
||||
- rv = self.app.post('/user/login', data=dict(user='alice', password='badpassword'), follow_redirects=True)
|
||||
- self.assertIn('Wrong password', rv.data)
|
||||
-
|
||||
- def test_login_admin(self):
|
||||
- # Login with a valid admin user
|
||||
- rv = self.app.post('/user/login', data=dict(user='alice', password='alice'), follow_redirects=True)
|
||||
- self.assertIn('Logged in', rv.data)
|
||||
- self.assertIn('Users', rv.data)
|
||||
- self.assertIn('Folders', rv.data)
|
||||
-
|
||||
- def test_login_non_admin(self):
|
||||
- # Login with a valid non-admin user
|
||||
- rv = self.app.post('/user/login', data=dict(user='bob', password='bob'), follow_redirects=True)
|
||||
- self.assertIn('Logged in', rv.data)
|
||||
- # Non-admin user cannot acces to users and folders
|
||||
- self.assertNotIn('Users', rv.data)
|
||||
- self.assertNotIn('Folders', rv.data)
|
||||
-
|
||||
- def test_root_with_valid_session(self):
|
||||
- # Root with valid session
|
||||
- with self.app.session_transaction() as sess:
|
||||
- sess['userid'] = store.find(db.User, db.User.name == 'alice').one().id
|
||||
- sess['username'] = 'alice'
|
||||
- rv = self.app.get('/', follow_redirects=True)
|
||||
- self.assertIn('alice', rv.data)
|
||||
- self.assertIn('Log out', rv.data)
|
||||
- self.assertIn('There\'s nothing much to see here.', rv.data)
|
||||
-
|
||||
- def test_root_with_non_valid_session(self):
|
||||
- # Root with a no-valid session
|
||||
- with self.app.session_transaction() as sess:
|
||||
- sess['userid'] = uuid.uuid4()
|
||||
- sess['username'] = 'alice'
|
||||
- rv = self.app.get('/', follow_redirects=True)
|
||||
- self.assertIn('Please login', rv.data)
|
||||
- # Root with a no-valid user
|
||||
- with self.app.session_transaction() as sess:
|
||||
- sess['userid'] = store.find(db.User, db.User.name == 'alice').one().id
|
||||
- sess['username'] = 'nonexistent'
|
||||
- rv = self.app.get('/', follow_redirects=True)
|
||||
- self.assertIn('Please login', rv.data)
|
||||
-
|
||||
-if __name__ == '__main__':
|
||||
- unittest.main()
|
||||
diff --git a/tests/test_manager_folder.py b/tests/test_manager_folder.py
|
||||
deleted file mode 100644
|
||||
index 9cbcea3..0000000
|
||||
--- a/tests/test_manager_folder.py
|
||||
+++ /dev/null
|
||||
@@ -1,91 +0,0 @@
|
||||
-#!/usr/bin/env python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-# vim:fenc=utf-8
|
||||
-#
|
||||
-# This file is part of Supysonic.
|
||||
-# Supysonic is a Python implementation of the Subsonic server API.
|
||||
-#
|
||||
-# Copyright (C) 2013-2017 Alban 'spl0k' Féron
|
||||
-# 2017 Óscar García Amor
|
||||
-#
|
||||
-# Distributed under terms of the GNU AGPLv3 license.
|
||||
-
|
||||
-from supysonic import db
|
||||
-from supysonic.managers.folder import FolderManager
|
||||
-
|
||||
-import os
|
||||
-import shutil
|
||||
-import tempfile
|
||||
-import unittest
|
||||
-import uuid
|
||||
-
|
||||
-class FolderManagerTestCase(unittest.TestCase):
|
||||
- def setUp(self):
|
||||
- # Create an empty sqlite database in memory
|
||||
- self.store = db.get_store("sqlite:")
|
||||
- # Read schema from file
|
||||
- with open('schema/sqlite.sql') as sql:
|
||||
- schema = sql.read()
|
||||
- # Create tables on memory database
|
||||
- for command in schema.split(';'):
|
||||
- self.store.execute(command)
|
||||
- # Create some temporary directories
|
||||
- self.media_dir = tempfile.mkdtemp()
|
||||
- self.music_dir = tempfile.mkdtemp()
|
||||
- # Add test folders
|
||||
- self.assertEqual(FolderManager.add(self.store, 'media', self.media_dir), FolderManager.SUCCESS)
|
||||
- self.assertEqual(FolderManager.add(self.store, 'music', self.music_dir), FolderManager.SUCCESS)
|
||||
- folder = db.Folder()
|
||||
- folder.root = False
|
||||
- folder.name = 'non-root'
|
||||
- folder.path = os.path.join(self.music_dir, 'subfolder')
|
||||
- self.store.add(folder)
|
||||
- self.store.commit()
|
||||
-
|
||||
- def tearDown(self):
|
||||
- shutil.rmtree(self.media_dir)
|
||||
- shutil.rmtree(self.music_dir)
|
||||
-
|
||||
- def test_get_folder(self):
|
||||
- # Get existing folders
|
||||
- for name in ['media', 'music']:
|
||||
- folder = self.store.find(db.Folder, db.Folder.name == name, db.Folder.root == True).one()
|
||||
- self.assertEqual(FolderManager.get(self.store, folder.id), (FolderManager.SUCCESS, folder))
|
||||
- # Get with invalid UUID
|
||||
- self.assertEqual(FolderManager.get(self.store, 'invalid-uuid'), (FolderManager.INVALID_ID, None))
|
||||
- # Non-existent folder
|
||||
- self.assertEqual(FolderManager.get(self.store, uuid.uuid4()), (FolderManager.NO_SUCH_FOLDER, None))
|
||||
-
|
||||
- def test_add_folder(self):
|
||||
- # Create duplicate
|
||||
- self.assertEqual(FolderManager.add(self.store,'media', self.media_dir), FolderManager.NAME_EXISTS)
|
||||
- # Duplicate path
|
||||
- self.assertEqual(FolderManager.add(self.store,'new-folder', self.media_dir), FolderManager.PATH_EXISTS)
|
||||
- # Invalid path
|
||||
- self.assertEqual(FolderManager.add(self.store,'invalid-path', os.path.abspath('/this/not/is/valid')), FolderManager.INVALID_PATH)
|
||||
- # Subfolder of already added path
|
||||
- os.mkdir(os.path.join(self.media_dir, 'subfolder'))
|
||||
- self.assertEqual(FolderManager.add(self.store,'subfolder', os.path.join(self.media_dir, 'subfolder')), FolderManager.PATH_EXISTS)
|
||||
-
|
||||
- def test_delete_folder(self):
|
||||
- # Delete existing folders
|
||||
- for name in ['media', 'music']:
|
||||
- folder = self.store.find(db.Folder, db.Folder.name == name, db.Folder.root == True).one()
|
||||
- self.assertEqual(FolderManager.delete(self.store, folder.id), FolderManager.SUCCESS)
|
||||
- # Delete invalid UUID
|
||||
- self.assertEqual(FolderManager.delete(self.store, 'invalid-uuid'), FolderManager.INVALID_ID)
|
||||
- # Delete non-existent folder
|
||||
- self.assertEqual(FolderManager.delete(self.store, uuid.uuid4()), FolderManager.NO_SUCH_FOLDER)
|
||||
- # Delete non-root folder
|
||||
- folder = self.store.find(db.Folder, db.Folder.name == 'non-root').one()
|
||||
- self.assertEqual(FolderManager.delete(self.store, folder.id), FolderManager.NO_SUCH_FOLDER)
|
||||
-
|
||||
- def test_delete_by_name(self):
|
||||
- # Delete existing folders
|
||||
- for name in ['media', 'music']:
|
||||
- self.assertEqual(FolderManager.delete_by_name(self.store, name), FolderManager.SUCCESS)
|
||||
- # Delete non-existent folder
|
||||
- self.assertEqual(FolderManager.delete_by_name(self.store, 'null'), FolderManager.NO_SUCH_FOLDER)
|
||||
-
|
||||
-if __name__ == '__main__':
|
||||
- unittest.main()
|
||||
diff --git a/tests/test_manager_user.py b/tests/test_manager_user.py
|
||||
deleted file mode 100644
|
||||
index 3194ddd..0000000
|
||||
--- a/tests/test_manager_user.py
|
||||
+++ /dev/null
|
||||
@@ -1,96 +0,0 @@
|
||||
-#!/usr/bin/env python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-# vim:fenc=utf-8
|
||||
-#
|
||||
-# This file is part of Supysonic.
|
||||
-# Supysonic is a Python implementation of the Subsonic server API.
|
||||
-#
|
||||
-# Copyright (C) 2013-2017 Alban 'spl0k' Féron
|
||||
-# 2017 Óscar García Amor
|
||||
-#
|
||||
-# Distributed under terms of the GNU AGPLv3 license.
|
||||
-
|
||||
-from supysonic import db
|
||||
-from supysonic.managers.user import UserManager
|
||||
-
|
||||
-import unittest
|
||||
-import uuid
|
||||
-
|
||||
-class UserManagerTestCase(unittest.TestCase):
|
||||
- def setUp(self):
|
||||
- # Create an empty sqlite database in memory
|
||||
- self.store = db.get_store("sqlite:")
|
||||
- # Read schema from file
|
||||
- with open('schema/sqlite.sql') as sql:
|
||||
- schema = sql.read()
|
||||
- # Create tables on memory database
|
||||
- for command in schema.split(';'):
|
||||
- self.store.execute(command)
|
||||
- # Create some users
|
||||
- self.assertEqual(UserManager.add(self.store, 'alice', 'alice', 'test@example.com', True), UserManager.SUCCESS)
|
||||
- self.assertEqual(UserManager.add(self.store, 'bob', 'bob', 'bob@example.com', False), UserManager.SUCCESS)
|
||||
- self.assertEqual(UserManager.add(self.store, 'charlie', 'charlie', 'charlie@example.com', False), UserManager.SUCCESS)
|
||||
-
|
||||
- def test_encrypt_password(self):
|
||||
- self.assertEqual(UserManager._UserManager__encrypt_password('password','salt'), ('59b3e8d637cf97edbe2384cf59cb7453dfe30789', 'salt'))
|
||||
- self.assertEqual(UserManager._UserManager__encrypt_password('pass-word','pepper'), ('d68c95a91ed7773aa57c7c044d2309a5bf1da2e7', 'pepper'))
|
||||
-
|
||||
- def test_get_user(self):
|
||||
- # Get existing users
|
||||
- for name in ['alice', 'bob', 'charlie']:
|
||||
- user = self.store.find(db.User, db.User.name == name).one()
|
||||
- self.assertEqual(UserManager.get(self.store, user.id), (UserManager.SUCCESS, user))
|
||||
- # Get with invalid UUID
|
||||
- self.assertEqual(UserManager.get(self.store, 'invalid-uuid'), (UserManager.INVALID_ID, None))
|
||||
- # Non-existent user
|
||||
- self.assertEqual(UserManager.get(self.store, uuid.uuid4()), (UserManager.NO_SUCH_USER, None))
|
||||
-
|
||||
- def test_add_user(self):
|
||||
- # Create duplicate
|
||||
- self.assertEqual(UserManager.add(self.store, 'alice', 'alice', 'test@example.com', True), UserManager.NAME_EXISTS)
|
||||
-
|
||||
- def test_delete_user(self):
|
||||
- # Delete existing users
|
||||
- for name in ['alice', 'bob', 'charlie']:
|
||||
- user = self.store.find(db.User, db.User.name == name).one()
|
||||
- self.assertEqual(UserManager.delete(self.store, user.id), UserManager.SUCCESS)
|
||||
- # Delete invalid UUID
|
||||
- self.assertEqual(UserManager.delete(self.store, 'invalid-uuid'), UserManager.INVALID_ID)
|
||||
- # Delete non-existent user
|
||||
- self.assertEqual(UserManager.delete(self.store, uuid.uuid4()), UserManager.NO_SUCH_USER)
|
||||
-
|
||||
- def test_try_auth(self):
|
||||
- # Test authentication
|
||||
- for name in ['alice', 'bob', 'charlie']:
|
||||
- user = self.store.find(db.User, db.User.name == name).one()
|
||||
- self.assertEqual(UserManager.try_auth(self.store, name, name), (UserManager.SUCCESS, user))
|
||||
- # Wrong password
|
||||
- self.assertEqual(UserManager.try_auth(self.store, name, 'bad'), (UserManager.WRONG_PASS, None))
|
||||
- # Non-existent user
|
||||
- self.assertEqual(UserManager.try_auth(self.store, 'null', 'null'), (UserManager.NO_SUCH_USER, None))
|
||||
-
|
||||
- def test_change_password(self):
|
||||
- # With existing users
|
||||
- for name in ['alice', 'bob', 'charlie']:
|
||||
- user = self.store.find(db.User, db.User.name == name).one()
|
||||
- # God password
|
||||
- self.assertEqual(UserManager.change_password(self.store, user.id, name, 'newpass'), UserManager.SUCCESS)
|
||||
- self.assertEqual(UserManager.try_auth(self.store, name, 'newpass'), (UserManager.SUCCESS, user))
|
||||
- # Wrong password
|
||||
- self.assertEqual(UserManager.change_password(self.store, user.id, 'badpass', 'newpass'), UserManager.WRONG_PASS)
|
||||
- # With invalid UUID
|
||||
- self.assertEqual(UserManager.change_password(self.store, 'invalid-uuid', 'oldpass', 'newpass'), UserManager.INVALID_ID)
|
||||
- # Non-existent user
|
||||
- self.assertEqual(UserManager.change_password(self.store, uuid.uuid4(), 'oldpass', 'newpass'), UserManager.NO_SUCH_USER)
|
||||
-
|
||||
- def test_change_password2(self):
|
||||
- # With existing users
|
||||
- for name in ['alice', 'bob', 'charlie']:
|
||||
- self.assertEqual(UserManager.change_password2(self.store, name, 'newpass'), UserManager.SUCCESS)
|
||||
- user = self.store.find(db.User, db.User.name == name).one()
|
||||
- self.assertEqual(UserManager.try_auth(self.store, name, 'newpass'), (UserManager.SUCCESS, user))
|
||||
- # Non-existent user
|
||||
- self.assertEqual(UserManager.change_password2(self.store, 'null', 'newpass'), UserManager.NO_SUCH_USER)
|
||||
-
|
||||
-if __name__ == '__main__':
|
||||
- unittest.main()
|
||||
--
|
||||
2.13.5
|
||||
|
20
media-sound/supysonic/files/supysonic-watcher.initd
Normal file
20
media-sound/supysonic/files/supysonic-watcher.initd
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
EXEC="/usr/bin/supysonic-watcher"
|
||||
|
||||
PIDFILE="/tmp/supysonic-watcher.pid"
|
||||
|
||||
SUPYUSER="${SUPYUSER:-apache}"
|
||||
SUPYGROUP="${SUPYGROUP:-apache}"
|
||||
|
||||
start() {
|
||||
ebegin "Starting supysonic watcher"
|
||||
start-stop-daemon --pidfile "${PIDFILE}" -u "${SUPYUSER}:${SUPYGROUP}" --start --quiet --exec "${EXEC}" -- start
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping supysonic watcher"
|
||||
start-stop-daemon --pidfile "${PIDFILE}" -u "${SUPYUSER}:${SUPYGROUP}" --stop --quiet --exec "${EXEC}" -- stop
|
||||
eend $?
|
||||
}
|
7
media-sound/supysonic/metadata.xml
Normal file
7
media-sound/supysonic/metadata.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
|
||||
<pkgmetadata>
|
||||
<maintainer type="person">
|
||||
<email>tk+gentoo@meskal.net</email>
|
||||
</maintainer>
|
||||
</pkgmetadata>
|
43
media-sound/supysonic/supysonic-9999.ebuild
Normal file
43
media-sound/supysonic/supysonic-9999.ebuild
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Copyright 1999-2017 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=5
|
||||
|
||||
PYTHON_COMPAT=(python2_7)
|
||||
|
||||
inherit distutils-r1 git-r3
|
||||
|
||||
DESCRIPTION="python implementation of subsonic api"
|
||||
HOMEPAGE="https://github.com/spl0k/supysonic"
|
||||
EGIT_REPO_URI="https://github.com/spl0k/supysonic.git"
|
||||
|
||||
LICENSE="GPL-3"
|
||||
SLOT="0"
|
||||
KEYWORDS=""
|
||||
IUSE=""
|
||||
|
||||
DEPEND="dev-python/flask
|
||||
dev-python/storm
|
||||
dev-python/simplejson
|
||||
dev-python/requests
|
||||
dev-python/watchdog
|
||||
dev-python/pillow
|
||||
dev-python/python-daemon
|
||||
media-libs/mutagen
|
||||
media-sound/mpg123
|
||||
"
|
||||
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
EXAMPLES=("cgi-bin")
|
||||
|
||||
src_prepare(){
|
||||
epatch "${FILESDIR}"/0001-fixes-execution-from-initd-script.patch
|
||||
epatch "${FILESDIR}"/0002-setup.py-comment-pip-integration.patch
|
||||
}
|
||||
|
||||
python_install(){
|
||||
distutils-r1_python_install
|
||||
python_newscript cgi-bin/server.py supysonic-standalone
|
||||
newinitd "${FILESDIR}"/supysonic-watcher.initd supysonic-watcher
|
||||
}
|
Loading…
Add table
Reference in a new issue