Ejemplo n.º 1
0
    def test_only_me_can_delete_account(self):
        """
        Accounts can only be deleted by authed owner
        :return:
        """
        # setup
        self.test_create_account()
        view = AccountViewSet.as_view({'delete': 'destroy'})
        account = Account.objects.get(username=self.username)
        client = APIClient()

        # auth with jwt
        response = client.post('/api-token-auth/',
                               self.json_account_credentials,
                               format='json')

        token = response.data['token']
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Make request
        client.credentials(HTTP_AUTHORIZATION='Bearer ' + token)
        response = client.delete('/api/v1/accounts/' + self.username + '/')
        # Asserts
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        # check no object exists
        try:
            account = Account.objects.get(username=self.username)
        except:
            account = None
        self.assertIsNone(account)
Ejemplo n.º 2
0
    def test_only_me_can_delete_account(self):
        """
        Accounts can only be deleted by authed owner
        :return:
        """
        # setup
        self.test_create_account()
        view = AccountViewSet.as_view({'delete': 'destroy'})
        account = Account.objects.get(username=self.username)
        client = APIClient()

        # auth with jwt
        response = client.post('/api-token-auth/',
                               self.json_account_credentials,
                               format='json')

        token = response.data['token']
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Make request
        client.credentials(HTTP_AUTHORIZATION='Bearer ' + token)
        response = client.delete('/api/v1/accounts/'+self.username+'/')
        # Asserts
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        # check no object exists
        try:
            account = Account.objects.get(username=self.username)
        except:
            account = None
        self.assertIsNone(account)
Ejemplo n.º 3
0
    def test_create_account(self):
        # setup
        view = AccountViewSet.as_view({'post': 'create'})
        client = APIClient()

        # auth with jwt
        response = client.post('/api/v1/accounts/',
                               self.json_new_account_data,
                               format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        account = Account.objects.get(username=self.username)
        self.assertIsNotNone(account)
Ejemplo n.º 4
0
    def test_create_account(self):
        # setup
        view = AccountViewSet.as_view({'post': 'create'})
        client = APIClient()

        # auth with jwt
        response = client.post('/api/v1/accounts/',
                               self.json_new_account_data,
                               format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        account = Account.objects.get(username=self.username)
        self.assertIsNotNone(account)
Ejemplo n.º 5
0
from django.contrib import admin
from rest_framework import routers
from authentication.views import AccountViewSet, LoginView, LogoutView

from transferfund.views import getAccountInfoView
from transferfund.views import getAllAccountsView
from transferfund.views import getTransactionHistoryView
from transferfund.views import handleInternalTransfer
from transferfund.views import handleCheckDeposit
from transferfund.views import getContactsInfoView
from transferfund.views import handleExternalTransfer
from transferfund.views import addContactView

urlpatterns = [
    # url(r'^admin/', include(admin.site.urls)),
    url(r'^account', AccountViewSet.as_view(), name='account'),
    url(r'^auth/login', LoginView.as_view(), name='login'),
    url(r'^auth/logout', LogoutView.as_view(), name='logout'),
    url(r'^loanmanage/', include('loanmanagement.urls')),
    url(r'^transferfund/getAccountInfo',
        getAccountInfoView.as_view(),
        name="getAccountInfo"),
    url(r'^transferfund/getAllAccounts',
        getAllAccountsView.as_view(),
        name="getAllAccounts"),
    url(r'^transferfund/getTransactionHistory',
        getTransactionHistoryView.as_view(),
        name="getTransactionHistory"),
    url(r'^transferfund/internalTransfer',
        handleInternalTransfer.as_view(),
        name="handleInternalTransfer"),