--- #check options - name: check OPTIONS for billingnetworks type: item method: OPTIONS path: /api/billingnetworks/ conditions: is: code: 200 header: Accept-Post: application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-billingnetworks ok: options: - GET - HEAD - OPTIONS - POST perl_code: !!perl/code | { my ($retained) = @_; $retained->{blocks} = [{ip=>'fdfe::5a55:caff:fefa:9089',mask=>128}, {ip=>'fdfe::5a55:caff:fefa:908a'}, {ip=>'fdfe::5a55:caff:fefa:908b',mask=>128},]; } #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: name: test billing network ${unique_id} description: test billing network description ${unique_id} reseller_id: 1 blocks: ${blocks} retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork: body conditions: is: code: 200 #PUT test billingnetwork - name: PUT test billingnetwork type: item method: PUT path: '/${billingnetwork_path}' header: Content-Type: application/json Prefer: return=representation content: name: test billingnetwork PUT ${unique_id} description: test billing network description PUT ${unique_id} reseller_id: 1 blocks: ${blocks} conditions: is: code: 200 #GET billingnetwork - name: fetch PUT test billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork: body conditions: is: code: 200 #PATCH test billingnetwork - name: PATCH test billingnetwork type: item method: PATCH path: '/${billingnetwork_path}' header: Content-Type: application/json-patch+json Prefer: return=representation content: - op: replace path: /name value: test billingnetwork PATCH ${unique_id} conditions: is: code: 200 #GET billingnetwork - name: fetch PATCHed test billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork: body conditions: is: code: 200 #DELETE billingnetwork - name: terminate test billingnetwork type: item method: DELETE path: '${billingnetwork_path}' conditions: is: code: 204 #GET billingnetwork - name: try to fetch terminated billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork: body conditions: is: code: 404 #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv6 billing network 1 ${unique_id} description: test ipv6 billing network description 1 ${unique_id} reseller_id: 1 blocks: - ip: 'fdfe::5a55:caff:fefa:9089' mask: 128 status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv6_1: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv6_1}->{id}; delete $retained->{billingnetwork_ipv6_1}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv6_1}': *content #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv6 billing network 2 ${unique_id} description: test ipv6 billing network description 2 ${unique_id} reseller_id: 1 blocks: - ip: 'fdfe::5a55:caff:fefa:908a' mask: null status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv6_2: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv6_2}->{id}; delete $retained->{billingnetwork_ipv6_2}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv6_2}': *content #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv6 billing network 3 ${unique_id} description: test ipv6 billing network description 3 ${unique_id} reseller_id: 1 blocks: - ip: 'fdfe::5a55:caff:fefa:908b' mask: 128 status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv6_3: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv6_3}->{id}; delete $retained->{billingnetwork_ipv6_3}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv6_3}': *content #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv6 billing network 4 ${unique_id} description: test ipv6 billing network description 4 ${unique_id} reseller_id: 1 blocks: - ip: 'fdfe::5a55:caff:fefa:9089' mask: 128 - ip: 'fdfe::5a55:caff:fefa:908a' mask: null - ip: 'fdfe::5a55:caff:fefa:908b' mask: 128 status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv6_4: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv6_4}->{id}; delete $retained->{billingnetwork_ipv6_4}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv6_4}': *content #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv4 billing network 1 ${unique_id} description: test ipv4 billing network description 1 ${unique_id} reseller_id: 1 blocks: - ip: '10.0.4.7' mask: 26 status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv4_1: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv4_1}->{id}; delete $retained->{billingnetwork_ipv4_1}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv4_1}': *content #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv4 billing network 2 ${unique_id} description: test ipv4 billing network description 2 ${unique_id} reseller_id: 1 blocks: - ip: '10.0.4.99' mask: 26 status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv4_2: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv4_2}->{id}; delete $retained->{billingnetwork_ipv4_2}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv4_2}': *content #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv4 billing network 3 ${unique_id} description: test ipv4 billing network description 3 ${unique_id} reseller_id: 1 blocks: - ip: '10.0.5.9' mask: 24 status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv4_3: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv4_3}->{id}; delete $retained->{billingnetwork_ipv4_3}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv4_3}': *content #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv4 billing network 4 ${unique_id} description: test ipv4 billing network description 4 ${unique_id} reseller_id: 1 blocks: - ip: '10.0.6.9' mask: 24 status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv4_4: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv4_4}->{id}; delete $retained->{billingnetwork_ipv4_4}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv4_4}': *content #POST test billingnetwork - name: POST test billingnetwork type: item method: POST path: /api/billingnetworks/ header: Content-Type: application/json Prefer: return=representation content: &content name: test ipv4 billing network 5 ${unique_id} description: test ipv4 billing network description 5 ${unique_id} reseller_id: 1 blocks: - ip: '10.0.4.7' mask: 26 - ip: '10.0.4.99' mask: 26 - ip: '10.0.5.9' mask: 24 - ip: '10.0.6.9' mask: 24 status: active retain: billingnetwork_path: header.location conditions: is: code: 201 #GET billingnetwork - name: fetch POSTed billingnetwork type: item method: GET path: '/${billingnetwork_path}' retain: billingnetwork_ipv4_5: body perl_code: !!perl/code | { my ($retained) = @_; delete $retained->{billingnetwork_ipv4_5}->{id}; delete $retained->{billingnetwork_ipv4_5}->{_links}; } conditions: is: code: 200 is_deeply: '${billingnetwork_ipv4_5}': *content #compare filtered collection - name: compare filtered collection type: item method: GET path: '/api/billingnetworks/?page=1&rows=5&ip=fdfe::5a55:caff:fefa:9089&name=%25${unique_id}' retain: collection: body perl_code: !!perl/code | { my ($retained) = @_; $retained->{expected} = [ $retained->{billingnetwork_ipv6_1}, $retained->{billingnetwork_ipv6_4} ]; map { delete $_->{id} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; map { delete $_->{_links} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; } conditions: is: code: 200 is_deeply: '${collection}._embedded.ngcp:billingnetworks': ${expected} #compare filtered collection - name: compare filtered collection type: item method: GET path: '/api/billingnetworks/?page=1&rows=5&ip=10.0.4.0&name=%25${unique_id}' retain: collection: body perl_code: !!perl/code | { my ($retained) = @_; $retained->{expected} = [ $retained->{billingnetwork_ipv4_1}, $retained->{billingnetwork_ipv4_5} ]; map { delete $_->{id} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; map { delete $_->{_links} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; } conditions: is: code: 200 is_deeply: '${collection}._embedded.ngcp:billingnetworks': ${expected} #compare filtered collection - name: compare filtered collection type: item method: GET path: '/api/billingnetworks/?page=1&rows=5&ip=10.0.4.64&name=%25${unique_id}' retain: collection: body perl_code: !!perl/code | { my ($retained) = @_; $retained->{expected} = [ $retained->{billingnetwork_ipv4_2}, $retained->{billingnetwork_ipv4_5} ]; map { delete $_->{id} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; map { delete $_->{_links} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; } conditions: is: code: 200 is_deeply: '${collection}._embedded.ngcp:billingnetworks': ${expected} #compare filtered collection - name: compare filtered collection type: item method: GET path: '/api/billingnetworks/?page=1&rows=5&ip=10.0.5.255&name=%25${unique_id}' retain: collection: body perl_code: !!perl/code | { my ($retained) = @_; $retained->{expected} = [ $retained->{billingnetwork_ipv4_3}, $retained->{billingnetwork_ipv4_5} ]; map { delete $_->{id} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; map { delete $_->{_links} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; } conditions: is: code: 200 is_deeply: '${collection}._embedded.ngcp:billingnetworks': ${expected} #compare filtered collection - name: compare filtered collection type: item method: GET path: '/api/billingnetworks/?page=1&rows=5&ip=10.0.6.255&name=%25${unique_id}' retain: collection: body perl_code: !!perl/code | { my ($retained) = @_; $retained->{expected} = [ $retained->{billingnetwork_ipv4_4}, $retained->{billingnetwork_ipv4_5} ]; map { delete $_->{id} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; map { delete $_->{_links} } @{$retained->{collection}->{'_embedded'}->{'ngcp:billingnetworks'}}; } conditions: is: code: 200 is_deeply: '${collection}._embedded.ngcp:billingnetworks': ${expected}